node-appwrite 7.0.2 → 8.0.0-RC1

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.
Files changed (69) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -2
  3. package/docs/examples/databases/create-boolean-attribute.md +2 -2
  4. package/docs/examples/databases/create-collection.md +2 -2
  5. package/docs/examples/databases/create-datetime-attribute.md +20 -0
  6. package/docs/examples/databases/create-document.md +2 -2
  7. package/docs/examples/databases/create-email-attribute.md +2 -2
  8. package/docs/examples/databases/create-enum-attribute.md +2 -2
  9. package/docs/examples/databases/create-float-attribute.md +2 -2
  10. package/docs/examples/databases/create-index.md +2 -2
  11. package/docs/examples/databases/create-integer-attribute.md +2 -2
  12. package/docs/examples/databases/create-ip-attribute.md +2 -2
  13. package/docs/examples/databases/create-string-attribute.md +2 -2
  14. package/docs/examples/databases/create-url-attribute.md +2 -2
  15. package/docs/examples/databases/create.md +2 -2
  16. package/docs/examples/databases/delete-attribute.md +2 -2
  17. package/docs/examples/databases/delete-collection.md +2 -2
  18. package/docs/examples/databases/delete-document.md +2 -2
  19. package/docs/examples/databases/delete-index.md +2 -2
  20. package/docs/examples/databases/delete.md +2 -2
  21. package/docs/examples/databases/get-attribute.md +2 -2
  22. package/docs/examples/databases/get-collection.md +2 -2
  23. package/docs/examples/databases/get-document.md +2 -2
  24. package/docs/examples/databases/get-index.md +2 -2
  25. package/docs/examples/databases/get.md +2 -2
  26. package/docs/examples/databases/list-attributes.md +2 -2
  27. package/docs/examples/databases/list-collections.md +2 -2
  28. package/docs/examples/databases/list-documents.md +2 -2
  29. package/docs/examples/databases/list-indexes.md +2 -2
  30. package/docs/examples/databases/list.md +1 -1
  31. package/docs/examples/databases/update-collection.md +2 -2
  32. package/docs/examples/databases/update-document.md +2 -2
  33. package/docs/examples/databases/update.md +2 -2
  34. package/docs/examples/functions/create-deployment.md +1 -1
  35. package/docs/examples/functions/create-variable.md +20 -0
  36. package/docs/examples/functions/create.md +1 -1
  37. package/docs/examples/functions/delete-variable.md +20 -0
  38. package/docs/examples/functions/get-variable.md +20 -0
  39. package/docs/examples/functions/list-variables.md +20 -0
  40. package/docs/examples/functions/update-variable.md +20 -0
  41. package/docs/examples/functions/update.md +1 -1
  42. package/docs/examples/storage/create-bucket.md +1 -1
  43. package/docs/examples/storage/create-file.md +1 -1
  44. package/docs/examples/storage/update-bucket.md +1 -1
  45. package/docs/examples/users/create-argon2user.md +20 -0
  46. package/docs/examples/users/create-bcrypt-user.md +20 -0
  47. package/docs/examples/users/create-m-d5user.md +20 -0
  48. package/docs/examples/users/create-p-h-pass-user.md +20 -0
  49. package/docs/examples/users/create-s-h-a-user.md +20 -0
  50. package/docs/examples/users/create-scrypt-modified-user.md +20 -0
  51. package/docs/examples/users/create-scrypt-user.md +20 -0
  52. package/docs/examples/users/create.md +1 -1
  53. package/index.d.ts +714 -262
  54. package/index.js +6 -0
  55. package/lib/client.js +5 -2
  56. package/lib/id.js +12 -0
  57. package/lib/permission.js +24 -0
  58. package/lib/query.js +30 -12
  59. package/lib/role.js +25 -0
  60. package/lib/services/account.js +43 -42
  61. package/lib/services/avatars.js +22 -20
  62. package/lib/services/databases.js +385 -243
  63. package/lib/services/functions.js +219 -109
  64. package/lib/services/health.js +7 -1
  65. package/lib/services/locale.js +7 -1
  66. package/lib/services/storage.js +78 -129
  67. package/lib/services/teams.js +39 -73
  68. package/lib/services/users.js +482 -63
  69. package/package.json +1 -1
@@ -7,72 +7,34 @@ const { promisify } = require('util');
7
7
  const fs = require('fs');
8
8
 
9
9
  class Databases extends Service {
10
- databaseId;
11
- /**
12
- * Set databaseId.
13
- *
14
- * @param {string} databaseId
15
- *
16
- * @return void
17
- */
18
- setDatabaseId(databaseId)
19
- {
20
- this.databaseId = databaseId;
21
- }
22
- /**
23
- * Get databaseId.
24
- *
25
- * @return string
26
- */
27
- getDatabaseId()
28
- {
29
- return this.databaseId;
30
- }
31
- constructor(client, databaseId)
10
+
11
+ constructor(client)
32
12
  {
33
13
  super(client);
34
-
35
- this.databaseId = databaseId;
36
14
  }
37
15
 
16
+
38
17
  /**
39
18
  * List Databases
40
19
  *
20
+ * Get a list of all databases from the current Appwrite project. You can use
21
+ * the search parameter to filter your results.
22
+ *
23
+ * @param {string[]} queries
41
24
  * @param {string} search
42
- * @param {number} limit
43
- * @param {number} offset
44
- * @param {string} cursor
45
- * @param {string} cursorDirection
46
- * @param {string} orderType
47
25
  * @throws {AppwriteException}
48
26
  * @returns {Promise}
49
27
  */
50
- async list(search, limit, offset, cursor, cursorDirection, orderType) {
28
+ async list(queries, search) {
51
29
  let path = '/databases';
52
30
  let payload = {};
53
31
 
54
- if (typeof search !== 'undefined') {
55
- payload['search'] = search;
56
- }
57
-
58
- if (typeof limit !== 'undefined') {
59
- payload['limit'] = limit;
60
- }
61
-
62
- if (typeof offset !== 'undefined') {
63
- payload['offset'] = offset;
64
- }
65
-
66
- if (typeof cursor !== 'undefined') {
67
- payload['cursor'] = cursor;
68
- }
69
-
70
- if (typeof cursorDirection !== 'undefined') {
71
- payload['cursorDirection'] = cursorDirection;
32
+ if (typeof queries !== 'undefined') {
33
+ payload['queries'] = queries;
72
34
  }
73
35
 
74
- if (typeof orderType !== 'undefined') {
75
- payload['orderType'] = orderType;
36
+ if (typeof search !== 'undefined') {
37
+ payload['search'] = search;
76
38
  }
77
39
 
78
40
  return await this.client.call('get', path, {
@@ -83,20 +45,28 @@ class Databases extends Service {
83
45
  /**
84
46
  * Create Database
85
47
  *
48
+ * Create a new Database.
49
+ *
50
+ *
51
+ * @param {string} databaseId
86
52
  * @param {string} name
87
53
  * @throws {AppwriteException}
88
54
  * @returns {Promise}
89
55
  */
90
- async create(name) {
56
+ async create(databaseId, name) {
57
+ let path = '/databases';
58
+ let payload = {};
59
+ if (typeof databaseId === 'undefined') {
60
+ throw new AppwriteException('Missing required parameter: "databaseId"');
61
+ }
62
+
91
63
  if (typeof name === 'undefined') {
92
64
  throw new AppwriteException('Missing required parameter: "name"');
93
65
  }
94
66
 
95
- let path = '/databases';
96
- let payload = {};
97
67
 
98
- if (typeof this.databaseId !== 'undefined') {
99
- payload['databaseId'] = this.databaseId;
68
+ if (typeof databaseId !== 'undefined') {
69
+ payload['databaseId'] = databaseId;
100
70
  }
101
71
 
102
72
  if (typeof name !== 'undefined') {
@@ -111,12 +81,20 @@ class Databases extends Service {
111
81
  /**
112
82
  * Get Database
113
83
  *
84
+ * Get a database by its unique ID. This endpoint response returns a JSON
85
+ * object with the database metadata.
86
+ *
87
+ * @param {string} databaseId
114
88
  * @throws {AppwriteException}
115
89
  * @returns {Promise}
116
90
  */
117
- async get() {
118
- let path = '/databases/{databaseId}'.replace('{databaseId}', this.databaseId);
91
+ async get(databaseId) {
92
+ let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId);
119
93
  let payload = {};
94
+ if (typeof databaseId === 'undefined') {
95
+ throw new AppwriteException('Missing required parameter: "databaseId"');
96
+ }
97
+
120
98
 
121
99
  return await this.client.call('get', path, {
122
100
  'content-type': 'application/json',
@@ -126,17 +104,24 @@ class Databases extends Service {
126
104
  /**
127
105
  * Update Database
128
106
  *
107
+ * Update a database by its unique ID.
108
+ *
109
+ * @param {string} databaseId
129
110
  * @param {string} name
130
111
  * @throws {AppwriteException}
131
112
  * @returns {Promise}
132
113
  */
133
- async update(name) {
114
+ async update(databaseId, name) {
115
+ let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId);
116
+ let payload = {};
117
+ if (typeof databaseId === 'undefined') {
118
+ throw new AppwriteException('Missing required parameter: "databaseId"');
119
+ }
120
+
134
121
  if (typeof name === 'undefined') {
135
122
  throw new AppwriteException('Missing required parameter: "name"');
136
123
  }
137
124
 
138
- let path = '/databases/{databaseId}'.replace('{databaseId}', this.databaseId);
139
- let payload = {};
140
125
 
141
126
  if (typeof name !== 'undefined') {
142
127
  payload['name'] = name;
@@ -150,12 +135,20 @@ class Databases extends Service {
150
135
  /**
151
136
  * Delete Database
152
137
  *
138
+ * Delete a database by its unique ID. Only API keys with with databases.write
139
+ * scope can delete a database.
140
+ *
141
+ * @param {string} databaseId
153
142
  * @throws {AppwriteException}
154
143
  * @returns {Promise}
155
144
  */
156
- async delete() {
157
- let path = '/databases/{databaseId}'.replace('{databaseId}', this.databaseId);
145
+ async delete(databaseId) {
146
+ let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId);
158
147
  let payload = {};
148
+ if (typeof databaseId === 'undefined') {
149
+ throw new AppwriteException('Missing required parameter: "databaseId"');
150
+ }
151
+
159
152
 
160
153
  return await this.client.call('delete', path, {
161
154
  'content-type': 'application/json',
@@ -165,41 +158,29 @@ class Databases extends Service {
165
158
  /**
166
159
  * List Collections
167
160
  *
161
+ * Get a list of all collections that belong to the provided databaseId. You
162
+ * can use the search parameter to filter your results.
163
+ *
164
+ * @param {string} databaseId
165
+ * @param {string[]} queries
168
166
  * @param {string} search
169
- * @param {number} limit
170
- * @param {number} offset
171
- * @param {string} cursor
172
- * @param {string} cursorDirection
173
- * @param {string} orderType
174
167
  * @throws {AppwriteException}
175
168
  * @returns {Promise}
176
169
  */
177
- async listCollections(search, limit, offset, cursor, cursorDirection, orderType) {
178
- let path = '/databases/{databaseId}/collections'.replace('{databaseId}', this.databaseId);
170
+ async listCollections(databaseId, queries, search) {
171
+ let path = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId);
179
172
  let payload = {};
180
-
181
- if (typeof search !== 'undefined') {
182
- payload['search'] = search;
183
- }
184
-
185
- if (typeof limit !== 'undefined') {
186
- payload['limit'] = limit;
173
+ if (typeof databaseId === 'undefined') {
174
+ throw new AppwriteException('Missing required parameter: "databaseId"');
187
175
  }
188
176
 
189
- if (typeof offset !== 'undefined') {
190
- payload['offset'] = offset;
191
- }
192
177
 
193
- if (typeof cursor !== 'undefined') {
194
- payload['cursor'] = cursor;
195
- }
196
-
197
- if (typeof cursorDirection !== 'undefined') {
198
- payload['cursorDirection'] = cursorDirection;
178
+ if (typeof queries !== 'undefined') {
179
+ payload['queries'] = queries;
199
180
  }
200
181
 
201
- if (typeof orderType !== 'undefined') {
202
- payload['orderType'] = orderType;
182
+ if (typeof search !== 'undefined') {
183
+ payload['search'] = search;
203
184
  }
204
185
 
205
186
  return await this.client.call('get', path, {
@@ -210,15 +191,26 @@ class Databases extends Service {
210
191
  /**
211
192
  * Create Collection
212
193
  *
194
+ * Create a new Collection. Before using this route, you should create a new
195
+ * database resource using either a [server
196
+ * integration](/docs/server/databases#databasesCreateCollection) API or
197
+ * directly from your database console.
198
+ *
199
+ * @param {string} databaseId
213
200
  * @param {string} collectionId
214
201
  * @param {string} name
215
- * @param {string} permission
216
- * @param {string[]} read
217
- * @param {string[]} write
202
+ * @param {string[]} permissions
203
+ * @param {boolean} documentSecurity
218
204
  * @throws {AppwriteException}
219
205
  * @returns {Promise}
220
206
  */
221
- async createCollection(collectionId, name, permission, read, write) {
207
+ async createCollection(databaseId, collectionId, name, permissions, documentSecurity) {
208
+ let path = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId);
209
+ let payload = {};
210
+ if (typeof databaseId === 'undefined') {
211
+ throw new AppwriteException('Missing required parameter: "databaseId"');
212
+ }
213
+
222
214
  if (typeof collectionId === 'undefined') {
223
215
  throw new AppwriteException('Missing required parameter: "collectionId"');
224
216
  }
@@ -227,20 +219,6 @@ class Databases extends Service {
227
219
  throw new AppwriteException('Missing required parameter: "name"');
228
220
  }
229
221
 
230
- if (typeof permission === 'undefined') {
231
- throw new AppwriteException('Missing required parameter: "permission"');
232
- }
233
-
234
- if (typeof read === 'undefined') {
235
- throw new AppwriteException('Missing required parameter: "read"');
236
- }
237
-
238
- if (typeof write === 'undefined') {
239
- throw new AppwriteException('Missing required parameter: "write"');
240
- }
241
-
242
- let path = '/databases/{databaseId}/collections'.replace('{databaseId}', this.databaseId);
243
- let payload = {};
244
222
 
245
223
  if (typeof collectionId !== 'undefined') {
246
224
  payload['collectionId'] = collectionId;
@@ -250,16 +228,12 @@ class Databases extends Service {
250
228
  payload['name'] = name;
251
229
  }
252
230
 
253
- if (typeof permission !== 'undefined') {
254
- payload['permission'] = permission;
255
- }
256
-
257
- if (typeof read !== 'undefined') {
258
- payload['read'] = read;
231
+ if (typeof permissions !== 'undefined') {
232
+ payload['permissions'] = permissions;
259
233
  }
260
234
 
261
- if (typeof write !== 'undefined') {
262
- payload['write'] = write;
235
+ if (typeof documentSecurity !== 'undefined') {
236
+ payload['documentSecurity'] = documentSecurity;
263
237
  }
264
238
 
265
239
  return await this.client.call('post', path, {
@@ -270,17 +244,25 @@ class Databases extends Service {
270
244
  /**
271
245
  * Get Collection
272
246
  *
247
+ * Get a collection by its unique ID. This endpoint response returns a JSON
248
+ * object with the collection metadata.
249
+ *
250
+ * @param {string} databaseId
273
251
  * @param {string} collectionId
274
252
  * @throws {AppwriteException}
275
253
  * @returns {Promise}
276
254
  */
277
- async getCollection(collectionId) {
255
+ async getCollection(databaseId, collectionId) {
256
+ let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
257
+ let payload = {};
258
+ if (typeof databaseId === 'undefined') {
259
+ throw new AppwriteException('Missing required parameter: "databaseId"');
260
+ }
261
+
278
262
  if (typeof collectionId === 'undefined') {
279
263
  throw new AppwriteException('Missing required parameter: "collectionId"');
280
264
  }
281
265
 
282
- let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
283
- let payload = {};
284
266
 
285
267
  return await this.client.call('get', path, {
286
268
  'content-type': 'application/json',
@@ -290,16 +272,24 @@ class Databases extends Service {
290
272
  /**
291
273
  * Update Collection
292
274
  *
275
+ * Update a collection by its unique ID.
276
+ *
277
+ * @param {string} databaseId
293
278
  * @param {string} collectionId
294
279
  * @param {string} name
295
- * @param {string} permission
296
- * @param {string[]} read
297
- * @param {string[]} write
280
+ * @param {string[]} permissions
281
+ * @param {boolean} documentSecurity
298
282
  * @param {boolean} enabled
299
283
  * @throws {AppwriteException}
300
284
  * @returns {Promise}
301
285
  */
302
- async updateCollection(collectionId, name, permission, read, write, enabled) {
286
+ async updateCollection(databaseId, collectionId, name, permissions, documentSecurity, enabled) {
287
+ let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
288
+ let payload = {};
289
+ if (typeof databaseId === 'undefined') {
290
+ throw new AppwriteException('Missing required parameter: "databaseId"');
291
+ }
292
+
303
293
  if (typeof collectionId === 'undefined') {
304
294
  throw new AppwriteException('Missing required parameter: "collectionId"');
305
295
  }
@@ -308,27 +298,17 @@ class Databases extends Service {
308
298
  throw new AppwriteException('Missing required parameter: "name"');
309
299
  }
310
300
 
311
- if (typeof permission === 'undefined') {
312
- throw new AppwriteException('Missing required parameter: "permission"');
313
- }
314
-
315
- let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
316
- let payload = {};
317
301
 
318
302
  if (typeof name !== 'undefined') {
319
303
  payload['name'] = name;
320
304
  }
321
305
 
322
- if (typeof permission !== 'undefined') {
323
- payload['permission'] = permission;
306
+ if (typeof permissions !== 'undefined') {
307
+ payload['permissions'] = permissions;
324
308
  }
325
309
 
326
- if (typeof read !== 'undefined') {
327
- payload['read'] = read;
328
- }
329
-
330
- if (typeof write !== 'undefined') {
331
- payload['write'] = write;
310
+ if (typeof documentSecurity !== 'undefined') {
311
+ payload['documentSecurity'] = documentSecurity;
332
312
  }
333
313
 
334
314
  if (typeof enabled !== 'undefined') {
@@ -343,17 +323,25 @@ class Databases extends Service {
343
323
  /**
344
324
  * Delete Collection
345
325
  *
326
+ * Delete a collection by its unique ID. Only users with write permissions
327
+ * have access to delete this resource.
328
+ *
329
+ * @param {string} databaseId
346
330
  * @param {string} collectionId
347
331
  * @throws {AppwriteException}
348
332
  * @returns {Promise}
349
333
  */
350
- async deleteCollection(collectionId) {
334
+ async deleteCollection(databaseId, collectionId) {
335
+ let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
336
+ let payload = {};
337
+ if (typeof databaseId === 'undefined') {
338
+ throw new AppwriteException('Missing required parameter: "databaseId"');
339
+ }
340
+
351
341
  if (typeof collectionId === 'undefined') {
352
342
  throw new AppwriteException('Missing required parameter: "collectionId"');
353
343
  }
354
344
 
355
- let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
356
- let payload = {};
357
345
 
358
346
  return await this.client.call('delete', path, {
359
347
  'content-type': 'application/json',
@@ -363,17 +351,22 @@ class Databases extends Service {
363
351
  /**
364
352
  * List Attributes
365
353
  *
354
+ * @param {string} databaseId
366
355
  * @param {string} collectionId
367
356
  * @throws {AppwriteException}
368
357
  * @returns {Promise}
369
358
  */
370
- async listAttributes(collectionId) {
359
+ async listAttributes(databaseId, collectionId) {
360
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
361
+ let payload = {};
362
+ if (typeof databaseId === 'undefined') {
363
+ throw new AppwriteException('Missing required parameter: "databaseId"');
364
+ }
365
+
371
366
  if (typeof collectionId === 'undefined') {
372
367
  throw new AppwriteException('Missing required parameter: "collectionId"');
373
368
  }
374
369
 
375
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
376
- let payload = {};
377
370
 
378
371
  return await this.client.call('get', path, {
379
372
  'content-type': 'application/json',
@@ -383,6 +376,10 @@ class Databases extends Service {
383
376
  /**
384
377
  * Create Boolean Attribute
385
378
  *
379
+ * Create a boolean attribute.
380
+ *
381
+ *
382
+ * @param {string} databaseId
386
383
  * @param {string} collectionId
387
384
  * @param {string} key
388
385
  * @param {boolean} required
@@ -391,7 +388,13 @@ class Databases extends Service {
391
388
  * @throws {AppwriteException}
392
389
  * @returns {Promise}
393
390
  */
394
- async createBooleanAttribute(collectionId, key, required, xdefault, array) {
391
+ async createBooleanAttribute(databaseId, collectionId, key, required, xdefault, array) {
392
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
393
+ let payload = {};
394
+ if (typeof databaseId === 'undefined') {
395
+ throw new AppwriteException('Missing required parameter: "databaseId"');
396
+ }
397
+
395
398
  if (typeof collectionId === 'undefined') {
396
399
  throw new AppwriteException('Missing required parameter: "collectionId"');
397
400
  }
@@ -404,8 +407,59 @@ class Databases extends Service {
404
407
  throw new AppwriteException('Missing required parameter: "required"');
405
408
  }
406
409
 
407
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
410
+
411
+ if (typeof key !== 'undefined') {
412
+ payload['key'] = key;
413
+ }
414
+
415
+ if (typeof required !== 'undefined') {
416
+ payload['required'] = required;
417
+ }
418
+
419
+ if (typeof xdefault !== 'undefined') {
420
+ payload['default'] = xdefault;
421
+ }
422
+
423
+ if (typeof array !== 'undefined') {
424
+ payload['array'] = array;
425
+ }
426
+
427
+ return await this.client.call('post', path, {
428
+ 'content-type': 'application/json',
429
+ }, payload);
430
+ }
431
+
432
+ /**
433
+ * Create DateTime Attribute
434
+ *
435
+ * @param {string} databaseId
436
+ * @param {string} collectionId
437
+ * @param {string} key
438
+ * @param {boolean} required
439
+ * @param {string} xdefault
440
+ * @param {boolean} array
441
+ * @throws {AppwriteException}
442
+ * @returns {Promise}
443
+ */
444
+ async createDatetimeAttribute(databaseId, collectionId, key, required, xdefault, array) {
445
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
408
446
  let payload = {};
447
+ if (typeof databaseId === 'undefined') {
448
+ throw new AppwriteException('Missing required parameter: "databaseId"');
449
+ }
450
+
451
+ if (typeof collectionId === 'undefined') {
452
+ throw new AppwriteException('Missing required parameter: "collectionId"');
453
+ }
454
+
455
+ if (typeof key === 'undefined') {
456
+ throw new AppwriteException('Missing required parameter: "key"');
457
+ }
458
+
459
+ if (typeof required === 'undefined') {
460
+ throw new AppwriteException('Missing required parameter: "required"');
461
+ }
462
+
409
463
 
410
464
  if (typeof key !== 'undefined') {
411
465
  payload['key'] = key;
@@ -431,6 +485,10 @@ class Databases extends Service {
431
485
  /**
432
486
  * Create Email Attribute
433
487
  *
488
+ * Create an email attribute.
489
+ *
490
+ *
491
+ * @param {string} databaseId
434
492
  * @param {string} collectionId
435
493
  * @param {string} key
436
494
  * @param {boolean} required
@@ -439,7 +497,13 @@ class Databases extends Service {
439
497
  * @throws {AppwriteException}
440
498
  * @returns {Promise}
441
499
  */
442
- async createEmailAttribute(collectionId, key, required, xdefault, array) {
500
+ async createEmailAttribute(databaseId, collectionId, key, required, xdefault, array) {
501
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
502
+ let payload = {};
503
+ if (typeof databaseId === 'undefined') {
504
+ throw new AppwriteException('Missing required parameter: "databaseId"');
505
+ }
506
+
443
507
  if (typeof collectionId === 'undefined') {
444
508
  throw new AppwriteException('Missing required parameter: "collectionId"');
445
509
  }
@@ -452,8 +516,6 @@ class Databases extends Service {
452
516
  throw new AppwriteException('Missing required parameter: "required"');
453
517
  }
454
518
 
455
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
456
- let payload = {};
457
519
 
458
520
  if (typeof key !== 'undefined') {
459
521
  payload['key'] = key;
@@ -479,6 +541,7 @@ class Databases extends Service {
479
541
  /**
480
542
  * Create Enum Attribute
481
543
  *
544
+ * @param {string} databaseId
482
545
  * @param {string} collectionId
483
546
  * @param {string} key
484
547
  * @param {string[]} elements
@@ -488,7 +551,13 @@ class Databases extends Service {
488
551
  * @throws {AppwriteException}
489
552
  * @returns {Promise}
490
553
  */
491
- async createEnumAttribute(collectionId, key, elements, required, xdefault, array) {
554
+ async createEnumAttribute(databaseId, collectionId, key, elements, required, xdefault, array) {
555
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
556
+ let payload = {};
557
+ if (typeof databaseId === 'undefined') {
558
+ throw new AppwriteException('Missing required parameter: "databaseId"');
559
+ }
560
+
492
561
  if (typeof collectionId === 'undefined') {
493
562
  throw new AppwriteException('Missing required parameter: "collectionId"');
494
563
  }
@@ -505,8 +574,6 @@ class Databases extends Service {
505
574
  throw new AppwriteException('Missing required parameter: "required"');
506
575
  }
507
576
 
508
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
509
- let payload = {};
510
577
 
511
578
  if (typeof key !== 'undefined') {
512
579
  payload['key'] = key;
@@ -536,6 +603,11 @@ class Databases extends Service {
536
603
  /**
537
604
  * Create Float Attribute
538
605
  *
606
+ * Create a float attribute. Optionally, minimum and maximum values can be
607
+ * provided.
608
+ *
609
+ *
610
+ * @param {string} databaseId
539
611
  * @param {string} collectionId
540
612
  * @param {string} key
541
613
  * @param {boolean} required
@@ -546,7 +618,13 @@ class Databases extends Service {
546
618
  * @throws {AppwriteException}
547
619
  * @returns {Promise}
548
620
  */
549
- async createFloatAttribute(collectionId, key, required, min, max, xdefault, array) {
621
+ async createFloatAttribute(databaseId, collectionId, key, required, min, max, xdefault, array) {
622
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
623
+ let payload = {};
624
+ if (typeof databaseId === 'undefined') {
625
+ throw new AppwriteException('Missing required parameter: "databaseId"');
626
+ }
627
+
550
628
  if (typeof collectionId === 'undefined') {
551
629
  throw new AppwriteException('Missing required parameter: "collectionId"');
552
630
  }
@@ -559,8 +637,6 @@ class Databases extends Service {
559
637
  throw new AppwriteException('Missing required parameter: "required"');
560
638
  }
561
639
 
562
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
563
- let payload = {};
564
640
 
565
641
  if (typeof key !== 'undefined') {
566
642
  payload['key'] = key;
@@ -594,6 +670,11 @@ class Databases extends Service {
594
670
  /**
595
671
  * Create Integer Attribute
596
672
  *
673
+ * Create an integer attribute. Optionally, minimum and maximum values can be
674
+ * provided.
675
+ *
676
+ *
677
+ * @param {string} databaseId
597
678
  * @param {string} collectionId
598
679
  * @param {string} key
599
680
  * @param {boolean} required
@@ -604,7 +685,13 @@ class Databases extends Service {
604
685
  * @throws {AppwriteException}
605
686
  * @returns {Promise}
606
687
  */
607
- async createIntegerAttribute(collectionId, key, required, min, max, xdefault, array) {
688
+ async createIntegerAttribute(databaseId, collectionId, key, required, min, max, xdefault, array) {
689
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
690
+ let payload = {};
691
+ if (typeof databaseId === 'undefined') {
692
+ throw new AppwriteException('Missing required parameter: "databaseId"');
693
+ }
694
+
608
695
  if (typeof collectionId === 'undefined') {
609
696
  throw new AppwriteException('Missing required parameter: "collectionId"');
610
697
  }
@@ -617,8 +704,6 @@ class Databases extends Service {
617
704
  throw new AppwriteException('Missing required parameter: "required"');
618
705
  }
619
706
 
620
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
621
- let payload = {};
622
707
 
623
708
  if (typeof key !== 'undefined') {
624
709
  payload['key'] = key;
@@ -652,6 +737,10 @@ class Databases extends Service {
652
737
  /**
653
738
  * Create IP Address Attribute
654
739
  *
740
+ * Create IP address attribute.
741
+ *
742
+ *
743
+ * @param {string} databaseId
655
744
  * @param {string} collectionId
656
745
  * @param {string} key
657
746
  * @param {boolean} required
@@ -660,7 +749,13 @@ class Databases extends Service {
660
749
  * @throws {AppwriteException}
661
750
  * @returns {Promise}
662
751
  */
663
- async createIpAttribute(collectionId, key, required, xdefault, array) {
752
+ async createIpAttribute(databaseId, collectionId, key, required, xdefault, array) {
753
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
754
+ let payload = {};
755
+ if (typeof databaseId === 'undefined') {
756
+ throw new AppwriteException('Missing required parameter: "databaseId"');
757
+ }
758
+
664
759
  if (typeof collectionId === 'undefined') {
665
760
  throw new AppwriteException('Missing required parameter: "collectionId"');
666
761
  }
@@ -673,8 +768,6 @@ class Databases extends Service {
673
768
  throw new AppwriteException('Missing required parameter: "required"');
674
769
  }
675
770
 
676
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
677
- let payload = {};
678
771
 
679
772
  if (typeof key !== 'undefined') {
680
773
  payload['key'] = key;
@@ -700,6 +793,10 @@ class Databases extends Service {
700
793
  /**
701
794
  * Create String Attribute
702
795
  *
796
+ * Create a string attribute.
797
+ *
798
+ *
799
+ * @param {string} databaseId
703
800
  * @param {string} collectionId
704
801
  * @param {string} key
705
802
  * @param {number} size
@@ -709,7 +806,13 @@ class Databases extends Service {
709
806
  * @throws {AppwriteException}
710
807
  * @returns {Promise}
711
808
  */
712
- async createStringAttribute(collectionId, key, size, required, xdefault, array) {
809
+ async createStringAttribute(databaseId, collectionId, key, size, required, xdefault, array) {
810
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
811
+ let payload = {};
812
+ if (typeof databaseId === 'undefined') {
813
+ throw new AppwriteException('Missing required parameter: "databaseId"');
814
+ }
815
+
713
816
  if (typeof collectionId === 'undefined') {
714
817
  throw new AppwriteException('Missing required parameter: "collectionId"');
715
818
  }
@@ -726,8 +829,6 @@ class Databases extends Service {
726
829
  throw new AppwriteException('Missing required parameter: "required"');
727
830
  }
728
831
 
729
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
730
- let payload = {};
731
832
 
732
833
  if (typeof key !== 'undefined') {
733
834
  payload['key'] = key;
@@ -757,6 +858,10 @@ class Databases extends Service {
757
858
  /**
758
859
  * Create URL Attribute
759
860
  *
861
+ * Create a URL attribute.
862
+ *
863
+ *
864
+ * @param {string} databaseId
760
865
  * @param {string} collectionId
761
866
  * @param {string} key
762
867
  * @param {boolean} required
@@ -765,7 +870,13 @@ class Databases extends Service {
765
870
  * @throws {AppwriteException}
766
871
  * @returns {Promise}
767
872
  */
768
- async createUrlAttribute(collectionId, key, required, xdefault, array) {
873
+ async createUrlAttribute(databaseId, collectionId, key, required, xdefault, array) {
874
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
875
+ let payload = {};
876
+ if (typeof databaseId === 'undefined') {
877
+ throw new AppwriteException('Missing required parameter: "databaseId"');
878
+ }
879
+
769
880
  if (typeof collectionId === 'undefined') {
770
881
  throw new AppwriteException('Missing required parameter: "collectionId"');
771
882
  }
@@ -778,8 +889,6 @@ class Databases extends Service {
778
889
  throw new AppwriteException('Missing required parameter: "required"');
779
890
  }
780
891
 
781
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
782
- let payload = {};
783
892
 
784
893
  if (typeof key !== 'undefined') {
785
894
  payload['key'] = key;
@@ -805,12 +914,19 @@ class Databases extends Service {
805
914
  /**
806
915
  * Get Attribute
807
916
  *
917
+ * @param {string} databaseId
808
918
  * @param {string} collectionId
809
919
  * @param {string} key
810
920
  * @throws {AppwriteException}
811
921
  * @returns {Promise}
812
922
  */
813
- async getAttribute(collectionId, key) {
923
+ async getAttribute(databaseId, collectionId, key) {
924
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
925
+ let payload = {};
926
+ if (typeof databaseId === 'undefined') {
927
+ throw new AppwriteException('Missing required parameter: "databaseId"');
928
+ }
929
+
814
930
  if (typeof collectionId === 'undefined') {
815
931
  throw new AppwriteException('Missing required parameter: "collectionId"');
816
932
  }
@@ -819,8 +935,6 @@ class Databases extends Service {
819
935
  throw new AppwriteException('Missing required parameter: "key"');
820
936
  }
821
937
 
822
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
823
- let payload = {};
824
938
 
825
939
  return await this.client.call('get', path, {
826
940
  'content-type': 'application/json',
@@ -830,12 +944,19 @@ class Databases extends Service {
830
944
  /**
831
945
  * Delete Attribute
832
946
  *
947
+ * @param {string} databaseId
833
948
  * @param {string} collectionId
834
949
  * @param {string} key
835
950
  * @throws {AppwriteException}
836
951
  * @returns {Promise}
837
952
  */
838
- async deleteAttribute(collectionId, key) {
953
+ async deleteAttribute(databaseId, collectionId, key) {
954
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
955
+ let payload = {};
956
+ if (typeof databaseId === 'undefined') {
957
+ throw new AppwriteException('Missing required parameter: "databaseId"');
958
+ }
959
+
839
960
  if (typeof collectionId === 'undefined') {
840
961
  throw new AppwriteException('Missing required parameter: "collectionId"');
841
962
  }
@@ -844,8 +965,6 @@ class Databases extends Service {
844
965
  throw new AppwriteException('Missing required parameter: "key"');
845
966
  }
846
967
 
847
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
848
- let payload = {};
849
968
 
850
969
  return await this.client.call('delete', path, {
851
970
  'content-type': 'application/json',
@@ -855,53 +974,33 @@ class Databases extends Service {
855
974
  /**
856
975
  * List Documents
857
976
  *
977
+ * Get a list of all the user's documents in a given collection. You can use
978
+ * the query params to filter your results. On admin mode, this endpoint will
979
+ * return a list of all of documents belonging to the provided collectionId.
980
+ * [Learn more about different API modes](/docs/admin).
981
+ *
982
+ * @param {string} databaseId
858
983
  * @param {string} collectionId
859
984
  * @param {string[]} queries
860
- * @param {number} limit
861
- * @param {number} offset
862
- * @param {string} cursor
863
- * @param {string} cursorDirection
864
- * @param {string[]} orderAttributes
865
- * @param {string[]} orderTypes
866
985
  * @throws {AppwriteException}
867
986
  * @returns {Promise}
868
987
  */
869
- async listDocuments(collectionId, queries, limit, offset, cursor, cursorDirection, orderAttributes, orderTypes) {
988
+ async listDocuments(databaseId, collectionId, queries) {
989
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
990
+ let payload = {};
991
+ if (typeof databaseId === 'undefined') {
992
+ throw new AppwriteException('Missing required parameter: "databaseId"');
993
+ }
994
+
870
995
  if (typeof collectionId === 'undefined') {
871
996
  throw new AppwriteException('Missing required parameter: "collectionId"');
872
997
  }
873
998
 
874
- let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
875
- let payload = {};
876
999
 
877
1000
  if (typeof queries !== 'undefined') {
878
1001
  payload['queries'] = queries;
879
1002
  }
880
1003
 
881
- if (typeof limit !== 'undefined') {
882
- payload['limit'] = limit;
883
- }
884
-
885
- if (typeof offset !== 'undefined') {
886
- payload['offset'] = offset;
887
- }
888
-
889
- if (typeof cursor !== 'undefined') {
890
- payload['cursor'] = cursor;
891
- }
892
-
893
- if (typeof cursorDirection !== 'undefined') {
894
- payload['cursorDirection'] = cursorDirection;
895
- }
896
-
897
- if (typeof orderAttributes !== 'undefined') {
898
- payload['orderAttributes'] = orderAttributes;
899
- }
900
-
901
- if (typeof orderTypes !== 'undefined') {
902
- payload['orderTypes'] = orderTypes;
903
- }
904
-
905
1004
  return await this.client.call('get', path, {
906
1005
  'content-type': 'application/json',
907
1006
  }, payload);
@@ -910,15 +1009,26 @@ class Databases extends Service {
910
1009
  /**
911
1010
  * Create Document
912
1011
  *
1012
+ * Create a new Document. Before using this route, you should create a new
1013
+ * collection resource using either a [server
1014
+ * integration](/docs/server/databases#databasesCreateCollection) API or
1015
+ * directly from your database console.
1016
+ *
1017
+ * @param {string} databaseId
913
1018
  * @param {string} collectionId
914
1019
  * @param {string} documentId
915
1020
  * @param {object} data
916
- * @param {string[]} read
917
- * @param {string[]} write
1021
+ * @param {string[]} permissions
918
1022
  * @throws {AppwriteException}
919
1023
  * @returns {Promise}
920
1024
  */
921
- async createDocument(collectionId, documentId, data, read, write) {
1025
+ async createDocument(databaseId, collectionId, documentId, data, permissions) {
1026
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
1027
+ let payload = {};
1028
+ if (typeof databaseId === 'undefined') {
1029
+ throw new AppwriteException('Missing required parameter: "databaseId"');
1030
+ }
1031
+
922
1032
  if (typeof collectionId === 'undefined') {
923
1033
  throw new AppwriteException('Missing required parameter: "collectionId"');
924
1034
  }
@@ -931,8 +1041,6 @@ class Databases extends Service {
931
1041
  throw new AppwriteException('Missing required parameter: "data"');
932
1042
  }
933
1043
 
934
- let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
935
- let payload = {};
936
1044
 
937
1045
  if (typeof documentId !== 'undefined') {
938
1046
  payload['documentId'] = documentId;
@@ -942,12 +1050,8 @@ class Databases extends Service {
942
1050
  payload['data'] = data;
943
1051
  }
944
1052
 
945
- if (typeof read !== 'undefined') {
946
- payload['read'] = read;
947
- }
948
-
949
- if (typeof write !== 'undefined') {
950
- payload['write'] = write;
1053
+ if (typeof permissions !== 'undefined') {
1054
+ payload['permissions'] = permissions;
951
1055
  }
952
1056
 
953
1057
  return await this.client.call('post', path, {
@@ -958,12 +1062,22 @@ class Databases extends Service {
958
1062
  /**
959
1063
  * Get Document
960
1064
  *
1065
+ * Get a document by its unique ID. This endpoint response returns a JSON
1066
+ * object with the document data.
1067
+ *
1068
+ * @param {string} databaseId
961
1069
  * @param {string} collectionId
962
1070
  * @param {string} documentId
963
1071
  * @throws {AppwriteException}
964
1072
  * @returns {Promise}
965
1073
  */
966
- async getDocument(collectionId, documentId) {
1074
+ async getDocument(databaseId, collectionId, documentId) {
1075
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
1076
+ let payload = {};
1077
+ if (typeof databaseId === 'undefined') {
1078
+ throw new AppwriteException('Missing required parameter: "databaseId"');
1079
+ }
1080
+
967
1081
  if (typeof collectionId === 'undefined') {
968
1082
  throw new AppwriteException('Missing required parameter: "collectionId"');
969
1083
  }
@@ -972,8 +1086,6 @@ class Databases extends Service {
972
1086
  throw new AppwriteException('Missing required parameter: "documentId"');
973
1087
  }
974
1088
 
975
- let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
976
- let payload = {};
977
1089
 
978
1090
  return await this.client.call('get', path, {
979
1091
  'content-type': 'application/json',
@@ -983,15 +1095,24 @@ class Databases extends Service {
983
1095
  /**
984
1096
  * Update Document
985
1097
  *
1098
+ * Update a document by its unique ID. Using the patch method you can pass
1099
+ * only specific fields that will get updated.
1100
+ *
1101
+ * @param {string} databaseId
986
1102
  * @param {string} collectionId
987
1103
  * @param {string} documentId
988
1104
  * @param {object} data
989
- * @param {string[]} read
990
- * @param {string[]} write
1105
+ * @param {string[]} permissions
991
1106
  * @throws {AppwriteException}
992
1107
  * @returns {Promise}
993
1108
  */
994
- async updateDocument(collectionId, documentId, data, read, write) {
1109
+ async updateDocument(databaseId, collectionId, documentId, data, permissions) {
1110
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
1111
+ let payload = {};
1112
+ if (typeof databaseId === 'undefined') {
1113
+ throw new AppwriteException('Missing required parameter: "databaseId"');
1114
+ }
1115
+
995
1116
  if (typeof collectionId === 'undefined') {
996
1117
  throw new AppwriteException('Missing required parameter: "collectionId"');
997
1118
  }
@@ -1000,19 +1121,13 @@ class Databases extends Service {
1000
1121
  throw new AppwriteException('Missing required parameter: "documentId"');
1001
1122
  }
1002
1123
 
1003
- let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
1004
- let payload = {};
1005
1124
 
1006
1125
  if (typeof data !== 'undefined') {
1007
1126
  payload['data'] = data;
1008
1127
  }
1009
1128
 
1010
- if (typeof read !== 'undefined') {
1011
- payload['read'] = read;
1012
- }
1013
-
1014
- if (typeof write !== 'undefined') {
1015
- payload['write'] = write;
1129
+ if (typeof permissions !== 'undefined') {
1130
+ payload['permissions'] = permissions;
1016
1131
  }
1017
1132
 
1018
1133
  return await this.client.call('patch', path, {
@@ -1023,12 +1138,21 @@ class Databases extends Service {
1023
1138
  /**
1024
1139
  * Delete Document
1025
1140
  *
1141
+ * Delete a document by its unique ID.
1142
+ *
1143
+ * @param {string} databaseId
1026
1144
  * @param {string} collectionId
1027
1145
  * @param {string} documentId
1028
1146
  * @throws {AppwriteException}
1029
1147
  * @returns {Promise}
1030
1148
  */
1031
- async deleteDocument(collectionId, documentId) {
1149
+ async deleteDocument(databaseId, collectionId, documentId) {
1150
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
1151
+ let payload = {};
1152
+ if (typeof databaseId === 'undefined') {
1153
+ throw new AppwriteException('Missing required parameter: "databaseId"');
1154
+ }
1155
+
1032
1156
  if (typeof collectionId === 'undefined') {
1033
1157
  throw new AppwriteException('Missing required parameter: "collectionId"');
1034
1158
  }
@@ -1037,8 +1161,6 @@ class Databases extends Service {
1037
1161
  throw new AppwriteException('Missing required parameter: "documentId"');
1038
1162
  }
1039
1163
 
1040
- let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
1041
- let payload = {};
1042
1164
 
1043
1165
  return await this.client.call('delete', path, {
1044
1166
  'content-type': 'application/json',
@@ -1048,17 +1170,22 @@ class Databases extends Service {
1048
1170
  /**
1049
1171
  * List Indexes
1050
1172
  *
1173
+ * @param {string} databaseId
1051
1174
  * @param {string} collectionId
1052
1175
  * @throws {AppwriteException}
1053
1176
  * @returns {Promise}
1054
1177
  */
1055
- async listIndexes(collectionId) {
1178
+ async listIndexes(databaseId, collectionId) {
1179
+ let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
1180
+ let payload = {};
1181
+ if (typeof databaseId === 'undefined') {
1182
+ throw new AppwriteException('Missing required parameter: "databaseId"');
1183
+ }
1184
+
1056
1185
  if (typeof collectionId === 'undefined') {
1057
1186
  throw new AppwriteException('Missing required parameter: "collectionId"');
1058
1187
  }
1059
1188
 
1060
- let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
1061
- let payload = {};
1062
1189
 
1063
1190
  return await this.client.call('get', path, {
1064
1191
  'content-type': 'application/json',
@@ -1068,6 +1195,7 @@ class Databases extends Service {
1068
1195
  /**
1069
1196
  * Create Index
1070
1197
  *
1198
+ * @param {string} databaseId
1071
1199
  * @param {string} collectionId
1072
1200
  * @param {string} key
1073
1201
  * @param {string} type
@@ -1076,7 +1204,13 @@ class Databases extends Service {
1076
1204
  * @throws {AppwriteException}
1077
1205
  * @returns {Promise}
1078
1206
  */
1079
- async createIndex(collectionId, key, type, attributes, orders) {
1207
+ async createIndex(databaseId, collectionId, key, type, attributes, orders) {
1208
+ let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
1209
+ let payload = {};
1210
+ if (typeof databaseId === 'undefined') {
1211
+ throw new AppwriteException('Missing required parameter: "databaseId"');
1212
+ }
1213
+
1080
1214
  if (typeof collectionId === 'undefined') {
1081
1215
  throw new AppwriteException('Missing required parameter: "collectionId"');
1082
1216
  }
@@ -1093,8 +1227,6 @@ class Databases extends Service {
1093
1227
  throw new AppwriteException('Missing required parameter: "attributes"');
1094
1228
  }
1095
1229
 
1096
- let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
1097
- let payload = {};
1098
1230
 
1099
1231
  if (typeof key !== 'undefined') {
1100
1232
  payload['key'] = key;
@@ -1120,12 +1252,19 @@ class Databases extends Service {
1120
1252
  /**
1121
1253
  * Get Index
1122
1254
  *
1255
+ * @param {string} databaseId
1123
1256
  * @param {string} collectionId
1124
1257
  * @param {string} key
1125
1258
  * @throws {AppwriteException}
1126
1259
  * @returns {Promise}
1127
1260
  */
1128
- async getIndex(collectionId, key) {
1261
+ async getIndex(databaseId, collectionId, key) {
1262
+ let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
1263
+ let payload = {};
1264
+ if (typeof databaseId === 'undefined') {
1265
+ throw new AppwriteException('Missing required parameter: "databaseId"');
1266
+ }
1267
+
1129
1268
  if (typeof collectionId === 'undefined') {
1130
1269
  throw new AppwriteException('Missing required parameter: "collectionId"');
1131
1270
  }
@@ -1134,8 +1273,6 @@ class Databases extends Service {
1134
1273
  throw new AppwriteException('Missing required parameter: "key"');
1135
1274
  }
1136
1275
 
1137
- let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
1138
- let payload = {};
1139
1276
 
1140
1277
  return await this.client.call('get', path, {
1141
1278
  'content-type': 'application/json',
@@ -1145,12 +1282,19 @@ class Databases extends Service {
1145
1282
  /**
1146
1283
  * Delete Index
1147
1284
  *
1285
+ * @param {string} databaseId
1148
1286
  * @param {string} collectionId
1149
1287
  * @param {string} key
1150
1288
  * @throws {AppwriteException}
1151
1289
  * @returns {Promise}
1152
1290
  */
1153
- async deleteIndex(collectionId, key) {
1291
+ async deleteIndex(databaseId, collectionId, key) {
1292
+ let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
1293
+ let payload = {};
1294
+ if (typeof databaseId === 'undefined') {
1295
+ throw new AppwriteException('Missing required parameter: "databaseId"');
1296
+ }
1297
+
1154
1298
  if (typeof collectionId === 'undefined') {
1155
1299
  throw new AppwriteException('Missing required parameter: "collectionId"');
1156
1300
  }
@@ -1159,8 +1303,6 @@ class Databases extends Service {
1159
1303
  throw new AppwriteException('Missing required parameter: "key"');
1160
1304
  }
1161
1305
 
1162
- let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
1163
- let payload = {};
1164
1306
 
1165
1307
  return await this.client.call('delete', path, {
1166
1308
  'content-type': 'application/json',
@@ -1168,4 +1310,4 @@ class Databases extends Service {
1168
1310
  }
1169
1311
  }
1170
1312
 
1171
- module.exports = Databases;
1313
+ module.exports = Databases;