-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathschema.teo
148 lines (130 loc) · 2.93 KB
/
schema.teo
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
connector {
// SQLite
// provider: .sqlite,
// url: "sqlite:./database.sqlite",
// MySQL
// provider: .mysql,
// url: "mysql://localhost:3306/adminbackend",
// PostgreSQL
provider: .postgres,
url: "postgres://localhost:5432/adminbackend4",
}
server {
bind: ("0.0.0.0", 5052)
}
client kotlin {
provider: .kotlin,
dest: "../teo-admin-dev-client-kotlin",
host: .string("http://localhost:5052"),
package: true,
}
client swift {
provider: .swift,
dest: "../teo-admin-dev-client-swift",
host: .string("http://localhost:5052"),
package: true,
}
admin {
dest: "../teo-admin-dev",
host: .inject("process.env.TEO_HOST"),
languages: [.enUs, .enUk, .de, .es, .fr, .he, .hi, .ja, .ko, .zhCn, .zhTw]
}
@identity.tokenIssuer($identity.jwt(expired: 3600 * 24 * 365))
@identity.jwtSecret(ENV["JWT_SECRET"]!) @admin.administrator
model Root {
@id @autoIncrement @readonly
id: Int
@unique @onSet($if($presents, $isEmail)) @identity.id
email: String
@writeonly @onSet($presents.bcrypt.salt) @admin.secureInput
@identity.checker($get(.value).presents.bcrypt.verify($self.get(.password).presents))
password: String
include handler identity.signIn
include handler identity.identity
}
@identity.tokenIssuer($identity.jwt(expired: 3600 * 24 * 365))
@identity.jwtSecret(ENV["JWT_SECRET"]!) @admin.administrator
model Admin {
@id @autoIncrement @readonly
id: Int
@unique @onSet($if($presents, $isEmail)) @identity.id
email: String
@unique @identity.id
phoneNo: String
@writeonly @onSet($presents.bcrypt.salt) @admin.secureInput
@identity.checker($get(.value).presents.bcrypt.verify($self.get(.password).presents))
password: String
include handler identity.signIn
include handler identity.identity
}
model Item {
@id @autoIncrement @readonly
id: Int
@admin.title
name: String
}
model Product {
@id @autoIncrement @readonly
id: Int
name: String
stock: Int
@foreignKey
categoryId: Int
@relation(fields: .categoryId, references: .id)
category: Category
}
model Category {
@id @autoIncrement @readonly
id: Int
name: String
@relation(fields: .id, references: .categoryId)
products: Product[]
}
enum Sex {
male
female
}
model Record {
@id @autoIncrement @readonly
id: Int
string: String
bool: Bool
int: Int
float: Float
decimal: Decimal
date: Date
dateTime: DateTime
sex: Sex
strings: String[]
genders: Sex[]
}
model NullableRecord {
@id @autoIncrement @readonly
id: Int
string: String?
bool: Bool?
int: Int?
float: Float?
decimal: Decimal?
date: Date?
dateTime: DateTime?
sex: Sex?
strings: String[]?
genders: Sex?[]?
}
middlewares [identity.identityFromJwt(secret: ENV["JWT_SECRET"]!)]
autoseed dataset default {
group Admin {
record admin {
email: "[email protected]",
phoneNo: "13588888888",
password: "Aa123456"
}
}
group Root {
record root {
email: "[email protected]",
password: "Aa123456"
}
}
}