-
Notifications
You must be signed in to change notification settings - Fork 385
/
project.dbx
261 lines (231 loc) · 8.07 KB
/
project.dbx
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
// project contains information about a user project.
model project (
key id
index (
name projects_public_id_index
fields public_id
)
index (
name projects_owner_id_index
fields owner_id
)
// id is a UUID used for identifying the project.
field id blob
// public_id is a UUID that's used in web requests.
field public_id blob ( nullable )
// name is a identifier that's shown to the user.
field name text ( updatable )
// description helps users to clarify what the project is for.
field description text ( updatable )
// usage_limit defines maximum allowed bytes that can be stored.
field usage_limit int64 ( nullable, updatable )
// bandwidth_limit defines maximum allowed bandwidth per month in bytes.
field bandwidth_limit int64 ( nullable, updatable )
// user_specified_usage_limit is set by the user to limit their bytes that can be stored.
field user_specified_usage_limit int64 ( nullable, updatable )
// user_specified_bandwidth_limit is set by the user to limit their bytes that downloaded.
field user_specified_bandwidth_limit int64 ( nullable, updatable )
// segment_limit specifies how many segments can be stored in the project.
field segment_limit int64 ( nullable, updatable, default 1000000)
// rate_limit defines maximum requests per second the project can use.
// See golang.org/x/time/rate#Limiter for details.
field rate_limit int ( nullable, updatable )
// burst_limit defines number of requests that are not throttled by rate_limit.
// See golang.org/x/time/rate#Limiter for details.
field burst_limit int ( nullable, updatable )
// max_buckets is the maximum number of buckets that can be created for the project.
field max_buckets int ( nullable, updatable )
// user_agent is the referred partner who created the project.
field user_agent blob ( nullable, updatable )
// owner_id refers to the user UUID in user.id.
field owner_id blob
// salt is used for salting the user passphrase for the content.
field salt blob ( nullable )
// created_at indicates when the project was created.
field created_at timestamp ( autoinsert )
// placement to be used for every new bucket.
field default_placement int (nullable, updatable)
// versioning state to be used for every new bucket.
//0 - unsupported (versioning for new buckets is not supported)
//1 - unversioned (versioning for new buckets is supported but not enabled)
//2 - VersioningEnabled (versioning for new buckets is supported and enabled)
// note: suspended is not a valid state for new buckets
field default_versioning int (updatable, default 1)
)
create project ( )
update project ( where project.id = ? )
delete project ( where project.id = ? )
read one (
select project.salt
where project.id = ?
)
read one (
select project
where project.public_id = ?
)
read one (
select project
where project.id = ?
)
read one (
select project.usage_limit
where project.id = ?
)
read one (
select project.bandwidth_limit
where project.id = ?
)
read one (
select project.user_specified_usage_limit
where project.id = ?
)
read one (
select project.user_specified_bandwidth_limit
where project.id = ?
)
read one (
select project.segment_limit
where project.id = ?
)
read one (
select project.max_buckets
where project.id = ?
)
read one (
select project.bandwidth_limit project.usage_limit project.segment_limit project.rate_limit project.burst_limit
where project.id = ?
)
read one (
select project.default_versioning
where project.id = ?
)
read one (
select project.user_agent
where project.id = ?
)
read all (
select project
)
read all (
select project
where project.created_at < ?
orderby asc project.created_at
)
read all (
select project
where project.owner_id = ?
orderby asc project.created_at
)
read all (
select project
join project.id = project_member.project_id
where project_member.member_id = ?
orderby asc project.name
)
read limitoffset (
select project
where project.created_at < ?
orderby asc project.created_at
)
// project_member is an association table between projects and users.
// It indicates which users have access to the specific project.
model project_member (
key member_id project_id
index ( fields project_id )
// member_id is the user that can access the project.
field member_id user.id cascade
// project_id is the project that can be accessed.
field project_id project.id cascade
// created_at indicates when the user was added as a member.
field created_at timestamp ( autoinsert )
)
create project_member ( )
delete project_member (
where project_member.member_id = ?
where project_member.project_id = ?
)
read all (
select project_member
where project_member.member_id = ?
)
// project_invitation contains info for pending project member invitations.
model project_invitation (
key project_id email
index ( fields project_id )
index ( fields email )
// project_id is the ID of the project that the invitation is for.
field project_id project.id cascade
// email is the normalized form of the email address that the invitation email was sent to.
// See satellitedb.normalizeEmail for details.
field email text
// inviter_id is the ID of the user who sent the invitation.
field inviter_id user.id setnull ( nullable, updatable )
// created_at is the time that the invitation was created.
field created_at timestamp ( autoinsert, updatable )
)
create project_invitation ( replace )
read one (
select project_invitation
where project_invitation.project_id = ?
where project_invitation.email = ?
)
read all (
select project_invitation
where project_invitation.email = ?
)
read all (
select project_invitation
where project_invitation.project_id = ?
)
update project_invitation (
where project_invitation.project_id = ?
where project_invitation.email = ?
)
delete project_invitation (
where project_invitation.project_id = ?
where project_invitation.email = ?
)
// api_key is used to authenticate in requests.
model api_key (
key id
unique head
unique name project_id
// id is a UUID for the api key.
field id blob
// project_id is a UUID that refers to project.id.
field project_id project.id cascade
// head is restrictions for the api key.
field head blob
// name helps users to identify the purpose of the api key.
field name text (updatable)
// secret is the macaroon secret.
field secret blob
// user_agent is the referred partner who created the project.
field user_agent blob (nullable)
// created_at indicates when the api key was added.
field created_at timestamp (autoinsert)
// created_by is an UUID of the user who created this key.
field created_by user.id restrict (nullable)
)
create api_key ( )
update api_key (
where api_key.id = ?
noreturn
)
delete api_key ( where api_key.id = ? )
read one (
select api_key project.public_id
join project.id = api_key.project_id
where api_key.id = ?
)
read one (
select api_key project.public_id project.rate_limit project.burst_limit project.segment_limit project.usage_limit project.bandwidth_limit
join project.id = api_key.project_id
where api_key.head = ?
)
read one (
select api_key project.public_id
join project.id = api_key.project_id
where api_key.name = ?
where api_key.project_id = ?
)