node-appwrite 5.1.0 → 7.0.1

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 (148) hide show
  1. package/README.md +2 -2
  2. package/docs/examples/account/create-phone-verification.md +20 -0
  3. package/docs/examples/account/create-recovery.md +3 -3
  4. package/docs/examples/account/create-verification.md +3 -3
  5. package/docs/examples/account/delete-session.md +3 -3
  6. package/docs/examples/account/delete-sessions.md +3 -3
  7. package/docs/examples/account/get-logs.md +3 -3
  8. package/docs/examples/account/get-prefs.md +3 -3
  9. package/docs/examples/account/get-session.md +3 -3
  10. package/docs/examples/account/get-sessions.md +3 -3
  11. package/docs/examples/account/get.md +3 -3
  12. package/docs/examples/account/update-email.md +3 -3
  13. package/docs/examples/account/update-name.md +3 -3
  14. package/docs/examples/account/update-password.md +3 -3
  15. package/docs/examples/account/update-phone-verification.md +20 -0
  16. package/docs/examples/{database/create-ip-attribute.md → account/update-phone.md} +4 -4
  17. package/docs/examples/account/update-prefs.md +3 -3
  18. package/docs/examples/account/update-recovery.md +3 -3
  19. package/docs/examples/account/update-session.md +3 -3
  20. package/docs/examples/account/{delete.md → update-status.md} +3 -3
  21. package/docs/examples/account/update-verification.md +3 -3
  22. package/docs/examples/avatars/get-browser.md +3 -3
  23. package/docs/examples/avatars/get-credit-card.md +3 -3
  24. package/docs/examples/avatars/get-favicon.md +3 -3
  25. package/docs/examples/avatars/get-flag.md +3 -3
  26. package/docs/examples/avatars/get-image.md +3 -3
  27. package/docs/examples/avatars/get-initials.md +3 -3
  28. package/docs/examples/avatars/get-q-r.md +3 -3
  29. package/docs/examples/databases/create-boolean-attribute.md +20 -0
  30. package/docs/examples/{database → databases}/create-collection.md +3 -3
  31. package/docs/examples/databases/create-document.md +20 -0
  32. package/docs/examples/databases/create-email-attribute.md +20 -0
  33. package/docs/examples/databases/create-enum-attribute.md +20 -0
  34. package/docs/examples/{database → databases}/create-float-attribute.md +3 -3
  35. package/docs/examples/{database → databases}/create-index.md +3 -3
  36. package/docs/examples/{database → databases}/create-integer-attribute.md +3 -3
  37. package/docs/examples/{database/create-email-attribute.md → databases/create-ip-attribute.md} +3 -3
  38. package/docs/examples/{database → databases}/create-string-attribute.md +3 -3
  39. package/docs/examples/{database → databases}/create-url-attribute.md +3 -3
  40. package/docs/examples/{database/delete-attribute.md → databases/create.md} +3 -3
  41. package/docs/examples/databases/delete-attribute.md +20 -0
  42. package/docs/examples/databases/delete-collection.md +20 -0
  43. package/docs/examples/databases/delete-document.md +20 -0
  44. package/docs/examples/{database/create-document.md → databases/delete-index.md} +3 -3
  45. package/docs/examples/{database/delete-index.md → databases/delete.md} +3 -3
  46. package/docs/examples/databases/get-attribute.md +20 -0
  47. package/docs/examples/{database → databases}/get-collection.md +3 -3
  48. package/docs/examples/{database/delete-document.md → databases/get-document.md} +3 -3
  49. package/docs/examples/{database/create-boolean-attribute.md → databases/get-index.md} +3 -3
  50. package/docs/examples/{database/get-index.md → databases/get.md} +3 -3
  51. package/docs/examples/{database → databases}/list-attributes.md +3 -3
  52. package/docs/examples/databases/list-collections.md +20 -0
  53. package/docs/examples/{database/create-enum-attribute.md → databases/list-documents.md} +3 -3
  54. package/docs/examples/{database → databases}/list-indexes.md +3 -3
  55. package/docs/examples/{database/list-documents.md → databases/list.md} +3 -3
  56. package/docs/examples/{database → databases}/update-collection.md +3 -3
  57. package/docs/examples/{database → databases}/update-document.md +3 -3
  58. package/docs/examples/databases/update.md +20 -0
  59. package/docs/examples/functions/create-deployment.md +3 -3
  60. package/docs/examples/functions/create-execution.md +3 -3
  61. package/docs/examples/functions/create.md +3 -3
  62. package/docs/examples/functions/delete-deployment.md +3 -3
  63. package/docs/examples/functions/delete.md +3 -3
  64. package/docs/examples/functions/get-deployment.md +3 -3
  65. package/docs/examples/functions/get-execution.md +3 -3
  66. package/docs/examples/functions/get.md +3 -3
  67. package/docs/examples/functions/list-deployments.md +3 -3
  68. package/docs/examples/functions/list-executions.md +3 -3
  69. package/docs/examples/functions/list-runtimes.md +3 -3
  70. package/docs/examples/functions/list.md +3 -3
  71. package/docs/examples/functions/retry-build.md +3 -3
  72. package/docs/examples/functions/update-deployment.md +3 -3
  73. package/docs/examples/functions/update.md +3 -3
  74. package/docs/examples/health/get-antivirus.md +3 -3
  75. package/docs/examples/health/get-cache.md +3 -3
  76. package/docs/examples/health/get-d-b.md +3 -3
  77. package/docs/examples/health/get-queue-certificates.md +3 -3
  78. package/docs/examples/health/get-queue-functions.md +3 -3
  79. package/docs/examples/health/get-queue-logs.md +3 -3
  80. package/docs/examples/health/get-queue-webhooks.md +3 -3
  81. package/docs/examples/health/get-storage-local.md +3 -3
  82. package/docs/examples/health/get-time.md +3 -3
  83. package/docs/examples/health/get.md +3 -3
  84. package/docs/examples/locale/get-continents.md +3 -3
  85. package/docs/examples/locale/get-countries-e-u.md +3 -3
  86. package/docs/examples/locale/get-countries-phones.md +3 -3
  87. package/docs/examples/locale/get-countries.md +3 -3
  88. package/docs/examples/locale/get-currencies.md +3 -3
  89. package/docs/examples/locale/get-languages.md +3 -3
  90. package/docs/examples/locale/get.md +3 -3
  91. package/docs/examples/storage/create-bucket.md +3 -3
  92. package/docs/examples/storage/create-file.md +3 -3
  93. package/docs/examples/storage/delete-bucket.md +3 -3
  94. package/docs/examples/storage/delete-file.md +3 -3
  95. package/docs/examples/storage/get-bucket.md +3 -3
  96. package/docs/examples/storage/get-file-download.md +3 -3
  97. package/docs/examples/storage/get-file-preview.md +3 -3
  98. package/docs/examples/storage/get-file-view.md +3 -3
  99. package/docs/examples/storage/get-file.md +3 -3
  100. package/docs/examples/storage/list-buckets.md +3 -3
  101. package/docs/examples/storage/list-files.md +3 -3
  102. package/docs/examples/storage/update-bucket.md +3 -3
  103. package/docs/examples/storage/update-file.md +3 -3
  104. package/docs/examples/teams/create-membership.md +3 -3
  105. package/docs/examples/teams/create.md +3 -3
  106. package/docs/examples/teams/delete-membership.md +3 -3
  107. package/docs/examples/teams/delete.md +3 -3
  108. package/docs/examples/teams/get-membership.md +3 -3
  109. package/docs/examples/teams/get-memberships.md +3 -3
  110. package/docs/examples/teams/get.md +3 -3
  111. package/docs/examples/teams/list.md +3 -3
  112. package/docs/examples/teams/update-membership-roles.md +3 -3
  113. package/docs/examples/teams/update-membership-status.md +3 -3
  114. package/docs/examples/teams/update.md +3 -3
  115. package/docs/examples/users/create.md +3 -3
  116. package/docs/examples/users/delete-session.md +3 -3
  117. package/docs/examples/users/delete-sessions.md +3 -3
  118. package/docs/examples/users/delete.md +3 -3
  119. package/docs/examples/users/get-logs.md +3 -3
  120. package/docs/examples/{database/list-collections.md → users/get-memberships.md} +3 -3
  121. package/docs/examples/users/get-prefs.md +3 -3
  122. package/docs/examples/users/get-sessions.md +3 -3
  123. package/docs/examples/users/get.md +3 -3
  124. package/docs/examples/users/list.md +3 -3
  125. package/docs/examples/{database/delete-collection.md → users/update-email-verification.md} +3 -3
  126. package/docs/examples/users/update-email.md +3 -3
  127. package/docs/examples/users/update-name.md +3 -3
  128. package/docs/examples/users/update-password.md +3 -3
  129. package/docs/examples/{database/get-attribute.md → users/update-phone-verification.md} +3 -3
  130. package/docs/examples/{health/get-queue-usage.md → users/update-phone.md} +3 -3
  131. package/docs/examples/users/update-prefs.md +3 -3
  132. package/docs/examples/users/update-status.md +3 -3
  133. package/index.d.ts +375 -161
  134. package/index.js +4 -2
  135. package/lib/client.js +9 -3
  136. package/lib/inputFile.js +47 -0
  137. package/lib/services/account.js +127 -24
  138. package/lib/services/avatars.js +35 -3
  139. package/lib/services/{database.js → databases.js} +183 -89
  140. package/lib/services/functions.js +100 -42
  141. package/lib/services/health.js +2 -18
  142. package/lib/services/locale.js +2 -0
  143. package/lib/services/storage.js +108 -50
  144. package/lib/services/teams.js +2 -0
  145. package/lib/services/users.js +94 -3
  146. package/package.json +2 -2
  147. package/docs/examples/database/get-document.md +0 -20
  148. package/docs/examples/users/update-verification.md +0 -20
@@ -1,18 +1,169 @@
1
1
  const Service = require('../service.js');
2
2
  const AppwriteException = require('../exception.js');
3
+ const InputFile = require('../inputFile.js');
3
4
  const client = require('../client.js');
5
+ const Stream = require('stream');
4
6
  const { promisify } = require('util');
5
7
  const fs = require('fs');
6
8
 
7
- class Database extends Service {
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(databaseId)
28
+ {
29
+ return this.databaseId;
30
+ }
31
+ constructor(client, databaseId)
32
+ {
33
+ super(client);
34
+
35
+ this.databaseId = databaseId;
36
+ }
8
37
 
9
38
  /**
10
- * List Collections
39
+ * List Databases
11
40
  *
12
- * Get a list of all the user collections. You can use the query params to
13
- * filter your results. On admin mode, this endpoint will return a list of all
14
- * of the project's collections. [Learn more about different API
15
- * modes](/docs/admin).
41
+ * @param {string} search
42
+ * @param {number} limit
43
+ * @param {number} offset
44
+ * @param {string} cursor
45
+ * @param {string} cursorDirection
46
+ * @param {string} orderType
47
+ * @throws {AppwriteException}
48
+ * @returns {Promise}
49
+ */
50
+ async list(search, limit, offset, cursor, cursorDirection, orderType) {
51
+ let path = '/databases';
52
+ let payload = {};
53
+
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;
72
+ }
73
+
74
+ if (typeof orderType !== 'undefined') {
75
+ payload['orderType'] = orderType;
76
+ }
77
+
78
+ return await this.client.call('get', path, {
79
+ 'content-type': 'application/json',
80
+ }, payload);
81
+ }
82
+
83
+ /**
84
+ * Create Database
85
+ *
86
+ * @param {string} name
87
+ * @throws {AppwriteException}
88
+ * @returns {Promise}
89
+ */
90
+ async create(name) {
91
+ if (typeof name === 'undefined') {
92
+ throw new AppwriteException('Missing required parameter: "name"');
93
+ }
94
+
95
+ let path = '/databases';
96
+ let payload = {};
97
+
98
+ if (typeof this.databaseId !== 'undefined') {
99
+ payload['databaseId'] = this.databaseId;
100
+ }
101
+
102
+ if (typeof name !== 'undefined') {
103
+ payload['name'] = name;
104
+ }
105
+
106
+ return await this.client.call('post', path, {
107
+ 'content-type': 'application/json',
108
+ }, payload);
109
+ }
110
+
111
+ /**
112
+ * Get Database
113
+ *
114
+ * @throws {AppwriteException}
115
+ * @returns {Promise}
116
+ */
117
+ async get() {
118
+ let path = '/databases/{databaseId}'.replace('{databaseId}', this.databaseId);
119
+ let payload = {};
120
+
121
+ return await this.client.call('get', path, {
122
+ 'content-type': 'application/json',
123
+ }, payload);
124
+ }
125
+
126
+ /**
127
+ * Update Database
128
+ *
129
+ * @param {string} name
130
+ * @throws {AppwriteException}
131
+ * @returns {Promise}
132
+ */
133
+ async update(name) {
134
+ if (typeof name === 'undefined') {
135
+ throw new AppwriteException('Missing required parameter: "name"');
136
+ }
137
+
138
+ let path = '/databases/{databaseId}'.replace('{databaseId}', this.databaseId);
139
+ let payload = {};
140
+
141
+ if (typeof name !== 'undefined') {
142
+ payload['name'] = name;
143
+ }
144
+
145
+ return await this.client.call('put', path, {
146
+ 'content-type': 'application/json',
147
+ }, payload);
148
+ }
149
+
150
+ /**
151
+ * Delete Database
152
+ *
153
+ * @throws {AppwriteException}
154
+ * @returns {Promise}
155
+ */
156
+ async delete() {
157
+ let path = '/databases/{databaseId}'.replace('{databaseId}', this.databaseId);
158
+ let payload = {};
159
+
160
+ return await this.client.call('delete', path, {
161
+ 'content-type': 'application/json',
162
+ }, payload);
163
+ }
164
+
165
+ /**
166
+ * List Collections
16
167
  *
17
168
  * @param {string} search
18
169
  * @param {number} limit
@@ -24,7 +175,7 @@ class Database extends Service {
24
175
  * @returns {Promise}
25
176
  */
26
177
  async listCollections(search, limit, offset, cursor, cursorDirection, orderType) {
27
- let path = '/database/collections';
178
+ let path = '/databases/{databaseId}/collections'.replace('{databaseId}', this.databaseId);
28
179
  let payload = {};
29
180
 
30
181
  if (typeof search !== 'undefined') {
@@ -59,8 +210,6 @@ class Database extends Service {
59
210
  /**
60
211
  * Create Collection
61
212
  *
62
- * Create a new Collection.
63
- *
64
213
  * @param {string} collectionId
65
214
  * @param {string} name
66
215
  * @param {string} permission
@@ -90,7 +239,7 @@ class Database extends Service {
90
239
  throw new AppwriteException('Missing required parameter: "write"');
91
240
  }
92
241
 
93
- let path = '/database/collections';
242
+ let path = '/databases/{databaseId}/collections'.replace('{databaseId}', this.databaseId);
94
243
  let payload = {};
95
244
 
96
245
  if (typeof collectionId !== 'undefined') {
@@ -121,9 +270,6 @@ class Database extends Service {
121
270
  /**
122
271
  * Get Collection
123
272
  *
124
- * Get a collection by its unique ID. This endpoint response returns a JSON
125
- * object with the collection metadata.
126
- *
127
273
  * @param {string} collectionId
128
274
  * @throws {AppwriteException}
129
275
  * @returns {Promise}
@@ -133,7 +279,7 @@ class Database extends Service {
133
279
  throw new AppwriteException('Missing required parameter: "collectionId"');
134
280
  }
135
281
 
136
- let path = '/database/collections/{collectionId}'.replace('{collectionId}', collectionId);
282
+ let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
137
283
  let payload = {};
138
284
 
139
285
  return await this.client.call('get', path, {
@@ -144,8 +290,6 @@ class Database extends Service {
144
290
  /**
145
291
  * Update Collection
146
292
  *
147
- * Update a collection by its unique ID.
148
- *
149
293
  * @param {string} collectionId
150
294
  * @param {string} name
151
295
  * @param {string} permission
@@ -168,7 +312,7 @@ class Database extends Service {
168
312
  throw new AppwriteException('Missing required parameter: "permission"');
169
313
  }
170
314
 
171
- let path = '/database/collections/{collectionId}'.replace('{collectionId}', collectionId);
315
+ let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
172
316
  let payload = {};
173
317
 
174
318
  if (typeof name !== 'undefined') {
@@ -199,9 +343,6 @@ class Database extends Service {
199
343
  /**
200
344
  * Delete Collection
201
345
  *
202
- * Delete a collection by its unique ID. Only users with write permissions
203
- * have access to delete this resource.
204
- *
205
346
  * @param {string} collectionId
206
347
  * @throws {AppwriteException}
207
348
  * @returns {Promise}
@@ -211,7 +352,7 @@ class Database extends Service {
211
352
  throw new AppwriteException('Missing required parameter: "collectionId"');
212
353
  }
213
354
 
214
- let path = '/database/collections/{collectionId}'.replace('{collectionId}', collectionId);
355
+ let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
215
356
  let payload = {};
216
357
 
217
358
  return await this.client.call('delete', path, {
@@ -231,7 +372,7 @@ class Database extends Service {
231
372
  throw new AppwriteException('Missing required parameter: "collectionId"');
232
373
  }
233
374
 
234
- let path = '/database/collections/{collectionId}/attributes'.replace('{collectionId}', collectionId);
375
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
235
376
  let payload = {};
236
377
 
237
378
  return await this.client.call('get', path, {
@@ -242,9 +383,6 @@ class Database extends Service {
242
383
  /**
243
384
  * Create Boolean Attribute
244
385
  *
245
- * Create a boolean attribute.
246
- *
247
- *
248
386
  * @param {string} collectionId
249
387
  * @param {string} key
250
388
  * @param {boolean} required
@@ -266,7 +404,7 @@ class Database extends Service {
266
404
  throw new AppwriteException('Missing required parameter: "required"');
267
405
  }
268
406
 
269
- let path = '/database/collections/{collectionId}/attributes/boolean'.replace('{collectionId}', collectionId);
407
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
270
408
  let payload = {};
271
409
 
272
410
  if (typeof key !== 'undefined') {
@@ -293,9 +431,6 @@ class Database extends Service {
293
431
  /**
294
432
  * Create Email Attribute
295
433
  *
296
- * Create an email attribute.
297
- *
298
- *
299
434
  * @param {string} collectionId
300
435
  * @param {string} key
301
436
  * @param {boolean} required
@@ -317,7 +452,7 @@ class Database extends Service {
317
452
  throw new AppwriteException('Missing required parameter: "required"');
318
453
  }
319
454
 
320
- let path = '/database/collections/{collectionId}/attributes/email'.replace('{collectionId}', collectionId);
455
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
321
456
  let payload = {};
322
457
 
323
458
  if (typeof key !== 'undefined') {
@@ -370,7 +505,7 @@ class Database extends Service {
370
505
  throw new AppwriteException('Missing required parameter: "required"');
371
506
  }
372
507
 
373
- let path = '/database/collections/{collectionId}/attributes/enum'.replace('{collectionId}', collectionId);
508
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
374
509
  let payload = {};
375
510
 
376
511
  if (typeof key !== 'undefined') {
@@ -401,10 +536,6 @@ class Database extends Service {
401
536
  /**
402
537
  * Create Float Attribute
403
538
  *
404
- * Create a float attribute. Optionally, minimum and maximum values can be
405
- * provided.
406
- *
407
- *
408
539
  * @param {string} collectionId
409
540
  * @param {string} key
410
541
  * @param {boolean} required
@@ -428,7 +559,7 @@ class Database extends Service {
428
559
  throw new AppwriteException('Missing required parameter: "required"');
429
560
  }
430
561
 
431
- let path = '/database/collections/{collectionId}/attributes/float'.replace('{collectionId}', collectionId);
562
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
432
563
  let payload = {};
433
564
 
434
565
  if (typeof key !== 'undefined') {
@@ -463,10 +594,6 @@ class Database extends Service {
463
594
  /**
464
595
  * Create Integer Attribute
465
596
  *
466
- * Create an integer attribute. Optionally, minimum and maximum values can be
467
- * provided.
468
- *
469
- *
470
597
  * @param {string} collectionId
471
598
  * @param {string} key
472
599
  * @param {boolean} required
@@ -490,7 +617,7 @@ class Database extends Service {
490
617
  throw new AppwriteException('Missing required parameter: "required"');
491
618
  }
492
619
 
493
- let path = '/database/collections/{collectionId}/attributes/integer'.replace('{collectionId}', collectionId);
620
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
494
621
  let payload = {};
495
622
 
496
623
  if (typeof key !== 'undefined') {
@@ -525,9 +652,6 @@ class Database extends Service {
525
652
  /**
526
653
  * Create IP Address Attribute
527
654
  *
528
- * Create IP address attribute.
529
- *
530
- *
531
655
  * @param {string} collectionId
532
656
  * @param {string} key
533
657
  * @param {boolean} required
@@ -549,7 +673,7 @@ class Database extends Service {
549
673
  throw new AppwriteException('Missing required parameter: "required"');
550
674
  }
551
675
 
552
- let path = '/database/collections/{collectionId}/attributes/ip'.replace('{collectionId}', collectionId);
676
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
553
677
  let payload = {};
554
678
 
555
679
  if (typeof key !== 'undefined') {
@@ -576,9 +700,6 @@ class Database extends Service {
576
700
  /**
577
701
  * Create String Attribute
578
702
  *
579
- * Create a string attribute.
580
- *
581
- *
582
703
  * @param {string} collectionId
583
704
  * @param {string} key
584
705
  * @param {number} size
@@ -605,7 +726,7 @@ class Database extends Service {
605
726
  throw new AppwriteException('Missing required parameter: "required"');
606
727
  }
607
728
 
608
- let path = '/database/collections/{collectionId}/attributes/string'.replace('{collectionId}', collectionId);
729
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
609
730
  let payload = {};
610
731
 
611
732
  if (typeof key !== 'undefined') {
@@ -636,9 +757,6 @@ class Database extends Service {
636
757
  /**
637
758
  * Create URL Attribute
638
759
  *
639
- * Create a URL attribute.
640
- *
641
- *
642
760
  * @param {string} collectionId
643
761
  * @param {string} key
644
762
  * @param {boolean} required
@@ -660,7 +778,7 @@ class Database extends Service {
660
778
  throw new AppwriteException('Missing required parameter: "required"');
661
779
  }
662
780
 
663
- let path = '/database/collections/{collectionId}/attributes/url'.replace('{collectionId}', collectionId);
781
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
664
782
  let payload = {};
665
783
 
666
784
  if (typeof key !== 'undefined') {
@@ -701,7 +819,7 @@ class Database extends Service {
701
819
  throw new AppwriteException('Missing required parameter: "key"');
702
820
  }
703
821
 
704
- let path = '/database/collections/{collectionId}/attributes/{key}'.replace('{collectionId}', collectionId).replace('{key}', key);
822
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
705
823
  let payload = {};
706
824
 
707
825
  return await this.client.call('get', path, {
@@ -726,7 +844,7 @@ class Database extends Service {
726
844
  throw new AppwriteException('Missing required parameter: "key"');
727
845
  }
728
846
 
729
- let path = '/database/collections/{collectionId}/attributes/{key}'.replace('{collectionId}', collectionId).replace('{key}', key);
847
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
730
848
  let payload = {};
731
849
 
732
850
  return await this.client.call('delete', path, {
@@ -737,11 +855,6 @@ class Database extends Service {
737
855
  /**
738
856
  * List Documents
739
857
  *
740
- * Get a list of all the user documents. You can use the query params to
741
- * filter your results. On admin mode, this endpoint will return a list of all
742
- * of the project's documents. [Learn more about different API
743
- * modes](/docs/admin).
744
- *
745
858
  * @param {string} collectionId
746
859
  * @param {string[]} queries
747
860
  * @param {number} limit
@@ -758,7 +871,7 @@ class Database extends Service {
758
871
  throw new AppwriteException('Missing required parameter: "collectionId"');
759
872
  }
760
873
 
761
- let path = '/database/collections/{collectionId}/documents'.replace('{collectionId}', collectionId);
874
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
762
875
  let payload = {};
763
876
 
764
877
  if (typeof queries !== 'undefined') {
@@ -797,11 +910,6 @@ class Database extends Service {
797
910
  /**
798
911
  * Create Document
799
912
  *
800
- * Create a new Document. Before using this route, you should create a new
801
- * collection resource using either a [server
802
- * integration](/docs/server/database#databaseCreateCollection) API or
803
- * directly from your database console.
804
- *
805
913
  * @param {string} collectionId
806
914
  * @param {string} documentId
807
915
  * @param {object} data
@@ -823,7 +931,7 @@ class Database extends Service {
823
931
  throw new AppwriteException('Missing required parameter: "data"');
824
932
  }
825
933
 
826
- let path = '/database/collections/{collectionId}/documents'.replace('{collectionId}', collectionId);
934
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
827
935
  let payload = {};
828
936
 
829
937
  if (typeof documentId !== 'undefined') {
@@ -850,9 +958,6 @@ class Database extends Service {
850
958
  /**
851
959
  * Get Document
852
960
  *
853
- * Get a document by its unique ID. This endpoint response returns a JSON
854
- * object with the document data.
855
- *
856
961
  * @param {string} collectionId
857
962
  * @param {string} documentId
858
963
  * @throws {AppwriteException}
@@ -867,7 +972,7 @@ class Database extends Service {
867
972
  throw new AppwriteException('Missing required parameter: "documentId"');
868
973
  }
869
974
 
870
- let path = '/database/collections/{collectionId}/documents/{documentId}'.replace('{collectionId}', collectionId).replace('{documentId}', documentId);
975
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
871
976
  let payload = {};
872
977
 
873
978
  return await this.client.call('get', path, {
@@ -878,9 +983,6 @@ class Database extends Service {
878
983
  /**
879
984
  * Update Document
880
985
  *
881
- * Update a document by its unique ID. Using the patch method you can pass
882
- * only specific fields that will get updated.
883
- *
884
986
  * @param {string} collectionId
885
987
  * @param {string} documentId
886
988
  * @param {object} data
@@ -898,11 +1000,7 @@ class Database extends Service {
898
1000
  throw new AppwriteException('Missing required parameter: "documentId"');
899
1001
  }
900
1002
 
901
- if (typeof data === 'undefined') {
902
- throw new AppwriteException('Missing required parameter: "data"');
903
- }
904
-
905
- let path = '/database/collections/{collectionId}/documents/{documentId}'.replace('{collectionId}', collectionId).replace('{documentId}', documentId);
1003
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
906
1004
  let payload = {};
907
1005
 
908
1006
  if (typeof data !== 'undefined') {
@@ -925,10 +1023,6 @@ class Database extends Service {
925
1023
  /**
926
1024
  * Delete Document
927
1025
  *
928
- * Delete a document by its unique ID. This endpoint deletes only the parent
929
- * documents, its attributes and relations to other documents. Child documents
930
- * **will not** be deleted.
931
- *
932
1026
  * @param {string} collectionId
933
1027
  * @param {string} documentId
934
1028
  * @throws {AppwriteException}
@@ -943,7 +1037,7 @@ class Database extends Service {
943
1037
  throw new AppwriteException('Missing required parameter: "documentId"');
944
1038
  }
945
1039
 
946
- let path = '/database/collections/{collectionId}/documents/{documentId}'.replace('{collectionId}', collectionId).replace('{documentId}', documentId);
1040
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
947
1041
  let payload = {};
948
1042
 
949
1043
  return await this.client.call('delete', path, {
@@ -963,7 +1057,7 @@ class Database extends Service {
963
1057
  throw new AppwriteException('Missing required parameter: "collectionId"');
964
1058
  }
965
1059
 
966
- let path = '/database/collections/{collectionId}/indexes'.replace('{collectionId}', collectionId);
1060
+ let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
967
1061
  let payload = {};
968
1062
 
969
1063
  return await this.client.call('get', path, {
@@ -999,7 +1093,7 @@ class Database extends Service {
999
1093
  throw new AppwriteException('Missing required parameter: "attributes"');
1000
1094
  }
1001
1095
 
1002
- let path = '/database/collections/{collectionId}/indexes'.replace('{collectionId}', collectionId);
1096
+ let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId);
1003
1097
  let payload = {};
1004
1098
 
1005
1099
  if (typeof key !== 'undefined') {
@@ -1040,7 +1134,7 @@ class Database extends Service {
1040
1134
  throw new AppwriteException('Missing required parameter: "key"');
1041
1135
  }
1042
1136
 
1043
- let path = '/database/collections/{collectionId}/indexes/{key}'.replace('{collectionId}', collectionId).replace('{key}', key);
1137
+ let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
1044
1138
  let payload = {};
1045
1139
 
1046
1140
  return await this.client.call('get', path, {
@@ -1065,7 +1159,7 @@ class Database extends Service {
1065
1159
  throw new AppwriteException('Missing required parameter: "key"');
1066
1160
  }
1067
1161
 
1068
- let path = '/database/collections/{collectionId}/indexes/{key}'.replace('{collectionId}', collectionId).replace('{key}', key);
1162
+ let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
1069
1163
  let payload = {};
1070
1164
 
1071
1165
  return await this.client.call('delete', path, {
@@ -1074,4 +1168,4 @@ class Database extends Service {
1074
1168
  }
1075
1169
  }
1076
1170
 
1077
- module.exports = Database;
1171
+ module.exports = Databases;