node-appwrite 2.4.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug.yaml +82 -0
- package/.github/ISSUE_TEMPLATE/documentation.yaml +32 -0
- package/.github/ISSUE_TEMPLATE/feature.yaml +40 -0
- package/LICENSE +1 -1
- package/README.md +7 -7
- package/docs/examples/database/create-boolean-attribute.md +20 -0
- package/docs/examples/database/create-collection.md +1 -1
- package/docs/examples/database/create-document.md +1 -1
- package/docs/examples/database/create-email-attribute.md +20 -0
- package/docs/examples/database/create-enum-attribute.md +20 -0
- package/docs/examples/database/create-float-attribute.md +20 -0
- package/docs/examples/database/create-index.md +20 -0
- package/docs/examples/database/create-integer-attribute.md +20 -0
- package/docs/examples/database/create-ip-attribute.md +20 -0
- package/docs/examples/database/create-string-attribute.md +20 -0
- package/docs/examples/database/create-url-attribute.md +20 -0
- package/docs/examples/database/delete-attribute.md +20 -0
- package/docs/examples/database/delete-index.md +20 -0
- package/docs/examples/database/get-attribute.md +20 -0
- package/docs/examples/database/get-index.md +20 -0
- package/docs/examples/database/list-attributes.md +20 -0
- package/docs/examples/database/list-indexes.md +20 -0
- package/docs/examples/database/update-collection.md +1 -1
- package/docs/examples/functions/create-tag.md +1 -1
- package/docs/examples/functions/create.md +1 -1
- package/docs/examples/{health/get-queue-tasks.md → functions/list-runtimes.md} +2 -2
- package/docs/examples/health/{get-anti-virus.md → get-antivirus.md} +1 -1
- package/docs/examples/storage/create-file.md +1 -1
- package/docs/examples/teams/create.md +1 -1
- package/docs/examples/teams/get-membership.md +20 -0
- package/docs/examples/users/create.md +1 -1
- package/docs/examples/users/update-email.md +20 -0
- package/docs/examples/users/update-name.md +20 -0
- package/docs/examples/users/update-password.md +20 -0
- package/docs/examples/users/update-status.md +1 -1
- package/index.d.ts +1693 -235
- package/lib/client.js +5 -5
- package/lib/query.js +34 -0
- package/lib/services/account.js +18 -6
- package/lib/services/database.js +706 -47
- package/lib/services/functions.js +63 -12
- package/lib/services/health.js +4 -22
- package/lib/services/storage.js +21 -2
- package/lib/services/teams.js +93 -31
- package/lib/services/users.js +127 -5
- package/package.json +2 -2
package/lib/services/database.js
CHANGED
|
@@ -14,11 +14,13 @@ class Database extends Service {
|
|
|
14
14
|
* @param {string} search
|
|
15
15
|
* @param {number} limit
|
|
16
16
|
* @param {number} offset
|
|
17
|
+
* @param {string} cursor
|
|
18
|
+
* @param {string} cursorDirection
|
|
17
19
|
* @param {string} orderType
|
|
18
20
|
* @throws {AppwriteException}
|
|
19
21
|
* @returns {Promise}
|
|
20
22
|
*/
|
|
21
|
-
async listCollections(search, limit, offset, orderType) {
|
|
23
|
+
async listCollections(search, limit, offset, cursor, cursorDirection, orderType) {
|
|
22
24
|
let path = '/database/collections';
|
|
23
25
|
let payload = {};
|
|
24
26
|
|
|
@@ -34,6 +36,14 @@ class Database extends Service {
|
|
|
34
36
|
payload['offset'] = offset;
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
if (typeof cursor !== 'undefined') {
|
|
40
|
+
payload['cursor'] = cursor;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (typeof cursorDirection !== 'undefined') {
|
|
44
|
+
payload['cursorDirection'] = cursorDirection;
|
|
45
|
+
}
|
|
46
|
+
|
|
37
47
|
if (typeof orderType !== 'undefined') {
|
|
38
48
|
payload['orderType'] = orderType;
|
|
39
49
|
}
|
|
@@ -48,18 +58,27 @@ class Database extends Service {
|
|
|
48
58
|
*
|
|
49
59
|
* Create a new Collection.
|
|
50
60
|
*
|
|
61
|
+
* @param {string} collectionId
|
|
51
62
|
* @param {string} name
|
|
63
|
+
* @param {string} permission
|
|
52
64
|
* @param {string[]} read
|
|
53
65
|
* @param {string[]} write
|
|
54
|
-
* @param {string[]} rules
|
|
55
66
|
* @throws {AppwriteException}
|
|
56
67
|
* @returns {Promise}
|
|
57
68
|
*/
|
|
58
|
-
async createCollection(name, read, write
|
|
69
|
+
async createCollection(collectionId, name, permission, read, write) {
|
|
70
|
+
if (typeof collectionId === 'undefined') {
|
|
71
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
72
|
+
}
|
|
73
|
+
|
|
59
74
|
if (typeof name === 'undefined') {
|
|
60
75
|
throw new AppwriteException('Missing required parameter: "name"');
|
|
61
76
|
}
|
|
62
77
|
|
|
78
|
+
if (typeof permission === 'undefined') {
|
|
79
|
+
throw new AppwriteException('Missing required parameter: "permission"');
|
|
80
|
+
}
|
|
81
|
+
|
|
63
82
|
if (typeof read === 'undefined') {
|
|
64
83
|
throw new AppwriteException('Missing required parameter: "read"');
|
|
65
84
|
}
|
|
@@ -68,17 +87,21 @@ class Database extends Service {
|
|
|
68
87
|
throw new AppwriteException('Missing required parameter: "write"');
|
|
69
88
|
}
|
|
70
89
|
|
|
71
|
-
if (typeof rules === 'undefined') {
|
|
72
|
-
throw new AppwriteException('Missing required parameter: "rules"');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
90
|
let path = '/database/collections';
|
|
76
91
|
let payload = {};
|
|
77
92
|
|
|
93
|
+
if (typeof collectionId !== 'undefined') {
|
|
94
|
+
payload['collectionId'] = collectionId;
|
|
95
|
+
}
|
|
96
|
+
|
|
78
97
|
if (typeof name !== 'undefined') {
|
|
79
98
|
payload['name'] = name;
|
|
80
99
|
}
|
|
81
100
|
|
|
101
|
+
if (typeof permission !== 'undefined') {
|
|
102
|
+
payload['permission'] = permission;
|
|
103
|
+
}
|
|
104
|
+
|
|
82
105
|
if (typeof read !== 'undefined') {
|
|
83
106
|
payload['read'] = read;
|
|
84
107
|
}
|
|
@@ -87,10 +110,6 @@ class Database extends Service {
|
|
|
87
110
|
payload['write'] = write;
|
|
88
111
|
}
|
|
89
112
|
|
|
90
|
-
if (typeof rules !== 'undefined') {
|
|
91
|
-
payload['rules'] = rules;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
113
|
return await this.client.call('post', path, {
|
|
95
114
|
'content-type': 'application/json',
|
|
96
115
|
}, payload);
|
|
@@ -126,13 +145,14 @@ class Database extends Service {
|
|
|
126
145
|
*
|
|
127
146
|
* @param {string} collectionId
|
|
128
147
|
* @param {string} name
|
|
148
|
+
* @param {string} permission
|
|
129
149
|
* @param {string[]} read
|
|
130
150
|
* @param {string[]} write
|
|
131
|
-
* @param {
|
|
151
|
+
* @param {boolean} enabled
|
|
132
152
|
* @throws {AppwriteException}
|
|
133
153
|
* @returns {Promise}
|
|
134
154
|
*/
|
|
135
|
-
async updateCollection(collectionId, name, read, write,
|
|
155
|
+
async updateCollection(collectionId, name, permission, read, write, enabled) {
|
|
136
156
|
if (typeof collectionId === 'undefined') {
|
|
137
157
|
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
138
158
|
}
|
|
@@ -141,6 +161,10 @@ class Database extends Service {
|
|
|
141
161
|
throw new AppwriteException('Missing required parameter: "name"');
|
|
142
162
|
}
|
|
143
163
|
|
|
164
|
+
if (typeof permission === 'undefined') {
|
|
165
|
+
throw new AppwriteException('Missing required parameter: "permission"');
|
|
166
|
+
}
|
|
167
|
+
|
|
144
168
|
let path = '/database/collections/{collectionId}'.replace('{collectionId}', collectionId);
|
|
145
169
|
let payload = {};
|
|
146
170
|
|
|
@@ -148,6 +172,10 @@ class Database extends Service {
|
|
|
148
172
|
payload['name'] = name;
|
|
149
173
|
}
|
|
150
174
|
|
|
175
|
+
if (typeof permission !== 'undefined') {
|
|
176
|
+
payload['permission'] = permission;
|
|
177
|
+
}
|
|
178
|
+
|
|
151
179
|
if (typeof read !== 'undefined') {
|
|
152
180
|
payload['read'] = read;
|
|
153
181
|
}
|
|
@@ -156,8 +184,8 @@ class Database extends Service {
|
|
|
156
184
|
payload['write'] = write;
|
|
157
185
|
}
|
|
158
186
|
|
|
159
|
-
if (typeof
|
|
160
|
-
payload['
|
|
187
|
+
if (typeof enabled !== 'undefined') {
|
|
188
|
+
payload['enabled'] = enabled;
|
|
161
189
|
}
|
|
162
190
|
|
|
163
191
|
return await this.client.call('put', path, {
|
|
@@ -188,6 +216,521 @@ class Database extends Service {
|
|
|
188
216
|
}, payload);
|
|
189
217
|
}
|
|
190
218
|
|
|
219
|
+
/**
|
|
220
|
+
* List Attributes
|
|
221
|
+
*
|
|
222
|
+
* @param {string} collectionId
|
|
223
|
+
* @throws {AppwriteException}
|
|
224
|
+
* @returns {Promise}
|
|
225
|
+
*/
|
|
226
|
+
async listAttributes(collectionId) {
|
|
227
|
+
if (typeof collectionId === 'undefined') {
|
|
228
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
let path = '/database/collections/{collectionId}/attributes'.replace('{collectionId}', collectionId);
|
|
232
|
+
let payload = {};
|
|
233
|
+
|
|
234
|
+
return await this.client.call('get', path, {
|
|
235
|
+
'content-type': 'application/json',
|
|
236
|
+
}, payload);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Create Boolean Attribute
|
|
241
|
+
*
|
|
242
|
+
* Create a boolean attribute.
|
|
243
|
+
*
|
|
244
|
+
*
|
|
245
|
+
* @param {string} collectionId
|
|
246
|
+
* @param {string} key
|
|
247
|
+
* @param {boolean} required
|
|
248
|
+
* @param {boolean} xdefault
|
|
249
|
+
* @param {boolean} array
|
|
250
|
+
* @throws {AppwriteException}
|
|
251
|
+
* @returns {Promise}
|
|
252
|
+
*/
|
|
253
|
+
async createBooleanAttribute(collectionId, key, required, xdefault, array) {
|
|
254
|
+
if (typeof collectionId === 'undefined') {
|
|
255
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (typeof key === 'undefined') {
|
|
259
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (typeof required === 'undefined') {
|
|
263
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
let path = '/database/collections/{collectionId}/attributes/boolean'.replace('{collectionId}', collectionId);
|
|
267
|
+
let payload = {};
|
|
268
|
+
|
|
269
|
+
if (typeof key !== 'undefined') {
|
|
270
|
+
payload['key'] = key;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (typeof required !== 'undefined') {
|
|
274
|
+
payload['required'] = required;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (typeof xdefault !== 'undefined') {
|
|
278
|
+
payload['default'] = xdefault;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (typeof array !== 'undefined') {
|
|
282
|
+
payload['array'] = array;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return await this.client.call('post', path, {
|
|
286
|
+
'content-type': 'application/json',
|
|
287
|
+
}, payload);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Create Email Attribute
|
|
292
|
+
*
|
|
293
|
+
* Create an email attribute.
|
|
294
|
+
*
|
|
295
|
+
*
|
|
296
|
+
* @param {string} collectionId
|
|
297
|
+
* @param {string} key
|
|
298
|
+
* @param {boolean} required
|
|
299
|
+
* @param {string} xdefault
|
|
300
|
+
* @param {boolean} array
|
|
301
|
+
* @throws {AppwriteException}
|
|
302
|
+
* @returns {Promise}
|
|
303
|
+
*/
|
|
304
|
+
async createEmailAttribute(collectionId, key, required, xdefault, array) {
|
|
305
|
+
if (typeof collectionId === 'undefined') {
|
|
306
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (typeof key === 'undefined') {
|
|
310
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (typeof required === 'undefined') {
|
|
314
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
let path = '/database/collections/{collectionId}/attributes/email'.replace('{collectionId}', collectionId);
|
|
318
|
+
let payload = {};
|
|
319
|
+
|
|
320
|
+
if (typeof key !== 'undefined') {
|
|
321
|
+
payload['key'] = key;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (typeof required !== 'undefined') {
|
|
325
|
+
payload['required'] = required;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (typeof xdefault !== 'undefined') {
|
|
329
|
+
payload['default'] = xdefault;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (typeof array !== 'undefined') {
|
|
333
|
+
payload['array'] = array;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return await this.client.call('post', path, {
|
|
337
|
+
'content-type': 'application/json',
|
|
338
|
+
}, payload);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Create Enum Attribute
|
|
343
|
+
*
|
|
344
|
+
* @param {string} collectionId
|
|
345
|
+
* @param {string} key
|
|
346
|
+
* @param {string[]} elements
|
|
347
|
+
* @param {boolean} required
|
|
348
|
+
* @param {string} xdefault
|
|
349
|
+
* @param {boolean} array
|
|
350
|
+
* @throws {AppwriteException}
|
|
351
|
+
* @returns {Promise}
|
|
352
|
+
*/
|
|
353
|
+
async createEnumAttribute(collectionId, key, elements, required, xdefault, array) {
|
|
354
|
+
if (typeof collectionId === 'undefined') {
|
|
355
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (typeof key === 'undefined') {
|
|
359
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (typeof elements === 'undefined') {
|
|
363
|
+
throw new AppwriteException('Missing required parameter: "elements"');
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (typeof required === 'undefined') {
|
|
367
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
let path = '/database/collections/{collectionId}/attributes/enum'.replace('{collectionId}', collectionId);
|
|
371
|
+
let payload = {};
|
|
372
|
+
|
|
373
|
+
if (typeof key !== 'undefined') {
|
|
374
|
+
payload['key'] = key;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (typeof elements !== 'undefined') {
|
|
378
|
+
payload['elements'] = elements;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (typeof required !== 'undefined') {
|
|
382
|
+
payload['required'] = required;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (typeof xdefault !== 'undefined') {
|
|
386
|
+
payload['default'] = xdefault;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (typeof array !== 'undefined') {
|
|
390
|
+
payload['array'] = array;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return await this.client.call('post', path, {
|
|
394
|
+
'content-type': 'application/json',
|
|
395
|
+
}, payload);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Create Float Attribute
|
|
400
|
+
*
|
|
401
|
+
* Create a float attribute. Optionally, minimum and maximum values can be
|
|
402
|
+
* provided.
|
|
403
|
+
*
|
|
404
|
+
*
|
|
405
|
+
* @param {string} collectionId
|
|
406
|
+
* @param {string} key
|
|
407
|
+
* @param {boolean} required
|
|
408
|
+
* @param {string} min
|
|
409
|
+
* @param {string} max
|
|
410
|
+
* @param {string} xdefault
|
|
411
|
+
* @param {boolean} array
|
|
412
|
+
* @throws {AppwriteException}
|
|
413
|
+
* @returns {Promise}
|
|
414
|
+
*/
|
|
415
|
+
async createFloatAttribute(collectionId, key, required, min, max, xdefault, array) {
|
|
416
|
+
if (typeof collectionId === 'undefined') {
|
|
417
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (typeof key === 'undefined') {
|
|
421
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (typeof required === 'undefined') {
|
|
425
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
let path = '/database/collections/{collectionId}/attributes/float'.replace('{collectionId}', collectionId);
|
|
429
|
+
let payload = {};
|
|
430
|
+
|
|
431
|
+
if (typeof key !== 'undefined') {
|
|
432
|
+
payload['key'] = key;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
if (typeof required !== 'undefined') {
|
|
436
|
+
payload['required'] = required;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
if (typeof min !== 'undefined') {
|
|
440
|
+
payload['min'] = min;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (typeof max !== 'undefined') {
|
|
444
|
+
payload['max'] = max;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (typeof xdefault !== 'undefined') {
|
|
448
|
+
payload['default'] = xdefault;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (typeof array !== 'undefined') {
|
|
452
|
+
payload['array'] = array;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
return await this.client.call('post', path, {
|
|
456
|
+
'content-type': 'application/json',
|
|
457
|
+
}, payload);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Create Integer Attribute
|
|
462
|
+
*
|
|
463
|
+
* Create an integer attribute. Optionally, minimum and maximum values can be
|
|
464
|
+
* provided.
|
|
465
|
+
*
|
|
466
|
+
*
|
|
467
|
+
* @param {string} collectionId
|
|
468
|
+
* @param {string} key
|
|
469
|
+
* @param {boolean} required
|
|
470
|
+
* @param {number} min
|
|
471
|
+
* @param {number} max
|
|
472
|
+
* @param {number} xdefault
|
|
473
|
+
* @param {boolean} array
|
|
474
|
+
* @throws {AppwriteException}
|
|
475
|
+
* @returns {Promise}
|
|
476
|
+
*/
|
|
477
|
+
async createIntegerAttribute(collectionId, key, required, min, max, xdefault, array) {
|
|
478
|
+
if (typeof collectionId === 'undefined') {
|
|
479
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
if (typeof key === 'undefined') {
|
|
483
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (typeof required === 'undefined') {
|
|
487
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
let path = '/database/collections/{collectionId}/attributes/integer'.replace('{collectionId}', collectionId);
|
|
491
|
+
let payload = {};
|
|
492
|
+
|
|
493
|
+
if (typeof key !== 'undefined') {
|
|
494
|
+
payload['key'] = key;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
if (typeof required !== 'undefined') {
|
|
498
|
+
payload['required'] = required;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
if (typeof min !== 'undefined') {
|
|
502
|
+
payload['min'] = min;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
if (typeof max !== 'undefined') {
|
|
506
|
+
payload['max'] = max;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
if (typeof xdefault !== 'undefined') {
|
|
510
|
+
payload['default'] = xdefault;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if (typeof array !== 'undefined') {
|
|
514
|
+
payload['array'] = array;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
return await this.client.call('post', path, {
|
|
518
|
+
'content-type': 'application/json',
|
|
519
|
+
}, payload);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Create IP Address Attribute
|
|
524
|
+
*
|
|
525
|
+
* Create IP address attribute.
|
|
526
|
+
*
|
|
527
|
+
*
|
|
528
|
+
* @param {string} collectionId
|
|
529
|
+
* @param {string} key
|
|
530
|
+
* @param {boolean} required
|
|
531
|
+
* @param {string} xdefault
|
|
532
|
+
* @param {boolean} array
|
|
533
|
+
* @throws {AppwriteException}
|
|
534
|
+
* @returns {Promise}
|
|
535
|
+
*/
|
|
536
|
+
async createIpAttribute(collectionId, key, required, xdefault, array) {
|
|
537
|
+
if (typeof collectionId === 'undefined') {
|
|
538
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
if (typeof key === 'undefined') {
|
|
542
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
if (typeof required === 'undefined') {
|
|
546
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
let path = '/database/collections/{collectionId}/attributes/ip'.replace('{collectionId}', collectionId);
|
|
550
|
+
let payload = {};
|
|
551
|
+
|
|
552
|
+
if (typeof key !== 'undefined') {
|
|
553
|
+
payload['key'] = key;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
if (typeof required !== 'undefined') {
|
|
557
|
+
payload['required'] = required;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
if (typeof xdefault !== 'undefined') {
|
|
561
|
+
payload['default'] = xdefault;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (typeof array !== 'undefined') {
|
|
565
|
+
payload['array'] = array;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return await this.client.call('post', path, {
|
|
569
|
+
'content-type': 'application/json',
|
|
570
|
+
}, payload);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Create String Attribute
|
|
575
|
+
*
|
|
576
|
+
* Create a string attribute.
|
|
577
|
+
*
|
|
578
|
+
*
|
|
579
|
+
* @param {string} collectionId
|
|
580
|
+
* @param {string} key
|
|
581
|
+
* @param {number} size
|
|
582
|
+
* @param {boolean} required
|
|
583
|
+
* @param {string} xdefault
|
|
584
|
+
* @param {boolean} array
|
|
585
|
+
* @throws {AppwriteException}
|
|
586
|
+
* @returns {Promise}
|
|
587
|
+
*/
|
|
588
|
+
async createStringAttribute(collectionId, key, size, required, xdefault, array) {
|
|
589
|
+
if (typeof collectionId === 'undefined') {
|
|
590
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if (typeof key === 'undefined') {
|
|
594
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
if (typeof size === 'undefined') {
|
|
598
|
+
throw new AppwriteException('Missing required parameter: "size"');
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (typeof required === 'undefined') {
|
|
602
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
let path = '/database/collections/{collectionId}/attributes/string'.replace('{collectionId}', collectionId);
|
|
606
|
+
let payload = {};
|
|
607
|
+
|
|
608
|
+
if (typeof key !== 'undefined') {
|
|
609
|
+
payload['key'] = key;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
if (typeof size !== 'undefined') {
|
|
613
|
+
payload['size'] = size;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
if (typeof required !== 'undefined') {
|
|
617
|
+
payload['required'] = required;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
if (typeof xdefault !== 'undefined') {
|
|
621
|
+
payload['default'] = xdefault;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if (typeof array !== 'undefined') {
|
|
625
|
+
payload['array'] = array;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
return await this.client.call('post', path, {
|
|
629
|
+
'content-type': 'application/json',
|
|
630
|
+
}, payload);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Create URL Attribute
|
|
635
|
+
*
|
|
636
|
+
* Create a URL attribute.
|
|
637
|
+
*
|
|
638
|
+
*
|
|
639
|
+
* @param {string} collectionId
|
|
640
|
+
* @param {string} key
|
|
641
|
+
* @param {boolean} required
|
|
642
|
+
* @param {string} xdefault
|
|
643
|
+
* @param {boolean} array
|
|
644
|
+
* @throws {AppwriteException}
|
|
645
|
+
* @returns {Promise}
|
|
646
|
+
*/
|
|
647
|
+
async createUrlAttribute(collectionId, key, required, xdefault, array) {
|
|
648
|
+
if (typeof collectionId === 'undefined') {
|
|
649
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (typeof key === 'undefined') {
|
|
653
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
if (typeof required === 'undefined') {
|
|
657
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
let path = '/database/collections/{collectionId}/attributes/url'.replace('{collectionId}', collectionId);
|
|
661
|
+
let payload = {};
|
|
662
|
+
|
|
663
|
+
if (typeof key !== 'undefined') {
|
|
664
|
+
payload['key'] = key;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
if (typeof required !== 'undefined') {
|
|
668
|
+
payload['required'] = required;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
if (typeof xdefault !== 'undefined') {
|
|
672
|
+
payload['default'] = xdefault;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
if (typeof array !== 'undefined') {
|
|
676
|
+
payload['array'] = array;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
return await this.client.call('post', path, {
|
|
680
|
+
'content-type': 'application/json',
|
|
681
|
+
}, payload);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Get Attribute
|
|
686
|
+
*
|
|
687
|
+
* @param {string} collectionId
|
|
688
|
+
* @param {string} key
|
|
689
|
+
* @throws {AppwriteException}
|
|
690
|
+
* @returns {Promise}
|
|
691
|
+
*/
|
|
692
|
+
async getAttribute(collectionId, key) {
|
|
693
|
+
if (typeof collectionId === 'undefined') {
|
|
694
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
if (typeof key === 'undefined') {
|
|
698
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
let path = '/database/collections/{collectionId}/attributes/{key}'.replace('{collectionId}', collectionId).replace('{key}', key);
|
|
702
|
+
let payload = {};
|
|
703
|
+
|
|
704
|
+
return await this.client.call('get', path, {
|
|
705
|
+
'content-type': 'application/json',
|
|
706
|
+
}, payload);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Delete Attribute
|
|
711
|
+
*
|
|
712
|
+
* @param {string} collectionId
|
|
713
|
+
* @param {string} key
|
|
714
|
+
* @throws {AppwriteException}
|
|
715
|
+
* @returns {Promise}
|
|
716
|
+
*/
|
|
717
|
+
async deleteAttribute(collectionId, key) {
|
|
718
|
+
if (typeof collectionId === 'undefined') {
|
|
719
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
if (typeof key === 'undefined') {
|
|
723
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
let path = '/database/collections/{collectionId}/attributes/{key}'.replace('{collectionId}', collectionId).replace('{key}', key);
|
|
727
|
+
let payload = {};
|
|
728
|
+
|
|
729
|
+
return await this.client.call('delete', path, {
|
|
730
|
+
'content-type': 'application/json',
|
|
731
|
+
}, payload);
|
|
732
|
+
}
|
|
733
|
+
|
|
191
734
|
/**
|
|
192
735
|
* List Documents
|
|
193
736
|
*
|
|
@@ -197,17 +740,17 @@ class Database extends Service {
|
|
|
197
740
|
* modes](/docs/admin).
|
|
198
741
|
*
|
|
199
742
|
* @param {string} collectionId
|
|
200
|
-
* @param {string[]}
|
|
743
|
+
* @param {string[]} queries
|
|
201
744
|
* @param {number} limit
|
|
202
745
|
* @param {number} offset
|
|
203
|
-
* @param {string}
|
|
204
|
-
* @param {string}
|
|
205
|
-
* @param {string}
|
|
206
|
-
* @param {string}
|
|
746
|
+
* @param {string} cursor
|
|
747
|
+
* @param {string} cursorDirection
|
|
748
|
+
* @param {string[]} orderAttributes
|
|
749
|
+
* @param {string[]} orderTypes
|
|
207
750
|
* @throws {AppwriteException}
|
|
208
751
|
* @returns {Promise}
|
|
209
752
|
*/
|
|
210
|
-
async listDocuments(collectionId,
|
|
753
|
+
async listDocuments(collectionId, queries, limit, offset, cursor, cursorDirection, orderAttributes, orderTypes) {
|
|
211
754
|
if (typeof collectionId === 'undefined') {
|
|
212
755
|
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
213
756
|
}
|
|
@@ -215,8 +758,8 @@ class Database extends Service {
|
|
|
215
758
|
let path = '/database/collections/{collectionId}/documents'.replace('{collectionId}', collectionId);
|
|
216
759
|
let payload = {};
|
|
217
760
|
|
|
218
|
-
if (typeof
|
|
219
|
-
payload['
|
|
761
|
+
if (typeof queries !== 'undefined') {
|
|
762
|
+
payload['queries'] = queries;
|
|
220
763
|
}
|
|
221
764
|
|
|
222
765
|
if (typeof limit !== 'undefined') {
|
|
@@ -227,20 +770,20 @@ class Database extends Service {
|
|
|
227
770
|
payload['offset'] = offset;
|
|
228
771
|
}
|
|
229
772
|
|
|
230
|
-
if (typeof
|
|
231
|
-
payload['
|
|
773
|
+
if (typeof cursor !== 'undefined') {
|
|
774
|
+
payload['cursor'] = cursor;
|
|
232
775
|
}
|
|
233
776
|
|
|
234
|
-
if (typeof
|
|
235
|
-
payload['
|
|
777
|
+
if (typeof cursorDirection !== 'undefined') {
|
|
778
|
+
payload['cursorDirection'] = cursorDirection;
|
|
236
779
|
}
|
|
237
780
|
|
|
238
|
-
if (typeof
|
|
239
|
-
payload['
|
|
781
|
+
if (typeof orderAttributes !== 'undefined') {
|
|
782
|
+
payload['orderAttributes'] = orderAttributes;
|
|
240
783
|
}
|
|
241
784
|
|
|
242
|
-
if (typeof
|
|
243
|
-
payload['
|
|
785
|
+
if (typeof orderTypes !== 'undefined') {
|
|
786
|
+
payload['orderTypes'] = orderTypes;
|
|
244
787
|
}
|
|
245
788
|
|
|
246
789
|
return await this.client.call('get', path, {
|
|
@@ -257,20 +800,22 @@ class Database extends Service {
|
|
|
257
800
|
* directly from your database console.
|
|
258
801
|
*
|
|
259
802
|
* @param {string} collectionId
|
|
803
|
+
* @param {string} documentId
|
|
260
804
|
* @param {object} data
|
|
261
805
|
* @param {string[]} read
|
|
262
806
|
* @param {string[]} write
|
|
263
|
-
* @param {string} parentDocument
|
|
264
|
-
* @param {string} parentProperty
|
|
265
|
-
* @param {string} parentPropertyType
|
|
266
807
|
* @throws {AppwriteException}
|
|
267
808
|
* @returns {Promise}
|
|
268
809
|
*/
|
|
269
|
-
async createDocument(collectionId, data, read, write
|
|
810
|
+
async createDocument(collectionId, documentId, data, read, write) {
|
|
270
811
|
if (typeof collectionId === 'undefined') {
|
|
271
812
|
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
272
813
|
}
|
|
273
814
|
|
|
815
|
+
if (typeof documentId === 'undefined') {
|
|
816
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
817
|
+
}
|
|
818
|
+
|
|
274
819
|
if (typeof data === 'undefined') {
|
|
275
820
|
throw new AppwriteException('Missing required parameter: "data"');
|
|
276
821
|
}
|
|
@@ -278,6 +823,10 @@ class Database extends Service {
|
|
|
278
823
|
let path = '/database/collections/{collectionId}/documents'.replace('{collectionId}', collectionId);
|
|
279
824
|
let payload = {};
|
|
280
825
|
|
|
826
|
+
if (typeof documentId !== 'undefined') {
|
|
827
|
+
payload['documentId'] = documentId;
|
|
828
|
+
}
|
|
829
|
+
|
|
281
830
|
if (typeof data !== 'undefined') {
|
|
282
831
|
payload['data'] = data;
|
|
283
832
|
}
|
|
@@ -290,18 +839,6 @@ class Database extends Service {
|
|
|
290
839
|
payload['write'] = write;
|
|
291
840
|
}
|
|
292
841
|
|
|
293
|
-
if (typeof parentDocument !== 'undefined') {
|
|
294
|
-
payload['parentDocument'] = parentDocument;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (typeof parentProperty !== 'undefined') {
|
|
298
|
-
payload['parentProperty'] = parentProperty;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
if (typeof parentPropertyType !== 'undefined') {
|
|
302
|
-
payload['parentPropertyType'] = parentPropertyType;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
842
|
return await this.client.call('post', path, {
|
|
306
843
|
'content-type': 'application/json',
|
|
307
844
|
}, payload);
|
|
@@ -410,6 +947,128 @@ class Database extends Service {
|
|
|
410
947
|
'content-type': 'application/json',
|
|
411
948
|
}, payload);
|
|
412
949
|
}
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* List Indexes
|
|
953
|
+
*
|
|
954
|
+
* @param {string} collectionId
|
|
955
|
+
* @throws {AppwriteException}
|
|
956
|
+
* @returns {Promise}
|
|
957
|
+
*/
|
|
958
|
+
async listIndexes(collectionId) {
|
|
959
|
+
if (typeof collectionId === 'undefined') {
|
|
960
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
let path = '/database/collections/{collectionId}/indexes'.replace('{collectionId}', collectionId);
|
|
964
|
+
let payload = {};
|
|
965
|
+
|
|
966
|
+
return await this.client.call('get', path, {
|
|
967
|
+
'content-type': 'application/json',
|
|
968
|
+
}, payload);
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Create Index
|
|
973
|
+
*
|
|
974
|
+
* @param {string} collectionId
|
|
975
|
+
* @param {string} key
|
|
976
|
+
* @param {string} type
|
|
977
|
+
* @param {string[]} attributes
|
|
978
|
+
* @param {string[]} orders
|
|
979
|
+
* @throws {AppwriteException}
|
|
980
|
+
* @returns {Promise}
|
|
981
|
+
*/
|
|
982
|
+
async createIndex(collectionId, key, type, attributes, orders) {
|
|
983
|
+
if (typeof collectionId === 'undefined') {
|
|
984
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
if (typeof key === 'undefined') {
|
|
988
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
if (typeof type === 'undefined') {
|
|
992
|
+
throw new AppwriteException('Missing required parameter: "type"');
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
if (typeof attributes === 'undefined') {
|
|
996
|
+
throw new AppwriteException('Missing required parameter: "attributes"');
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
let path = '/database/collections/{collectionId}/indexes'.replace('{collectionId}', collectionId);
|
|
1000
|
+
let payload = {};
|
|
1001
|
+
|
|
1002
|
+
if (typeof key !== 'undefined') {
|
|
1003
|
+
payload['key'] = key;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
if (typeof type !== 'undefined') {
|
|
1007
|
+
payload['type'] = type;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
if (typeof attributes !== 'undefined') {
|
|
1011
|
+
payload['attributes'] = attributes;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
if (typeof orders !== 'undefined') {
|
|
1015
|
+
payload['orders'] = orders;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
return await this.client.call('post', path, {
|
|
1019
|
+
'content-type': 'application/json',
|
|
1020
|
+
}, payload);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* Get Index
|
|
1025
|
+
*
|
|
1026
|
+
* @param {string} collectionId
|
|
1027
|
+
* @param {string} key
|
|
1028
|
+
* @throws {AppwriteException}
|
|
1029
|
+
* @returns {Promise}
|
|
1030
|
+
*/
|
|
1031
|
+
async getIndex(collectionId, key) {
|
|
1032
|
+
if (typeof collectionId === 'undefined') {
|
|
1033
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
if (typeof key === 'undefined') {
|
|
1037
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
let path = '/database/collections/{collectionId}/indexes/{key}'.replace('{collectionId}', collectionId).replace('{key}', key);
|
|
1041
|
+
let payload = {};
|
|
1042
|
+
|
|
1043
|
+
return await this.client.call('get', path, {
|
|
1044
|
+
'content-type': 'application/json',
|
|
1045
|
+
}, payload);
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* Delete Index
|
|
1050
|
+
*
|
|
1051
|
+
* @param {string} collectionId
|
|
1052
|
+
* @param {string} key
|
|
1053
|
+
* @throws {AppwriteException}
|
|
1054
|
+
* @returns {Promise}
|
|
1055
|
+
*/
|
|
1056
|
+
async deleteIndex(collectionId, key) {
|
|
1057
|
+
if (typeof collectionId === 'undefined') {
|
|
1058
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
if (typeof key === 'undefined') {
|
|
1062
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
let path = '/database/collections/{collectionId}/indexes/{key}'.replace('{collectionId}', collectionId).replace('{key}', key);
|
|
1066
|
+
let payload = {};
|
|
1067
|
+
|
|
1068
|
+
return await this.client.call('delete', path, {
|
|
1069
|
+
'content-type': 'application/json',
|
|
1070
|
+
}, payload);
|
|
1071
|
+
}
|
|
413
1072
|
}
|
|
414
1073
|
|
|
415
1074
|
module.exports = Database;
|