-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.zmodel
40 lines (32 loc) · 957 Bytes
/
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
datasource db {
provider = 'sqlite'
url = 'file:./dev.db'
}
generator client {
provider = "prisma-client-js"
}
model User {
id String @id @default(cuid())
email String @unique @email @length(6, 32)
password String @password @omit
posts Post[]
// everybody can sign up
@@allow('create', true)
// full access by self
@@allow('all', auth() == this)
}
model Post {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String @length(1, 256)
slug String @length(1, 256) @unique
content String @length(1, 100000)
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId String
// allow read for all signin users
@@allow('read', auth() != null && published)
// full access by author
@@allow('all', auth() == author)
}