-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathkeystone.ts
57 lines (50 loc) · 1.33 KB
/
keystone.ts
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
import { config } from '@keystone-6/core'
import { lists } from './schema'
import type { Context } from '.keystone/types'
export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
onConnect: async (context: Context) => {
if ((await context.db.Person.count()) > 0) return
const people = []
for (let i = 0; i < 5; ++i) {
people.push(await context.db.Person.createOne({ data: { name: `Person #${i}` } }))
}
for (const { id } of people) {
// TODO: should work with .sudo()
// await context.sudo().db.Nice.createOne({
await context.prisma.priority.create({
data: {
person: {
connect: {
id,
},
},
},
})
await context.prisma.nice.create({
data: {
person: {
connect: {
id,
},
},
},
})
await context.prisma.naughty.create({
data: {
person: {
connect: {
id,
},
},
},
})
}
},
// WARNING: this is only needed for our monorepo examples, dont do this
prismaClientPath: 'node_modules/myprisma',
},
lists,
})