forked from luizfar/firedeaz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.rules.bolt
47 lines (41 loc) · 863 Bytes
/
database.rules.bolt
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
type UserId {
validate() { this.length > 0 && this == auth.uid }
}
type Board {
boardId: String,
user_id: UserId,
max_votes: Number,
date_created: String | Number,
text_editing_is_private: Boolean | Null,
columns: Object | Null,
boardContext: String | Null,
hide_vote: Boolean | Null
}
type Message {
text: String,
creating: Boolean,
user_id: UserId,
type: Object,
date: String | Number,
date_created: String | Number,
votes: Number | Null
}
function isUser(userKey) {
return userKey == auth.uid
}
path /boards {
/{boardId} is Board {
read() { isUser(this.user_id) }
write() { isUser(this.user_id) }
}
}
path /messages {
/{boardId} {
read() { auth != null }
write() { auth != null }
/{messageId} is Message {
read() { isUser(this.user_id) }
write() { isUser(this.user_id) }
}
}
}