-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.ts
43 lines (37 loc) · 769 Bytes
/
script.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
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient({
log: ["query"],
});
async function createUser() {
const user = await prisma.user.create({
data: {
name: "Bob",
email: "bob@prisma.io",
posts: {
create: {
title: "Hello World",
},
},
},
});
console.log(user);
}
async function main() {
// await createUser();
const users = await prisma.user.findMany({
relationLoadStrategy: "join", // or 'query',
include: {
posts: true,
},
});
console.dir({ users }, { depth: null });
}
main()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});