This repository has been archived by the owner on Feb 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.rules.bolt
167 lines (133 loc) · 3.2 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
path / {
read() { true }
write() { false }
}
path /songs/{song_key} is Song;
type Song{
create() { auth != null }
update() { auth != null }
validate() { isSnakeCase(key()) }
name: String
teams: Map<TeamID, True>
lives: Map<LiveID, True>
}
path /characters/{character_key} is Character;
type Character{
create() { auth != null }
update() { auth != null }
validate() { isSnakeCase(key()) }
name: String
teams: Map<TeamID, True>
}
path /teams/{team_key} is Team;
type Team{
create() { auth != null }
update() { auth != null }
validate() { isSnakeCase(key()) }
name: String
characters: Map<CharacterID, True>
songs: Map<SongID, True>
mds: Map<MdID, True>
}
path /mds/{md_key} is Md;
type Md{
create() { auth != null }
update() { auth != null }
validate() { isSnakeCase(key()) }
name: String
team: TeamID
Lives: Map<LiveID, True>
}
path /series/{series_key} is Series;
type Series{
create() { auth != null }
update() { auth != null }
validate() { isSnakeCase(key()) }
start_at: Date
end_at: Date
episodes : Map<EpisodeID, True>
}
path /episodes {
index() {['number', 'series']}
/{episode_key} is Episode;
}
type Episode{
create() { auth != null }
update() { auth != null }
validate() { isSnakeCase(key()) }
number: Number
series: SeriesID
title : String
}
path /brands/{brand_key} is Brand;
type Brand{
create() { auth != null }
update() { auth != null }
validate() { isSnakeCase(key()) }
name: String
coordinates : Map<CoordinateID, True>
}
path /coordinates/{coordinate_key} is Coordinate;
type Coordinate{
create() { auth != null }
update() { auth != null }
validate() { isSnakeCase(key()) }
name: String
brand: BrandID
Character: CharacterID
}
path /lives/{live_key} is Live;
type Live{
create() { auth != null }
update() { auth != null }
validate() { isSnakeCase(key()) }
md: String
coordinates : Map<CoordinateID, True>
episode: EpisodeID
song: SongID
team: TeamID
}
/* Types */
type True extends Boolean{
validate() { this }
}
type SnakeCase extends String{
validate() { isSnakaCase(this) }
}
type Date extends String{
validate() { isDate(this) }
}
type NumberString extends String{
validate() { isNumberString(this) }
}
function isSnakeCase(val){ return val.matches(/^[a-z_]+$/) }
function isDate(val){ return val.matches(/^(19|20)[0-9][0-9][-\/. ](0[1-9]|1[012])[-\/. ](0[1-9]|[12][0-9]|3[01])$/) }
function isNumberString(val){ return val.matches(/^[0-9]+$/) }
/* ID */
type SongID extends String{
validate() { return root.songs[this] != null }
}
type CharacterID extends String{
validate() { return root.characters[this] != null }
}
type TeamID extends String{
validate() { return root.teams[this] != null }
}
type MdID extends String{
validate() { return root.mds[this] != null }
}
type SeriesID extends String{
validate() { return root.series[this] != null }
}
type EpisodeID extends String{
validate() { return root.episodes[this] != null }
}
type BrandID extends String{
validate() { return root.brands[this] != null }
}
type CoordinateID extends String{
validate() { return root.coordinates[this] != null }
}
type LiveID extends String{
validate() { return root.lives[this] != null }
}