Skip to content

Commit bc77c5c

Browse files
committed
update
1 parent e6d9fca commit bc77c5c

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

packages/runtime/test/test-schema/schema.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,52 @@ export const schema = {
1212
},
1313
models: {
1414
User: {
15+
name: "User",
1516
fields: {
1617
id: {
18+
name: "id",
1719
type: "String",
1820
id: true,
1921
attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }],
2022
default: ExpressionUtils.call("cuid")
2123
},
2224
createdAt: {
25+
name: "createdAt",
2326
type: "DateTime",
2427
attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }],
2528
default: ExpressionUtils.call("now")
2629
},
2730
updatedAt: {
31+
name: "updatedAt",
2832
type: "DateTime",
2933
updatedAt: true,
3034
attributes: [{ name: "@updatedAt" }]
3135
},
3236
email: {
37+
name: "email",
3338
type: "String",
3439
unique: true,
3540
attributes: [{ name: "@unique" }]
3641
},
3742
name: {
43+
name: "name",
3844
type: "String",
3945
optional: true
4046
},
4147
role: {
48+
name: "role",
4249
type: "Role",
4350
attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("USER") }] }],
4451
default: "USER"
4552
},
4653
posts: {
54+
name: "posts",
4755
type: "Post",
4856
array: true,
4957
relation: { opposite: "author" }
5058
},
5159
profile: {
60+
name: "profile",
5261
type: "Profile",
5362
optional: true,
5463
relation: { opposite: "user" }
@@ -65,47 +74,57 @@ export const schema = {
6574
}
6675
},
6776
Post: {
77+
name: "Post",
6878
fields: {
6979
id: {
80+
name: "id",
7081
type: "String",
7182
id: true,
7283
attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }],
7384
default: ExpressionUtils.call("cuid")
7485
},
7586
createdAt: {
87+
name: "createdAt",
7688
type: "DateTime",
7789
attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }],
7890
default: ExpressionUtils.call("now")
7991
},
8092
updatedAt: {
93+
name: "updatedAt",
8194
type: "DateTime",
8295
updatedAt: true,
8396
attributes: [{ name: "@updatedAt" }]
8497
},
8598
title: {
99+
name: "title",
86100
type: "String"
87101
},
88102
content: {
103+
name: "content",
89104
type: "String",
90105
optional: true
91106
},
92107
published: {
108+
name: "published",
93109
type: "Boolean",
94110
attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }],
95111
default: false
96112
},
97113
author: {
114+
name: "author",
98115
type: "User",
99116
attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }],
100117
relation: { opposite: "posts", fields: ["authorId"], references: ["id"], onUpdate: "Cascade", onDelete: "Cascade" }
101118
},
102119
authorId: {
120+
name: "authorId",
103121
type: "String",
104122
foreignKeyFor: [
105123
"author"
106124
]
107125
},
108126
comments: {
127+
name: "comments",
109128
type: "Comment",
110129
array: true,
111130
relation: { opposite: "post" }
@@ -122,33 +141,40 @@ export const schema = {
122141
}
123142
},
124143
Comment: {
144+
name: "Comment",
125145
fields: {
126146
id: {
147+
name: "id",
127148
type: "String",
128149
id: true,
129150
attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }],
130151
default: ExpressionUtils.call("cuid")
131152
},
132153
createdAt: {
154+
name: "createdAt",
133155
type: "DateTime",
134156
attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }],
135157
default: ExpressionUtils.call("now")
136158
},
137159
updatedAt: {
160+
name: "updatedAt",
138161
type: "DateTime",
139162
updatedAt: true,
140163
attributes: [{ name: "@updatedAt" }]
141164
},
142165
content: {
166+
name: "content",
143167
type: "String"
144168
},
145169
post: {
170+
name: "post",
146171
type: "Post",
147172
optional: true,
148173
attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("postId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }],
149174
relation: { opposite: "comments", fields: ["postId"], references: ["id"], onUpdate: "Cascade", onDelete: "Cascade" }
150175
},
151176
postId: {
177+
name: "postId",
152178
type: "String",
153179
optional: true,
154180
foreignKeyFor: [
@@ -162,37 +188,45 @@ export const schema = {
162188
}
163189
},
164190
Profile: {
191+
name: "Profile",
165192
fields: {
166193
id: {
194+
name: "id",
167195
type: "String",
168196
id: true,
169197
attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }],
170198
default: ExpressionUtils.call("cuid")
171199
},
172200
createdAt: {
201+
name: "createdAt",
173202
type: "DateTime",
174203
attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }],
175204
default: ExpressionUtils.call("now")
176205
},
177206
updatedAt: {
207+
name: "updatedAt",
178208
type: "DateTime",
179209
updatedAt: true,
180210
attributes: [{ name: "@updatedAt" }]
181211
},
182212
bio: {
213+
name: "bio",
183214
type: "String"
184215
},
185216
age: {
217+
name: "age",
186218
type: "Int",
187219
optional: true
188220
},
189221
user: {
222+
name: "user",
190223
type: "User",
191224
optional: true,
192225
attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("userId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }],
193226
relation: { opposite: "profile", fields: ["userId"], references: ["id"], onUpdate: "Cascade", onDelete: "Cascade" }
194227
},
195228
userId: {
229+
name: "userId",
196230
type: "String",
197231
unique: true,
198232
optional: true,
@@ -211,18 +245,22 @@ export const schema = {
211245
},
212246
typeDefs: {
213247
CommonFields: {
248+
name: "CommonFields",
214249
fields: {
215250
id: {
251+
name: "id",
216252
type: "String",
217253
attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }],
218254
default: ExpressionUtils.call("cuid")
219255
},
220256
createdAt: {
257+
name: "createdAt",
221258
type: "DateTime",
222259
attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }],
223260
default: ExpressionUtils.call("now")
224261
},
225262
updatedAt: {
263+
name: "updatedAt",
226264
type: "DateTime",
227265
updatedAt: true,
228266
attributes: [{ name: "@updatedAt" }]

0 commit comments

Comments
 (0)