forked from ymc9/prisma-new-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.ts
More file actions
37 lines (32 loc) · 768 Bytes
/
script.ts
File metadata and controls
37 lines (32 loc) · 768 Bytes
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
import { PrismaClient } from "./.prisma/client";
import { enhance } from "./.zenstack/enhance";
const prisma = new PrismaClient();
const prismaExtended = prisma.$extends({
model: {
user: {
async signUp(email: string) {
return prisma.user.create({ data: { email } });
},
},
},
});
const db = enhance(prisma);
const dbExtended = enhance(prismaExtended);
async function main() {
const user = await db.user.create({
data: {
name: "John Doe",
email: "a@b.com",
},
});
console.log(user.email);
const post = await db.post.create({
data: {
title: "Hello World",
},
});
console.log(post.title);
const newUser = await dbExtended.user.signUp("a@b.com");
console.log(newUser.email);
}
main();