-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.zmodel
54 lines (45 loc) · 1.11 KB
/
schema.zmodel
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
53
54
datasource db {
provider = 'sqlite'
url = 'file:./dev.db'
}
generator client {
provider = "prisma-client-js"
}
plugin hooks {
provider = '@zenstackhq/tanstack-query'
target = 'vue'
output = 'lib/hooks'
}
/**
* User model
*/
model User {
id String @id @default(cuid())
email String @unique @email
name String
password String @password @omit @length(8, 16)
posts Post[]
// everybody can signup
@@allow('create', true)
// user profiles are public
@@allow('read', true)
// full access by self
@@allow('all', auth() == this)
}
/**
* Post model
*/
model Post {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String @length(1, 256)
content String
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId String @default(auth().id)
// allow read for all signin users
@@allow('read', auth() != null && published)
// full access by author
@@allow('all', author == auth())
}