-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.zmodel
58 lines (47 loc) · 1.2 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
55
56
57
58
// This is a sample model to get you started.
/// A sample data source using local sqlite db.
datasource db {
provider = 'sqlite'
url = 'file:./dev.db'
}
generator client {
provider = "prisma-client-js"
}
plugin hooks {
provider = '@zenstackhq/tanstack-query'
output = "./hooks"
target = "react"
portable=true
}
/// User model
model User {
id String @id @default(cuid())
email String @unique @email @length(6, 32)
password String @password @omit
posts Post[]
// everybody can signup
@@allow('create', true)
// full access by self
@@allow('all', auth() == this)
}
// enum Food {
// Banana
// Apple
// Orange
// }
/// 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
// food Food @default(Apple)
// allow read for all signin users
@@allow('read', auth() != null && published)
// full access by author
@@allow('all', author == auth())
}