-
Notifications
You must be signed in to change notification settings - Fork 0
/
seed.ts
52 lines (50 loc) · 1.13 KB
/
seed.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
import { prisma } from "./prisma";
const main = async(): Promise<void> => {
const alice = await prisma.user.upsert({
where: { email: "alice@prisma.io" },
update: {},
create: {
email: "alice@prisma.io",
name: "Alice",
posts: {
create: {
title: "Check out Prisma with Next.js",
content: "https://www.prisma.io/nextjs",
published: true
}
}
}
});
const bob = await prisma.user.upsert({
where: { email: "bob@prisma.io" },
update: {},
create: {
email: "bob@prisma.io",
name: "Bob",
posts: {
create: [
{
title: "Follow Prisma on Twitter",
content: "https://twitter.com/prisma",
published: true
},
{
title: "Follow Nexus on Twitter",
content: "https://twitter.com/nexusgql",
published: true
}
]
}
}
});
console.log({ alice, bob });
};
main()
.then(async() => {
await prisma.$disconnect();
})
.catch(async(e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});