-
Notifications
You must be signed in to change notification settings - Fork 2
/
schema.keel
55 lines (50 loc) · 1.38 KB
/
schema.keel
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
model Todo {
fields {
complete Boolean @default(false)
title Text
description Text?
completedAt Timestamp?
owner Identity
project Project?
}
actions {
get todo(id)
list allTodos(complete?, project.id?) {
@where(todo.owner == ctx.identity)
}
delete deleteTodo(id)
update updateTodo(id) with (title?, description?, project.id?)
create createTodo() with (title, description?, project.id?) {
@permission(expression: ctx.isAuthenticated)
@set(todo.owner.id = ctx.identity.id)
}
update setCompletion(id) with (complete) @function
}
@permission(
actions: [get, list, update, delete],
expression: todo.owner == ctx.identity
)
}
model Project {
fields {
title Text
owner Identity
tasks Todo[]
}
actions {
get getProject(id)
list listProjects() {
@where(project.owner == ctx.identity)
}
delete deleteProject(id)
create createProject() with (title) {
@permission(expression: ctx.isAuthenticated)
@set(project.owner.id = ctx.identity.id)
}
update updateProject(id) with (title)
}
@permission(
actions: [get, list, update, delete],
expression: project.owner == ctx.identity
)
}