-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
31 lines (26 loc) · 731 Bytes
/
main.ts
File metadata and controls
31 lines (26 loc) · 731 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
import { createClient } from './db';
async function main() {
const db = await createClient();
try {
// invalid email
await db.user.create({
data: { email: 'abc@xyz', age: 20, role: 'USER' }
})
} catch (err) {
console.log('Got expected error:', (err as Error).message);
}
try {
// admin is not an adult, plus not having a zenstack email
await db.user.create({
data: { email: 'john@gmail.com', age: 16, role: 'ADMIN' }
});
} catch (err) {
console.log('Got expected error:', (err as Error).message);
}
// success
const user = await db.user.create({
data: { email: 'john@zenstack.dev', age: 20, role: 'ADMIN' }
});
console.log('User create:', user);
}
main();