-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
44 lines (36 loc) · 838 Bytes
/
script.js
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
const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
// A `main` function so that you can use async/await
async function main() {
// Create the user
const newUser = await prisma.user.create({
data: {},
})
// Create a Category
const newCategory = await prisma.category.create({
data: {},
})
// Create a post
const newPost = await prisma.post.create({
data: {
author: {
connect: {
id: newUser.id
}
},
categories: {
connect: {
id: newCategory.id
}
},
},
})
console.log(newPost)
}
main()
.catch(e => {
throw e
})
.finally(async () => {
await prisma.$disconnect()
})