-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-example-config.ts
More file actions
47 lines (44 loc) · 1.17 KB
/
test-example-config.ts
File metadata and controls
47 lines (44 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { defineConfig, defineEntity, text, number, boolean, enumField, hasMany } from './src/index'
// Example User entity with various features
const User = defineEntity('User', {
fields: {
email: text().required().email(),
name: text().required().min(2).max(100),
age: number().optional().min(0).max(150).integer(),
role: enumField('admin', 'user', 'guest').default('user'),
isActive: boolean().default(true),
},
relations: {
posts: hasMany('Post'),
},
behaviors: {
timestamps: true,
softDelete: true,
},
protected: 'write', // list/get public, create/update/remove protected
})
// Example Post entity
const Post = defineEntity('Post', {
fields: {
title: text().required().min(5).max(200),
content: text().required().min(10),
slug: text().required().unique(),
published: boolean().default(false),
viewCount: number().default(0).min(0),
},
behaviors: {
timestamps: true,
},
protected: 'all', // All operations require auth
})
export default defineConfig({
entities: [User, Post],
database: {
type: 'sqlite',
file: './test.db',
},
auth: {
enabled: true,
providers: ['credentials'],
},
})