-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.ts
More file actions
35 lines (30 loc) · 765 Bytes
/
script.ts
File metadata and controls
35 lines (30 loc) · 765 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
import { PrismaClient } from '@prisma/client';
import { enhance } from '@zenstackhq/runtime';
const prisma = new PrismaClient().$extends({
model: {
user: {
async signUp(email: string) {
return prisma.user.create({ data: { email } });
},
},
},
});
const db = enhance(prisma);
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 db.user.signUp('a@b.com');
console.log(newUser.email);
}
main();