@appwrite.io/console 6.0.0 → 7.0.0-rc.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.
- package/README.md +1 -1
- package/dist/cjs/sdk.js +12678 -10125
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +12677 -10126
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +12566 -10013
- package/docs/examples/databases/create-index.md +2 -2
- package/docs/examples/documentsdb/create-collection.md +22 -0
- package/docs/examples/documentsdb/create-document.md +25 -0
- package/docs/examples/documentsdb/create-documents.md +17 -0
- package/docs/examples/documentsdb/create-index.md +21 -0
- package/docs/examples/documentsdb/create-transaction.md +15 -0
- package/docs/examples/documentsdb/create.md +17 -0
- package/docs/examples/documentsdb/decrement-document-attribute.md +21 -0
- package/docs/examples/documentsdb/delete-collection.md +16 -0
- package/docs/examples/documentsdb/delete-document.md +18 -0
- package/docs/examples/documentsdb/delete-documents.md +18 -0
- package/docs/examples/documentsdb/delete-index.md +17 -0
- package/docs/examples/documentsdb/delete-transaction.md +15 -0
- package/docs/examples/documentsdb/delete.md +15 -0
- package/docs/examples/documentsdb/get-collection-usage.md +17 -0
- package/docs/examples/documentsdb/get-collection.md +16 -0
- package/docs/examples/documentsdb/get-document.md +19 -0
- package/docs/examples/documentsdb/get-index.md +17 -0
- package/docs/examples/documentsdb/get-transaction.md +15 -0
- package/docs/examples/documentsdb/get-usage.md +16 -0
- package/docs/examples/documentsdb/get.md +15 -0
- package/docs/examples/documentsdb/increment-document-attribute.md +21 -0
- package/docs/examples/documentsdb/list-collection-logs.md +17 -0
- package/docs/examples/documentsdb/list-collections.md +18 -0
- package/docs/examples/documentsdb/list-document-logs.md +18 -0
- package/docs/examples/documentsdb/list-documents.md +20 -0
- package/docs/examples/documentsdb/list-indexes.md +18 -0
- package/docs/examples/documentsdb/list-transactions.md +15 -0
- package/docs/examples/documentsdb/list-usage.md +15 -0
- package/docs/examples/documentsdb/list.md +17 -0
- package/docs/examples/documentsdb/update-collection.md +20 -0
- package/docs/examples/documentsdb/update-document.md +20 -0
- package/docs/examples/documentsdb/update-documents.md +19 -0
- package/docs/examples/documentsdb/update-transaction.md +17 -0
- package/docs/examples/documentsdb/update.md +17 -0
- package/docs/examples/documentsdb/upsert-document.md +20 -0
- package/docs/examples/documentsdb/upsert-documents.md +18 -0
- package/docs/examples/domains/confirm-purchase.md +16 -0
- package/docs/examples/domains/confirm-transfer-in.md +16 -0
- package/docs/examples/projects/create-webhook.md +22 -0
- package/docs/examples/projects/delete-webhook.md +16 -0
- package/docs/examples/projects/get-webhook.md +16 -0
- package/docs/examples/projects/list-webhooks.md +16 -0
- package/docs/examples/projects/update-webhook-signature.md +16 -0
- package/docs/examples/projects/update-webhook.md +23 -0
- package/docs/examples/tablesdb/create-index.md +2 -2
- package/docs/examples/vectorsdb/create-collection.md +21 -0
- package/docs/examples/vectorsdb/create-document.md +29 -0
- package/docs/examples/vectorsdb/create-documents.md +17 -0
- package/docs/examples/vectorsdb/create-index.md +21 -0
- package/docs/examples/vectorsdb/create-operations.md +26 -0
- package/docs/examples/vectorsdb/create-text-embeddings.md +16 -0
- package/docs/examples/vectorsdb/create-transaction.md +15 -0
- package/docs/examples/vectorsdb/create.md +17 -0
- package/docs/examples/vectorsdb/delete-collection.md +16 -0
- package/docs/examples/vectorsdb/delete-document.md +18 -0
- package/docs/examples/vectorsdb/delete-documents.md +18 -0
- package/docs/examples/vectorsdb/delete-index.md +17 -0
- package/docs/examples/vectorsdb/delete-transaction.md +15 -0
- package/docs/examples/vectorsdb/delete.md +15 -0
- package/docs/examples/vectorsdb/get-collection-usage.md +17 -0
- package/docs/examples/vectorsdb/get-collection.md +16 -0
- package/docs/examples/vectorsdb/get-document.md +19 -0
- package/docs/examples/vectorsdb/get-index.md +17 -0
- package/docs/examples/vectorsdb/get-transaction.md +15 -0
- package/docs/examples/vectorsdb/get-usage.md +16 -0
- package/docs/examples/vectorsdb/get.md +15 -0
- package/docs/examples/vectorsdb/list-collection-logs.md +17 -0
- package/docs/examples/vectorsdb/list-collections.md +18 -0
- package/docs/examples/vectorsdb/list-documents.md +20 -0
- package/docs/examples/vectorsdb/list-indexes.md +18 -0
- package/docs/examples/vectorsdb/list-transactions.md +15 -0
- package/docs/examples/vectorsdb/list-usage.md +15 -0
- package/docs/examples/vectorsdb/list.md +17 -0
- package/docs/examples/vectorsdb/update-collection.md +21 -0
- package/docs/examples/vectorsdb/update-document.md +20 -0
- package/docs/examples/vectorsdb/update-documents.md +19 -0
- package/docs/examples/vectorsdb/update-transaction.md +17 -0
- package/docs/examples/vectorsdb/update.md +17 -0
- package/docs/examples/vectorsdb/upsert-document.md +20 -0
- package/docs/examples/vectorsdb/upsert-documents.md +18 -0
- package/package.json +1 -1
- package/src/enums/appwrite-migration-resource.ts +2 -0
- package/src/enums/backup-services.ts +3 -0
- package/src/enums/build-runtime.ts +6 -0
- package/src/enums/database-type.ts +2 -0
- package/src/enums/databases-index-type.ts +6 -0
- package/src/enums/documents-db-index-type.ts +6 -0
- package/src/enums/domain-purchase-payment-status.ts +10 -0
- package/src/enums/domain-transfer-status-status.ts +10 -0
- package/src/enums/model.ts +3 -0
- package/src/enums/runtime.ts +6 -0
- package/src/enums/runtimes.ts +6 -0
- package/src/enums/{index-type.ts → tables-db-index-type.ts} +1 -1
- package/src/enums/vectors-db-index-type.ts +8 -0
- package/src/index.ts +8 -2
- package/src/models.ts +461 -3
- package/src/services/databases.ts +10 -10
- package/src/services/documents-db.ts +2608 -0
- package/src/services/tables-db.ts +10 -10
- package/src/services/vectors-db.ts +2406 -0
- package/types/enums/appwrite-migration-resource.d.ts +2 -0
- package/types/enums/backup-services.d.ts +3 -0
- package/types/enums/build-runtime.d.ts +6 -0
- package/types/enums/database-type.d.ts +3 -1
- package/types/enums/databases-index-type.d.ts +6 -0
- package/types/enums/documents-db-index-type.d.ts +6 -0
- package/types/enums/domain-purchase-payment-status.d.ts +10 -0
- package/types/enums/domain-transfer-status-status.d.ts +10 -0
- package/types/enums/model.d.ts +3 -0
- package/types/enums/runtime.d.ts +6 -0
- package/types/enums/runtimes.d.ts +6 -0
- package/types/enums/{index-type.d.ts → tables-db-index-type.d.ts} +1 -1
- package/types/enums/vectors-db-index-type.d.ts +8 -0
- package/types/index.d.ts +8 -2
- package/types/models.d.ts +452 -3
- package/types/services/databases.d.ts +5 -5
- package/types/services/documents-db.d.ts +977 -0
- package/types/services/tables-db.d.ts +5 -5
- package/types/services/vectors-db.d.ts +854 -0
- package/.github/workflows/autoclose.yml +0 -11
|
@@ -0,0 +1,2608 @@
|
|
|
1
|
+
import { Service } from '../service';
|
|
2
|
+
import { AppwriteException, Client, type Payload, UploadProgress } from '../client';
|
|
3
|
+
import type { Models } from '../models';
|
|
4
|
+
|
|
5
|
+
import { UsageRange } from '../enums/usage-range';
|
|
6
|
+
import { DocumentsDBIndexType } from '../enums/documents-db-index-type';
|
|
7
|
+
import { OrderBy } from '../enums/order-by';
|
|
8
|
+
|
|
9
|
+
export class DocumentsDB {
|
|
10
|
+
client: Client;
|
|
11
|
+
|
|
12
|
+
constructor(client: Client) {
|
|
13
|
+
this.client = client;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results.
|
|
18
|
+
*
|
|
19
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name
|
|
20
|
+
* @param {string} params.search - Search term to filter your list results. Max length: 256 chars.
|
|
21
|
+
* @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
|
|
22
|
+
* @throws {AppwriteException}
|
|
23
|
+
* @returns {Promise<Models.DatabaseList>}
|
|
24
|
+
*/
|
|
25
|
+
list(params?: { queries?: string[], search?: string, total?: boolean }): Promise<Models.DatabaseList>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results.
|
|
28
|
+
*
|
|
29
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name
|
|
30
|
+
* @param {string} search - Search term to filter your list results. Max length: 256 chars.
|
|
31
|
+
* @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
|
|
32
|
+
* @throws {AppwriteException}
|
|
33
|
+
* @returns {Promise<Models.DatabaseList>}
|
|
34
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
35
|
+
*/
|
|
36
|
+
list(queries?: string[], search?: string, total?: boolean): Promise<Models.DatabaseList>;
|
|
37
|
+
list(
|
|
38
|
+
paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[],
|
|
39
|
+
...rest: [(string)?, (boolean)?]
|
|
40
|
+
): Promise<Models.DatabaseList> {
|
|
41
|
+
let params: { queries?: string[], search?: string, total?: boolean };
|
|
42
|
+
|
|
43
|
+
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
44
|
+
params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean };
|
|
45
|
+
} else {
|
|
46
|
+
params = {
|
|
47
|
+
queries: paramsOrFirst as string[],
|
|
48
|
+
search: rest[0] as string,
|
|
49
|
+
total: rest[1] as boolean
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const queries = params.queries;
|
|
54
|
+
const search = params.search;
|
|
55
|
+
const total = params.total;
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
const apiPath = '/documentsdb';
|
|
59
|
+
const payload: Payload = {};
|
|
60
|
+
if (typeof queries !== 'undefined') {
|
|
61
|
+
payload['queries'] = queries;
|
|
62
|
+
}
|
|
63
|
+
if (typeof search !== 'undefined') {
|
|
64
|
+
payload['search'] = search;
|
|
65
|
+
}
|
|
66
|
+
if (typeof total !== 'undefined') {
|
|
67
|
+
payload['total'] = total;
|
|
68
|
+
}
|
|
69
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
70
|
+
|
|
71
|
+
const apiHeaders: { [header: string]: string } = {
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return this.client.call(
|
|
75
|
+
'get',
|
|
76
|
+
uri,
|
|
77
|
+
apiHeaders,
|
|
78
|
+
payload
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Create a new Database.
|
|
84
|
+
*
|
|
85
|
+
*
|
|
86
|
+
* @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
87
|
+
* @param {string} params.name - Database name. Max length: 128 chars.
|
|
88
|
+
* @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.
|
|
89
|
+
* @throws {AppwriteException}
|
|
90
|
+
* @returns {Promise<Models.Database>}
|
|
91
|
+
*/
|
|
92
|
+
create(params: { databaseId: string, name: string, enabled?: boolean }): Promise<Models.Database>;
|
|
93
|
+
/**
|
|
94
|
+
* Create a new Database.
|
|
95
|
+
*
|
|
96
|
+
*
|
|
97
|
+
* @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
98
|
+
* @param {string} name - Database name. Max length: 128 chars.
|
|
99
|
+
* @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.
|
|
100
|
+
* @throws {AppwriteException}
|
|
101
|
+
* @returns {Promise<Models.Database>}
|
|
102
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
103
|
+
*/
|
|
104
|
+
create(databaseId: string, name: string, enabled?: boolean): Promise<Models.Database>;
|
|
105
|
+
create(
|
|
106
|
+
paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string,
|
|
107
|
+
...rest: [(string)?, (boolean)?]
|
|
108
|
+
): Promise<Models.Database> {
|
|
109
|
+
let params: { databaseId: string, name: string, enabled?: boolean };
|
|
110
|
+
|
|
111
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
112
|
+
params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean };
|
|
113
|
+
} else {
|
|
114
|
+
params = {
|
|
115
|
+
databaseId: paramsOrFirst as string,
|
|
116
|
+
name: rest[0] as string,
|
|
117
|
+
enabled: rest[1] as boolean
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const databaseId = params.databaseId;
|
|
122
|
+
const name = params.name;
|
|
123
|
+
const enabled = params.enabled;
|
|
124
|
+
|
|
125
|
+
if (typeof databaseId === 'undefined') {
|
|
126
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
127
|
+
}
|
|
128
|
+
if (typeof name === 'undefined') {
|
|
129
|
+
throw new AppwriteException('Missing required parameter: "name"');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const apiPath = '/documentsdb';
|
|
133
|
+
const payload: Payload = {};
|
|
134
|
+
if (typeof databaseId !== 'undefined') {
|
|
135
|
+
payload['databaseId'] = databaseId;
|
|
136
|
+
}
|
|
137
|
+
if (typeof name !== 'undefined') {
|
|
138
|
+
payload['name'] = name;
|
|
139
|
+
}
|
|
140
|
+
if (typeof enabled !== 'undefined') {
|
|
141
|
+
payload['enabled'] = enabled;
|
|
142
|
+
}
|
|
143
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
144
|
+
|
|
145
|
+
const apiHeaders: { [header: string]: string } = {
|
|
146
|
+
'content-type': 'application/json',
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return this.client.call(
|
|
150
|
+
'post',
|
|
151
|
+
uri,
|
|
152
|
+
apiHeaders,
|
|
153
|
+
payload
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
*
|
|
159
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries).
|
|
160
|
+
* @throws {AppwriteException}
|
|
161
|
+
* @returns {Promise<Models.TransactionList>}
|
|
162
|
+
*/
|
|
163
|
+
listTransactions(params?: { queries?: string[] }): Promise<Models.TransactionList>;
|
|
164
|
+
/**
|
|
165
|
+
*
|
|
166
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries).
|
|
167
|
+
* @throws {AppwriteException}
|
|
168
|
+
* @returns {Promise<Models.TransactionList>}
|
|
169
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
170
|
+
*/
|
|
171
|
+
listTransactions(queries?: string[]): Promise<Models.TransactionList>;
|
|
172
|
+
listTransactions(
|
|
173
|
+
paramsOrFirst?: { queries?: string[] } | string[]
|
|
174
|
+
): Promise<Models.TransactionList> {
|
|
175
|
+
let params: { queries?: string[] };
|
|
176
|
+
|
|
177
|
+
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
178
|
+
params = (paramsOrFirst || {}) as { queries?: string[] };
|
|
179
|
+
} else {
|
|
180
|
+
params = {
|
|
181
|
+
queries: paramsOrFirst as string[]
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const queries = params.queries;
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
const apiPath = '/documentsdb/transactions';
|
|
189
|
+
const payload: Payload = {};
|
|
190
|
+
if (typeof queries !== 'undefined') {
|
|
191
|
+
payload['queries'] = queries;
|
|
192
|
+
}
|
|
193
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
194
|
+
|
|
195
|
+
const apiHeaders: { [header: string]: string } = {
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return this.client.call(
|
|
199
|
+
'get',
|
|
200
|
+
uri,
|
|
201
|
+
apiHeaders,
|
|
202
|
+
payload
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
*
|
|
208
|
+
* @param {number} params.ttl - Seconds before the transaction expires.
|
|
209
|
+
* @throws {AppwriteException}
|
|
210
|
+
* @returns {Promise<Models.Transaction>}
|
|
211
|
+
*/
|
|
212
|
+
createTransaction(params?: { ttl?: number }): Promise<Models.Transaction>;
|
|
213
|
+
/**
|
|
214
|
+
*
|
|
215
|
+
* @param {number} ttl - Seconds before the transaction expires.
|
|
216
|
+
* @throws {AppwriteException}
|
|
217
|
+
* @returns {Promise<Models.Transaction>}
|
|
218
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
219
|
+
*/
|
|
220
|
+
createTransaction(ttl?: number): Promise<Models.Transaction>;
|
|
221
|
+
createTransaction(
|
|
222
|
+
paramsOrFirst?: { ttl?: number } | number
|
|
223
|
+
): Promise<Models.Transaction> {
|
|
224
|
+
let params: { ttl?: number };
|
|
225
|
+
|
|
226
|
+
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
227
|
+
params = (paramsOrFirst || {}) as { ttl?: number };
|
|
228
|
+
} else {
|
|
229
|
+
params = {
|
|
230
|
+
ttl: paramsOrFirst as number
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const ttl = params.ttl;
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
const apiPath = '/documentsdb/transactions';
|
|
238
|
+
const payload: Payload = {};
|
|
239
|
+
if (typeof ttl !== 'undefined') {
|
|
240
|
+
payload['ttl'] = ttl;
|
|
241
|
+
}
|
|
242
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
243
|
+
|
|
244
|
+
const apiHeaders: { [header: string]: string } = {
|
|
245
|
+
'content-type': 'application/json',
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return this.client.call(
|
|
249
|
+
'post',
|
|
250
|
+
uri,
|
|
251
|
+
apiHeaders,
|
|
252
|
+
payload
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
*
|
|
258
|
+
* @param {string} params.transactionId - Transaction ID.
|
|
259
|
+
* @throws {AppwriteException}
|
|
260
|
+
* @returns {Promise<Models.Transaction>}
|
|
261
|
+
*/
|
|
262
|
+
getTransaction(params: { transactionId: string }): Promise<Models.Transaction>;
|
|
263
|
+
/**
|
|
264
|
+
*
|
|
265
|
+
* @param {string} transactionId - Transaction ID.
|
|
266
|
+
* @throws {AppwriteException}
|
|
267
|
+
* @returns {Promise<Models.Transaction>}
|
|
268
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
269
|
+
*/
|
|
270
|
+
getTransaction(transactionId: string): Promise<Models.Transaction>;
|
|
271
|
+
getTransaction(
|
|
272
|
+
paramsOrFirst: { transactionId: string } | string
|
|
273
|
+
): Promise<Models.Transaction> {
|
|
274
|
+
let params: { transactionId: string };
|
|
275
|
+
|
|
276
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
277
|
+
params = (paramsOrFirst || {}) as { transactionId: string };
|
|
278
|
+
} else {
|
|
279
|
+
params = {
|
|
280
|
+
transactionId: paramsOrFirst as string
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const transactionId = params.transactionId;
|
|
285
|
+
|
|
286
|
+
if (typeof transactionId === 'undefined') {
|
|
287
|
+
throw new AppwriteException('Missing required parameter: "transactionId"');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const apiPath = '/documentsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId);
|
|
291
|
+
const payload: Payload = {};
|
|
292
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
293
|
+
|
|
294
|
+
const apiHeaders: { [header: string]: string } = {
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return this.client.call(
|
|
298
|
+
'get',
|
|
299
|
+
uri,
|
|
300
|
+
apiHeaders,
|
|
301
|
+
payload
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
*
|
|
307
|
+
* @param {string} params.transactionId - Transaction ID.
|
|
308
|
+
* @param {boolean} params.commit - Commit transaction?
|
|
309
|
+
* @param {boolean} params.rollback - Rollback transaction?
|
|
310
|
+
* @throws {AppwriteException}
|
|
311
|
+
* @returns {Promise<Models.Transaction>}
|
|
312
|
+
*/
|
|
313
|
+
updateTransaction(params: { transactionId: string, commit?: boolean, rollback?: boolean }): Promise<Models.Transaction>;
|
|
314
|
+
/**
|
|
315
|
+
*
|
|
316
|
+
* @param {string} transactionId - Transaction ID.
|
|
317
|
+
* @param {boolean} commit - Commit transaction?
|
|
318
|
+
* @param {boolean} rollback - Rollback transaction?
|
|
319
|
+
* @throws {AppwriteException}
|
|
320
|
+
* @returns {Promise<Models.Transaction>}
|
|
321
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
322
|
+
*/
|
|
323
|
+
updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise<Models.Transaction>;
|
|
324
|
+
updateTransaction(
|
|
325
|
+
paramsOrFirst: { transactionId: string, commit?: boolean, rollback?: boolean } | string,
|
|
326
|
+
...rest: [(boolean)?, (boolean)?]
|
|
327
|
+
): Promise<Models.Transaction> {
|
|
328
|
+
let params: { transactionId: string, commit?: boolean, rollback?: boolean };
|
|
329
|
+
|
|
330
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
331
|
+
params = (paramsOrFirst || {}) as { transactionId: string, commit?: boolean, rollback?: boolean };
|
|
332
|
+
} else {
|
|
333
|
+
params = {
|
|
334
|
+
transactionId: paramsOrFirst as string,
|
|
335
|
+
commit: rest[0] as boolean,
|
|
336
|
+
rollback: rest[1] as boolean
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const transactionId = params.transactionId;
|
|
341
|
+
const commit = params.commit;
|
|
342
|
+
const rollback = params.rollback;
|
|
343
|
+
|
|
344
|
+
if (typeof transactionId === 'undefined') {
|
|
345
|
+
throw new AppwriteException('Missing required parameter: "transactionId"');
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const apiPath = '/documentsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId);
|
|
349
|
+
const payload: Payload = {};
|
|
350
|
+
if (typeof commit !== 'undefined') {
|
|
351
|
+
payload['commit'] = commit;
|
|
352
|
+
}
|
|
353
|
+
if (typeof rollback !== 'undefined') {
|
|
354
|
+
payload['rollback'] = rollback;
|
|
355
|
+
}
|
|
356
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
357
|
+
|
|
358
|
+
const apiHeaders: { [header: string]: string } = {
|
|
359
|
+
'content-type': 'application/json',
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return this.client.call(
|
|
363
|
+
'patch',
|
|
364
|
+
uri,
|
|
365
|
+
apiHeaders,
|
|
366
|
+
payload
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
*
|
|
372
|
+
* @param {string} params.transactionId - Transaction ID.
|
|
373
|
+
* @throws {AppwriteException}
|
|
374
|
+
* @returns {Promise<{}>}
|
|
375
|
+
*/
|
|
376
|
+
deleteTransaction(params: { transactionId: string }): Promise<{}>;
|
|
377
|
+
/**
|
|
378
|
+
*
|
|
379
|
+
* @param {string} transactionId - Transaction ID.
|
|
380
|
+
* @throws {AppwriteException}
|
|
381
|
+
* @returns {Promise<{}>}
|
|
382
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
383
|
+
*/
|
|
384
|
+
deleteTransaction(transactionId: string): Promise<{}>;
|
|
385
|
+
deleteTransaction(
|
|
386
|
+
paramsOrFirst: { transactionId: string } | string
|
|
387
|
+
): Promise<{}> {
|
|
388
|
+
let params: { transactionId: string };
|
|
389
|
+
|
|
390
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
391
|
+
params = (paramsOrFirst || {}) as { transactionId: string };
|
|
392
|
+
} else {
|
|
393
|
+
params = {
|
|
394
|
+
transactionId: paramsOrFirst as string
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const transactionId = params.transactionId;
|
|
399
|
+
|
|
400
|
+
if (typeof transactionId === 'undefined') {
|
|
401
|
+
throw new AppwriteException('Missing required parameter: "transactionId"');
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const apiPath = '/documentsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId);
|
|
405
|
+
const payload: Payload = {};
|
|
406
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
407
|
+
|
|
408
|
+
const apiHeaders: { [header: string]: string } = {
|
|
409
|
+
'content-type': 'application/json',
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return this.client.call(
|
|
413
|
+
'delete',
|
|
414
|
+
uri,
|
|
415
|
+
apiHeaders,
|
|
416
|
+
payload
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* List usage metrics and statistics for all databases in the project. You can view the total number of databases, collections, documents, and storage usage. The response includes both current totals and historical data over time. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, range defaults to 30 days.
|
|
422
|
+
*
|
|
423
|
+
* @param {UsageRange} params.range - Date range.
|
|
424
|
+
* @throws {AppwriteException}
|
|
425
|
+
* @returns {Promise<Models.UsageDatabases>}
|
|
426
|
+
*/
|
|
427
|
+
listUsage(params?: { range?: UsageRange }): Promise<Models.UsageDatabases>;
|
|
428
|
+
/**
|
|
429
|
+
* List usage metrics and statistics for all databases in the project. You can view the total number of databases, collections, documents, and storage usage. The response includes both current totals and historical data over time. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, range defaults to 30 days.
|
|
430
|
+
*
|
|
431
|
+
* @param {UsageRange} range - Date range.
|
|
432
|
+
* @throws {AppwriteException}
|
|
433
|
+
* @returns {Promise<Models.UsageDatabases>}
|
|
434
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
435
|
+
*/
|
|
436
|
+
listUsage(range?: UsageRange): Promise<Models.UsageDatabases>;
|
|
437
|
+
listUsage(
|
|
438
|
+
paramsOrFirst?: { range?: UsageRange } | UsageRange
|
|
439
|
+
): Promise<Models.UsageDatabases> {
|
|
440
|
+
let params: { range?: UsageRange };
|
|
441
|
+
|
|
442
|
+
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('range' in paramsOrFirst))) {
|
|
443
|
+
params = (paramsOrFirst || {}) as { range?: UsageRange };
|
|
444
|
+
} else {
|
|
445
|
+
params = {
|
|
446
|
+
range: paramsOrFirst as UsageRange
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const range = params.range;
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
const apiPath = '/documentsdb/usage';
|
|
454
|
+
const payload: Payload = {};
|
|
455
|
+
if (typeof range !== 'undefined') {
|
|
456
|
+
payload['range'] = range;
|
|
457
|
+
}
|
|
458
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
459
|
+
|
|
460
|
+
const apiHeaders: { [header: string]: string } = {
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
return this.client.call(
|
|
464
|
+
'get',
|
|
465
|
+
uri,
|
|
466
|
+
apiHeaders,
|
|
467
|
+
payload
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata.
|
|
473
|
+
*
|
|
474
|
+
* @param {string} params.databaseId - Database ID.
|
|
475
|
+
* @throws {AppwriteException}
|
|
476
|
+
* @returns {Promise<Models.Database>}
|
|
477
|
+
*/
|
|
478
|
+
get(params: { databaseId: string }): Promise<Models.Database>;
|
|
479
|
+
/**
|
|
480
|
+
* Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata.
|
|
481
|
+
*
|
|
482
|
+
* @param {string} databaseId - Database ID.
|
|
483
|
+
* @throws {AppwriteException}
|
|
484
|
+
* @returns {Promise<Models.Database>}
|
|
485
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
486
|
+
*/
|
|
487
|
+
get(databaseId: string): Promise<Models.Database>;
|
|
488
|
+
get(
|
|
489
|
+
paramsOrFirst: { databaseId: string } | string
|
|
490
|
+
): Promise<Models.Database> {
|
|
491
|
+
let params: { databaseId: string };
|
|
492
|
+
|
|
493
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
494
|
+
params = (paramsOrFirst || {}) as { databaseId: string };
|
|
495
|
+
} else {
|
|
496
|
+
params = {
|
|
497
|
+
databaseId: paramsOrFirst as string
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
const databaseId = params.databaseId;
|
|
502
|
+
|
|
503
|
+
if (typeof databaseId === 'undefined') {
|
|
504
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
const apiPath = '/documentsdb/{databaseId}'.replace('{databaseId}', databaseId);
|
|
508
|
+
const payload: Payload = {};
|
|
509
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
510
|
+
|
|
511
|
+
const apiHeaders: { [header: string]: string } = {
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
return this.client.call(
|
|
515
|
+
'get',
|
|
516
|
+
uri,
|
|
517
|
+
apiHeaders,
|
|
518
|
+
payload
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Update a database by its unique ID.
|
|
524
|
+
*
|
|
525
|
+
* @param {string} params.databaseId - Database ID.
|
|
526
|
+
* @param {string} params.name - Database name. Max length: 128 chars.
|
|
527
|
+
* @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.
|
|
528
|
+
* @throws {AppwriteException}
|
|
529
|
+
* @returns {Promise<Models.Database>}
|
|
530
|
+
*/
|
|
531
|
+
update(params: { databaseId: string, name: string, enabled?: boolean }): Promise<Models.Database>;
|
|
532
|
+
/**
|
|
533
|
+
* Update a database by its unique ID.
|
|
534
|
+
*
|
|
535
|
+
* @param {string} databaseId - Database ID.
|
|
536
|
+
* @param {string} name - Database name. Max length: 128 chars.
|
|
537
|
+
* @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.
|
|
538
|
+
* @throws {AppwriteException}
|
|
539
|
+
* @returns {Promise<Models.Database>}
|
|
540
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
541
|
+
*/
|
|
542
|
+
update(databaseId: string, name: string, enabled?: boolean): Promise<Models.Database>;
|
|
543
|
+
update(
|
|
544
|
+
paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string,
|
|
545
|
+
...rest: [(string)?, (boolean)?]
|
|
546
|
+
): Promise<Models.Database> {
|
|
547
|
+
let params: { databaseId: string, name: string, enabled?: boolean };
|
|
548
|
+
|
|
549
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
550
|
+
params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean };
|
|
551
|
+
} else {
|
|
552
|
+
params = {
|
|
553
|
+
databaseId: paramsOrFirst as string,
|
|
554
|
+
name: rest[0] as string,
|
|
555
|
+
enabled: rest[1] as boolean
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const databaseId = params.databaseId;
|
|
560
|
+
const name = params.name;
|
|
561
|
+
const enabled = params.enabled;
|
|
562
|
+
|
|
563
|
+
if (typeof databaseId === 'undefined') {
|
|
564
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
565
|
+
}
|
|
566
|
+
if (typeof name === 'undefined') {
|
|
567
|
+
throw new AppwriteException('Missing required parameter: "name"');
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const apiPath = '/documentsdb/{databaseId}'.replace('{databaseId}', databaseId);
|
|
571
|
+
const payload: Payload = {};
|
|
572
|
+
if (typeof name !== 'undefined') {
|
|
573
|
+
payload['name'] = name;
|
|
574
|
+
}
|
|
575
|
+
if (typeof enabled !== 'undefined') {
|
|
576
|
+
payload['enabled'] = enabled;
|
|
577
|
+
}
|
|
578
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
579
|
+
|
|
580
|
+
const apiHeaders: { [header: string]: string } = {
|
|
581
|
+
'content-type': 'application/json',
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
return this.client.call(
|
|
585
|
+
'put',
|
|
586
|
+
uri,
|
|
587
|
+
apiHeaders,
|
|
588
|
+
payload
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database.
|
|
594
|
+
*
|
|
595
|
+
* @param {string} params.databaseId - Database ID.
|
|
596
|
+
* @throws {AppwriteException}
|
|
597
|
+
* @returns {Promise<{}>}
|
|
598
|
+
*/
|
|
599
|
+
delete(params: { databaseId: string }): Promise<{}>;
|
|
600
|
+
/**
|
|
601
|
+
* Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database.
|
|
602
|
+
*
|
|
603
|
+
* @param {string} databaseId - Database ID.
|
|
604
|
+
* @throws {AppwriteException}
|
|
605
|
+
* @returns {Promise<{}>}
|
|
606
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
607
|
+
*/
|
|
608
|
+
delete(databaseId: string): Promise<{}>;
|
|
609
|
+
delete(
|
|
610
|
+
paramsOrFirst: { databaseId: string } | string
|
|
611
|
+
): Promise<{}> {
|
|
612
|
+
let params: { databaseId: string };
|
|
613
|
+
|
|
614
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
615
|
+
params = (paramsOrFirst || {}) as { databaseId: string };
|
|
616
|
+
} else {
|
|
617
|
+
params = {
|
|
618
|
+
databaseId: paramsOrFirst as string
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
const databaseId = params.databaseId;
|
|
623
|
+
|
|
624
|
+
if (typeof databaseId === 'undefined') {
|
|
625
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
const apiPath = '/documentsdb/{databaseId}'.replace('{databaseId}', databaseId);
|
|
629
|
+
const payload: Payload = {};
|
|
630
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
631
|
+
|
|
632
|
+
const apiHeaders: { [header: string]: string } = {
|
|
633
|
+
'content-type': 'application/json',
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
return this.client.call(
|
|
637
|
+
'delete',
|
|
638
|
+
uri,
|
|
639
|
+
apiHeaders,
|
|
640
|
+
payload
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results.
|
|
646
|
+
*
|
|
647
|
+
* @param {string} params.databaseId - Database ID.
|
|
648
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity
|
|
649
|
+
* @param {string} params.search - Search term to filter your list results. Max length: 256 chars.
|
|
650
|
+
* @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
|
|
651
|
+
* @throws {AppwriteException}
|
|
652
|
+
* @returns {Promise<Models.CollectionList>}
|
|
653
|
+
*/
|
|
654
|
+
listCollections(params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise<Models.CollectionList>;
|
|
655
|
+
/**
|
|
656
|
+
* Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results.
|
|
657
|
+
*
|
|
658
|
+
* @param {string} databaseId - Database ID.
|
|
659
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity
|
|
660
|
+
* @param {string} search - Search term to filter your list results. Max length: 256 chars.
|
|
661
|
+
* @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
|
|
662
|
+
* @throws {AppwriteException}
|
|
663
|
+
* @returns {Promise<Models.CollectionList>}
|
|
664
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
665
|
+
*/
|
|
666
|
+
listCollections(databaseId: string, queries?: string[], search?: string, total?: boolean): Promise<Models.CollectionList>;
|
|
667
|
+
listCollections(
|
|
668
|
+
paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string,
|
|
669
|
+
...rest: [(string[])?, (string)?, (boolean)?]
|
|
670
|
+
): Promise<Models.CollectionList> {
|
|
671
|
+
let params: { databaseId: string, queries?: string[], search?: string, total?: boolean };
|
|
672
|
+
|
|
673
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
674
|
+
params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean };
|
|
675
|
+
} else {
|
|
676
|
+
params = {
|
|
677
|
+
databaseId: paramsOrFirst as string,
|
|
678
|
+
queries: rest[0] as string[],
|
|
679
|
+
search: rest[1] as string,
|
|
680
|
+
total: rest[2] as boolean
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
const databaseId = params.databaseId;
|
|
685
|
+
const queries = params.queries;
|
|
686
|
+
const search = params.search;
|
|
687
|
+
const total = params.total;
|
|
688
|
+
|
|
689
|
+
if (typeof databaseId === 'undefined') {
|
|
690
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
const apiPath = '/documentsdb/{databaseId}/collections'.replace('{databaseId}', databaseId);
|
|
694
|
+
const payload: Payload = {};
|
|
695
|
+
if (typeof queries !== 'undefined') {
|
|
696
|
+
payload['queries'] = queries;
|
|
697
|
+
}
|
|
698
|
+
if (typeof search !== 'undefined') {
|
|
699
|
+
payload['search'] = search;
|
|
700
|
+
}
|
|
701
|
+
if (typeof total !== 'undefined') {
|
|
702
|
+
payload['total'] = total;
|
|
703
|
+
}
|
|
704
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
705
|
+
|
|
706
|
+
const apiHeaders: { [header: string]: string } = {
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
return this.client.call(
|
|
710
|
+
'get',
|
|
711
|
+
uri,
|
|
712
|
+
apiHeaders,
|
|
713
|
+
payload
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console.
|
|
719
|
+
*
|
|
720
|
+
* @param {string} params.databaseId - Database ID.
|
|
721
|
+
* @param {string} params.collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
722
|
+
* @param {string} params.name - Collection name. Max length: 128 chars.
|
|
723
|
+
* @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
724
|
+
* @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
725
|
+
* @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.
|
|
726
|
+
* @param {object[]} params.attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options.
|
|
727
|
+
* @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional).
|
|
728
|
+
* @throws {AppwriteException}
|
|
729
|
+
* @returns {Promise<Models.Collection>}
|
|
730
|
+
*/
|
|
731
|
+
createCollection(params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }): Promise<Models.Collection>;
|
|
732
|
+
/**
|
|
733
|
+
* Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console.
|
|
734
|
+
*
|
|
735
|
+
* @param {string} databaseId - Database ID.
|
|
736
|
+
* @param {string} collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
737
|
+
* @param {string} name - Collection name. Max length: 128 chars.
|
|
738
|
+
* @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
739
|
+
* @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
740
|
+
* @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.
|
|
741
|
+
* @param {object[]} attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options.
|
|
742
|
+
* @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional).
|
|
743
|
+
* @throws {AppwriteException}
|
|
744
|
+
* @returns {Promise<Models.Collection>}
|
|
745
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
746
|
+
*/
|
|
747
|
+
createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[]): Promise<Models.Collection>;
|
|
748
|
+
createCollection(
|
|
749
|
+
paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] } | string,
|
|
750
|
+
...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (object[])?, (object[])?]
|
|
751
|
+
): Promise<Models.Collection> {
|
|
752
|
+
let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] };
|
|
753
|
+
|
|
754
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
755
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] };
|
|
756
|
+
} else {
|
|
757
|
+
params = {
|
|
758
|
+
databaseId: paramsOrFirst as string,
|
|
759
|
+
collectionId: rest[0] as string,
|
|
760
|
+
name: rest[1] as string,
|
|
761
|
+
permissions: rest[2] as string[],
|
|
762
|
+
documentSecurity: rest[3] as boolean,
|
|
763
|
+
enabled: rest[4] as boolean,
|
|
764
|
+
attributes: rest[5] as object[],
|
|
765
|
+
indexes: rest[6] as object[]
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
const databaseId = params.databaseId;
|
|
770
|
+
const collectionId = params.collectionId;
|
|
771
|
+
const name = params.name;
|
|
772
|
+
const permissions = params.permissions;
|
|
773
|
+
const documentSecurity = params.documentSecurity;
|
|
774
|
+
const enabled = params.enabled;
|
|
775
|
+
const attributes = params.attributes;
|
|
776
|
+
const indexes = params.indexes;
|
|
777
|
+
|
|
778
|
+
if (typeof databaseId === 'undefined') {
|
|
779
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
780
|
+
}
|
|
781
|
+
if (typeof collectionId === 'undefined') {
|
|
782
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
783
|
+
}
|
|
784
|
+
if (typeof name === 'undefined') {
|
|
785
|
+
throw new AppwriteException('Missing required parameter: "name"');
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
const apiPath = '/documentsdb/{databaseId}/collections'.replace('{databaseId}', databaseId);
|
|
789
|
+
const payload: Payload = {};
|
|
790
|
+
if (typeof collectionId !== 'undefined') {
|
|
791
|
+
payload['collectionId'] = collectionId;
|
|
792
|
+
}
|
|
793
|
+
if (typeof name !== 'undefined') {
|
|
794
|
+
payload['name'] = name;
|
|
795
|
+
}
|
|
796
|
+
if (typeof permissions !== 'undefined') {
|
|
797
|
+
payload['permissions'] = permissions;
|
|
798
|
+
}
|
|
799
|
+
if (typeof documentSecurity !== 'undefined') {
|
|
800
|
+
payload['documentSecurity'] = documentSecurity;
|
|
801
|
+
}
|
|
802
|
+
if (typeof enabled !== 'undefined') {
|
|
803
|
+
payload['enabled'] = enabled;
|
|
804
|
+
}
|
|
805
|
+
if (typeof attributes !== 'undefined') {
|
|
806
|
+
payload['attributes'] = attributes;
|
|
807
|
+
}
|
|
808
|
+
if (typeof indexes !== 'undefined') {
|
|
809
|
+
payload['indexes'] = indexes;
|
|
810
|
+
}
|
|
811
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
812
|
+
|
|
813
|
+
const apiHeaders: { [header: string]: string } = {
|
|
814
|
+
'content-type': 'application/json',
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
return this.client.call(
|
|
818
|
+
'post',
|
|
819
|
+
uri,
|
|
820
|
+
apiHeaders,
|
|
821
|
+
payload
|
|
822
|
+
);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.
|
|
827
|
+
*
|
|
828
|
+
* @param {string} params.databaseId - Database ID.
|
|
829
|
+
* @param {string} params.collectionId - Collection ID.
|
|
830
|
+
* @throws {AppwriteException}
|
|
831
|
+
* @returns {Promise<Models.Collection>}
|
|
832
|
+
*/
|
|
833
|
+
getCollection(params: { databaseId: string, collectionId: string }): Promise<Models.Collection>;
|
|
834
|
+
/**
|
|
835
|
+
* Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.
|
|
836
|
+
*
|
|
837
|
+
* @param {string} databaseId - Database ID.
|
|
838
|
+
* @param {string} collectionId - Collection ID.
|
|
839
|
+
* @throws {AppwriteException}
|
|
840
|
+
* @returns {Promise<Models.Collection>}
|
|
841
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
842
|
+
*/
|
|
843
|
+
getCollection(databaseId: string, collectionId: string): Promise<Models.Collection>;
|
|
844
|
+
getCollection(
|
|
845
|
+
paramsOrFirst: { databaseId: string, collectionId: string } | string,
|
|
846
|
+
...rest: [(string)?]
|
|
847
|
+
): Promise<Models.Collection> {
|
|
848
|
+
let params: { databaseId: string, collectionId: string };
|
|
849
|
+
|
|
850
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
851
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string };
|
|
852
|
+
} else {
|
|
853
|
+
params = {
|
|
854
|
+
databaseId: paramsOrFirst as string,
|
|
855
|
+
collectionId: rest[0] as string
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
const databaseId = params.databaseId;
|
|
860
|
+
const collectionId = params.collectionId;
|
|
861
|
+
|
|
862
|
+
if (typeof databaseId === 'undefined') {
|
|
863
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
864
|
+
}
|
|
865
|
+
if (typeof collectionId === 'undefined') {
|
|
866
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
870
|
+
const payload: Payload = {};
|
|
871
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
872
|
+
|
|
873
|
+
const apiHeaders: { [header: string]: string } = {
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
return this.client.call(
|
|
877
|
+
'get',
|
|
878
|
+
uri,
|
|
879
|
+
apiHeaders,
|
|
880
|
+
payload
|
|
881
|
+
);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Update a collection by its unique ID.
|
|
886
|
+
*
|
|
887
|
+
* @param {string} params.databaseId - Database ID.
|
|
888
|
+
* @param {string} params.collectionId - Collection ID.
|
|
889
|
+
* @param {string} params.name - Collection name. Max length: 128 chars.
|
|
890
|
+
* @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
891
|
+
* @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
892
|
+
* @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.
|
|
893
|
+
* @throws {AppwriteException}
|
|
894
|
+
* @returns {Promise<Models.Collection>}
|
|
895
|
+
*/
|
|
896
|
+
updateCollection(params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }): Promise<Models.Collection>;
|
|
897
|
+
/**
|
|
898
|
+
* Update a collection by its unique ID.
|
|
899
|
+
*
|
|
900
|
+
* @param {string} databaseId - Database ID.
|
|
901
|
+
* @param {string} collectionId - Collection ID.
|
|
902
|
+
* @param {string} name - Collection name. Max length: 128 chars.
|
|
903
|
+
* @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
904
|
+
* @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
905
|
+
* @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.
|
|
906
|
+
* @throws {AppwriteException}
|
|
907
|
+
* @returns {Promise<Models.Collection>}
|
|
908
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
909
|
+
*/
|
|
910
|
+
updateCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise<Models.Collection>;
|
|
911
|
+
updateCollection(
|
|
912
|
+
paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean } | string,
|
|
913
|
+
...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?]
|
|
914
|
+
): Promise<Models.Collection> {
|
|
915
|
+
let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean };
|
|
916
|
+
|
|
917
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
918
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean };
|
|
919
|
+
} else {
|
|
920
|
+
params = {
|
|
921
|
+
databaseId: paramsOrFirst as string,
|
|
922
|
+
collectionId: rest[0] as string,
|
|
923
|
+
name: rest[1] as string,
|
|
924
|
+
permissions: rest[2] as string[],
|
|
925
|
+
documentSecurity: rest[3] as boolean,
|
|
926
|
+
enabled: rest[4] as boolean
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
const databaseId = params.databaseId;
|
|
931
|
+
const collectionId = params.collectionId;
|
|
932
|
+
const name = params.name;
|
|
933
|
+
const permissions = params.permissions;
|
|
934
|
+
const documentSecurity = params.documentSecurity;
|
|
935
|
+
const enabled = params.enabled;
|
|
936
|
+
|
|
937
|
+
if (typeof databaseId === 'undefined') {
|
|
938
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
939
|
+
}
|
|
940
|
+
if (typeof collectionId === 'undefined') {
|
|
941
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
942
|
+
}
|
|
943
|
+
if (typeof name === 'undefined') {
|
|
944
|
+
throw new AppwriteException('Missing required parameter: "name"');
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
948
|
+
const payload: Payload = {};
|
|
949
|
+
if (typeof name !== 'undefined') {
|
|
950
|
+
payload['name'] = name;
|
|
951
|
+
}
|
|
952
|
+
if (typeof permissions !== 'undefined') {
|
|
953
|
+
payload['permissions'] = permissions;
|
|
954
|
+
}
|
|
955
|
+
if (typeof documentSecurity !== 'undefined') {
|
|
956
|
+
payload['documentSecurity'] = documentSecurity;
|
|
957
|
+
}
|
|
958
|
+
if (typeof enabled !== 'undefined') {
|
|
959
|
+
payload['enabled'] = enabled;
|
|
960
|
+
}
|
|
961
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
962
|
+
|
|
963
|
+
const apiHeaders: { [header: string]: string } = {
|
|
964
|
+
'content-type': 'application/json',
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
return this.client.call(
|
|
968
|
+
'put',
|
|
969
|
+
uri,
|
|
970
|
+
apiHeaders,
|
|
971
|
+
payload
|
|
972
|
+
);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.
|
|
977
|
+
*
|
|
978
|
+
* @param {string} params.databaseId - Database ID.
|
|
979
|
+
* @param {string} params.collectionId - Collection ID.
|
|
980
|
+
* @throws {AppwriteException}
|
|
981
|
+
* @returns {Promise<{}>}
|
|
982
|
+
*/
|
|
983
|
+
deleteCollection(params: { databaseId: string, collectionId: string }): Promise<{}>;
|
|
984
|
+
/**
|
|
985
|
+
* Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.
|
|
986
|
+
*
|
|
987
|
+
* @param {string} databaseId - Database ID.
|
|
988
|
+
* @param {string} collectionId - Collection ID.
|
|
989
|
+
* @throws {AppwriteException}
|
|
990
|
+
* @returns {Promise<{}>}
|
|
991
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
992
|
+
*/
|
|
993
|
+
deleteCollection(databaseId: string, collectionId: string): Promise<{}>;
|
|
994
|
+
deleteCollection(
|
|
995
|
+
paramsOrFirst: { databaseId: string, collectionId: string } | string,
|
|
996
|
+
...rest: [(string)?]
|
|
997
|
+
): Promise<{}> {
|
|
998
|
+
let params: { databaseId: string, collectionId: string };
|
|
999
|
+
|
|
1000
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1001
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string };
|
|
1002
|
+
} else {
|
|
1003
|
+
params = {
|
|
1004
|
+
databaseId: paramsOrFirst as string,
|
|
1005
|
+
collectionId: rest[0] as string
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
const databaseId = params.databaseId;
|
|
1010
|
+
const collectionId = params.collectionId;
|
|
1011
|
+
|
|
1012
|
+
if (typeof databaseId === 'undefined') {
|
|
1013
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1014
|
+
}
|
|
1015
|
+
if (typeof collectionId === 'undefined') {
|
|
1016
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1020
|
+
const payload: Payload = {};
|
|
1021
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1022
|
+
|
|
1023
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1024
|
+
'content-type': 'application/json',
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
return this.client.call(
|
|
1028
|
+
'delete',
|
|
1029
|
+
uri,
|
|
1030
|
+
apiHeaders,
|
|
1031
|
+
payload
|
|
1032
|
+
);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Get a list of all the user's documents in a given collection. You can use the query params to filter your results.
|
|
1037
|
+
*
|
|
1038
|
+
* @param {string} params.databaseId - Database ID.
|
|
1039
|
+
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
1040
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
|
|
1041
|
+
* @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction.
|
|
1042
|
+
* @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
|
|
1043
|
+
* @param {number} params.ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours).
|
|
1044
|
+
* @throws {AppwriteException}
|
|
1045
|
+
* @returns {Promise<Models.DocumentList<Document>>}
|
|
1046
|
+
*/
|
|
1047
|
+
listDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise<Models.DocumentList<Document>>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Get a list of all the user's documents in a given collection. You can use the query params to filter your results.
|
|
1050
|
+
*
|
|
1051
|
+
* @param {string} databaseId - Database ID.
|
|
1052
|
+
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
1053
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
|
|
1054
|
+
* @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction.
|
|
1055
|
+
* @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
|
|
1056
|
+
* @param {number} ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours).
|
|
1057
|
+
* @throws {AppwriteException}
|
|
1058
|
+
* @returns {Promise<Models.DocumentList<Document>>}
|
|
1059
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1060
|
+
*/
|
|
1061
|
+
listDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise<Models.DocumentList<Document>>;
|
|
1062
|
+
listDocuments<Document extends Models.Document = Models.DefaultDocument>(
|
|
1063
|
+
paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string,
|
|
1064
|
+
...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?]
|
|
1065
|
+
): Promise<Models.DocumentList<Document>> {
|
|
1066
|
+
let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number };
|
|
1067
|
+
|
|
1068
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1069
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number };
|
|
1070
|
+
} else {
|
|
1071
|
+
params = {
|
|
1072
|
+
databaseId: paramsOrFirst as string,
|
|
1073
|
+
collectionId: rest[0] as string,
|
|
1074
|
+
queries: rest[1] as string[],
|
|
1075
|
+
transactionId: rest[2] as string,
|
|
1076
|
+
total: rest[3] as boolean,
|
|
1077
|
+
ttl: rest[4] as number
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
const databaseId = params.databaseId;
|
|
1082
|
+
const collectionId = params.collectionId;
|
|
1083
|
+
const queries = params.queries;
|
|
1084
|
+
const transactionId = params.transactionId;
|
|
1085
|
+
const total = params.total;
|
|
1086
|
+
const ttl = params.ttl;
|
|
1087
|
+
|
|
1088
|
+
if (typeof databaseId === 'undefined') {
|
|
1089
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1090
|
+
}
|
|
1091
|
+
if (typeof collectionId === 'undefined') {
|
|
1092
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1096
|
+
const payload: Payload = {};
|
|
1097
|
+
if (typeof queries !== 'undefined') {
|
|
1098
|
+
payload['queries'] = queries;
|
|
1099
|
+
}
|
|
1100
|
+
if (typeof transactionId !== 'undefined') {
|
|
1101
|
+
payload['transactionId'] = transactionId;
|
|
1102
|
+
}
|
|
1103
|
+
if (typeof total !== 'undefined') {
|
|
1104
|
+
payload['total'] = total;
|
|
1105
|
+
}
|
|
1106
|
+
if (typeof ttl !== 'undefined') {
|
|
1107
|
+
payload['ttl'] = ttl;
|
|
1108
|
+
}
|
|
1109
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1110
|
+
|
|
1111
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
return this.client.call(
|
|
1115
|
+
'get',
|
|
1116
|
+
uri,
|
|
1117
|
+
apiHeaders,
|
|
1118
|
+
payload
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
/**
|
|
1123
|
+
* Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console.
|
|
1124
|
+
*
|
|
1125
|
+
* @param {string} params.databaseId - Database ID.
|
|
1126
|
+
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents.
|
|
1127
|
+
* @param {string} params.documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
1128
|
+
* @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} params.data - Document data as JSON object.
|
|
1129
|
+
* @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
1130
|
+
* @throws {AppwriteException}
|
|
1131
|
+
* @returns {Promise<Document>}
|
|
1132
|
+
*/
|
|
1133
|
+
createDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[] }): Promise<Document>;
|
|
1134
|
+
/**
|
|
1135
|
+
* Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console.
|
|
1136
|
+
*
|
|
1137
|
+
* @param {string} databaseId - Database ID.
|
|
1138
|
+
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents.
|
|
1139
|
+
* @param {string} documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
1140
|
+
* @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} data - Document data as JSON object.
|
|
1141
|
+
* @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
1142
|
+
* @throws {AppwriteException}
|
|
1143
|
+
* @returns {Promise<Document>}
|
|
1144
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1145
|
+
*/
|
|
1146
|
+
createDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[]): Promise<Document>;
|
|
1147
|
+
createDocument<Document extends Models.Document = Models.DefaultDocument>(
|
|
1148
|
+
paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[] } | string,
|
|
1149
|
+
...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>)?, (string[])?]
|
|
1150
|
+
): Promise<Document> {
|
|
1151
|
+
let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[] };
|
|
1152
|
+
|
|
1153
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1154
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[] };
|
|
1155
|
+
} else {
|
|
1156
|
+
params = {
|
|
1157
|
+
databaseId: paramsOrFirst as string,
|
|
1158
|
+
collectionId: rest[0] as string,
|
|
1159
|
+
documentId: rest[1] as string,
|
|
1160
|
+
data: rest[2] as Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>,
|
|
1161
|
+
permissions: rest[3] as string[]
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
const databaseId = params.databaseId;
|
|
1166
|
+
const collectionId = params.collectionId;
|
|
1167
|
+
const documentId = params.documentId;
|
|
1168
|
+
const data = params.data;
|
|
1169
|
+
const permissions = params.permissions;
|
|
1170
|
+
|
|
1171
|
+
if (typeof databaseId === 'undefined') {
|
|
1172
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1173
|
+
}
|
|
1174
|
+
if (typeof collectionId === 'undefined') {
|
|
1175
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1176
|
+
}
|
|
1177
|
+
if (typeof documentId === 'undefined') {
|
|
1178
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1179
|
+
}
|
|
1180
|
+
if (typeof data === 'undefined') {
|
|
1181
|
+
throw new AppwriteException('Missing required parameter: "data"');
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1185
|
+
const payload: Payload = {};
|
|
1186
|
+
if (typeof documentId !== 'undefined') {
|
|
1187
|
+
payload['documentId'] = documentId;
|
|
1188
|
+
}
|
|
1189
|
+
if (typeof data !== 'undefined') {
|
|
1190
|
+
payload['data'] = data;
|
|
1191
|
+
}
|
|
1192
|
+
if (typeof permissions !== 'undefined') {
|
|
1193
|
+
payload['permissions'] = permissions;
|
|
1194
|
+
}
|
|
1195
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1196
|
+
|
|
1197
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1198
|
+
'content-type': 'application/json',
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
return this.client.call(
|
|
1202
|
+
'post',
|
|
1203
|
+
uri,
|
|
1204
|
+
apiHeaders,
|
|
1205
|
+
payload
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console.
|
|
1211
|
+
*
|
|
1212
|
+
* @param {string} params.databaseId - Database ID.
|
|
1213
|
+
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents.
|
|
1214
|
+
* @param {object[]} params.documents - Array of documents data as JSON objects.
|
|
1215
|
+
* @throws {AppwriteException}
|
|
1216
|
+
* @returns {Promise<Models.DocumentList<Document>>}
|
|
1217
|
+
*/
|
|
1218
|
+
createDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documents: object[] }): Promise<Models.DocumentList<Document>>;
|
|
1219
|
+
/**
|
|
1220
|
+
* Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console.
|
|
1221
|
+
*
|
|
1222
|
+
* @param {string} databaseId - Database ID.
|
|
1223
|
+
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents.
|
|
1224
|
+
* @param {object[]} documents - Array of documents data as JSON objects.
|
|
1225
|
+
* @throws {AppwriteException}
|
|
1226
|
+
* @returns {Promise<Models.DocumentList<Document>>}
|
|
1227
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1228
|
+
*/
|
|
1229
|
+
createDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documents: object[]): Promise<Models.DocumentList<Document>>;
|
|
1230
|
+
createDocuments<Document extends Models.Document = Models.DefaultDocument>(
|
|
1231
|
+
paramsOrFirst: { databaseId: string, collectionId: string, documents: object[] } | string,
|
|
1232
|
+
...rest: [(string)?, (object[])?]
|
|
1233
|
+
): Promise<Models.DocumentList<Document>> {
|
|
1234
|
+
let params: { databaseId: string, collectionId: string, documents: object[] };
|
|
1235
|
+
|
|
1236
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1237
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[] };
|
|
1238
|
+
} else {
|
|
1239
|
+
params = {
|
|
1240
|
+
databaseId: paramsOrFirst as string,
|
|
1241
|
+
collectionId: rest[0] as string,
|
|
1242
|
+
documents: rest[1] as object[]
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
const databaseId = params.databaseId;
|
|
1247
|
+
const collectionId = params.collectionId;
|
|
1248
|
+
const documents = params.documents;
|
|
1249
|
+
|
|
1250
|
+
if (typeof databaseId === 'undefined') {
|
|
1251
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1252
|
+
}
|
|
1253
|
+
if (typeof collectionId === 'undefined') {
|
|
1254
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1255
|
+
}
|
|
1256
|
+
if (typeof documents === 'undefined') {
|
|
1257
|
+
throw new AppwriteException('Missing required parameter: "documents"');
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1261
|
+
const payload: Payload = {};
|
|
1262
|
+
if (typeof documents !== 'undefined') {
|
|
1263
|
+
payload['documents'] = documents;
|
|
1264
|
+
}
|
|
1265
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1266
|
+
|
|
1267
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1268
|
+
'content-type': 'application/json',
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
return this.client.call(
|
|
1272
|
+
'post',
|
|
1273
|
+
uri,
|
|
1274
|
+
apiHeaders,
|
|
1275
|
+
payload
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console.
|
|
1281
|
+
*
|
|
1282
|
+
*
|
|
1283
|
+
* @param {string} params.databaseId - Database ID.
|
|
1284
|
+
* @param {string} params.collectionId - Collection ID.
|
|
1285
|
+
* @param {object[]} params.documents - Array of document data as JSON objects. May contain partial documents.
|
|
1286
|
+
* @param {string} params.transactionId - Transaction ID for staging the operation.
|
|
1287
|
+
* @throws {AppwriteException}
|
|
1288
|
+
* @returns {Promise<Models.DocumentList<Document>>}
|
|
1289
|
+
*/
|
|
1290
|
+
upsertDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise<Models.DocumentList<Document>>;
|
|
1291
|
+
/**
|
|
1292
|
+
* Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console.
|
|
1293
|
+
*
|
|
1294
|
+
*
|
|
1295
|
+
* @param {string} databaseId - Database ID.
|
|
1296
|
+
* @param {string} collectionId - Collection ID.
|
|
1297
|
+
* @param {object[]} documents - Array of document data as JSON objects. May contain partial documents.
|
|
1298
|
+
* @param {string} transactionId - Transaction ID for staging the operation.
|
|
1299
|
+
* @throws {AppwriteException}
|
|
1300
|
+
* @returns {Promise<Models.DocumentList<Document>>}
|
|
1301
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1302
|
+
*/
|
|
1303
|
+
upsertDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise<Models.DocumentList<Document>>;
|
|
1304
|
+
upsertDocuments<Document extends Models.Document = Models.DefaultDocument>(
|
|
1305
|
+
paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string,
|
|
1306
|
+
...rest: [(string)?, (object[])?, (string)?]
|
|
1307
|
+
): Promise<Models.DocumentList<Document>> {
|
|
1308
|
+
let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string };
|
|
1309
|
+
|
|
1310
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1311
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string };
|
|
1312
|
+
} else {
|
|
1313
|
+
params = {
|
|
1314
|
+
databaseId: paramsOrFirst as string,
|
|
1315
|
+
collectionId: rest[0] as string,
|
|
1316
|
+
documents: rest[1] as object[],
|
|
1317
|
+
transactionId: rest[2] as string
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
const databaseId = params.databaseId;
|
|
1322
|
+
const collectionId = params.collectionId;
|
|
1323
|
+
const documents = params.documents;
|
|
1324
|
+
const transactionId = params.transactionId;
|
|
1325
|
+
|
|
1326
|
+
if (typeof databaseId === 'undefined') {
|
|
1327
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1328
|
+
}
|
|
1329
|
+
if (typeof collectionId === 'undefined') {
|
|
1330
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1331
|
+
}
|
|
1332
|
+
if (typeof documents === 'undefined') {
|
|
1333
|
+
throw new AppwriteException('Missing required parameter: "documents"');
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1337
|
+
const payload: Payload = {};
|
|
1338
|
+
if (typeof documents !== 'undefined') {
|
|
1339
|
+
payload['documents'] = documents;
|
|
1340
|
+
}
|
|
1341
|
+
if (typeof transactionId !== 'undefined') {
|
|
1342
|
+
payload['transactionId'] = transactionId;
|
|
1343
|
+
}
|
|
1344
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1345
|
+
|
|
1346
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1347
|
+
'content-type': 'application/json',
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
return this.client.call(
|
|
1351
|
+
'put',
|
|
1352
|
+
uri,
|
|
1353
|
+
apiHeaders,
|
|
1354
|
+
payload
|
|
1355
|
+
);
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
/**
|
|
1359
|
+
* Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated.
|
|
1360
|
+
*
|
|
1361
|
+
* @param {string} params.databaseId - Database ID.
|
|
1362
|
+
* @param {string} params.collectionId - Collection ID.
|
|
1363
|
+
* @param {object} params.data - Document data as JSON object. Include only attribute and value pairs to be updated.
|
|
1364
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
|
|
1365
|
+
* @param {string} params.transactionId - Transaction ID for staging the operation.
|
|
1366
|
+
* @throws {AppwriteException}
|
|
1367
|
+
* @returns {Promise<Models.DocumentList<Document>>}
|
|
1368
|
+
*/
|
|
1369
|
+
updateDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }): Promise<Models.DocumentList<Document>>;
|
|
1370
|
+
/**
|
|
1371
|
+
* Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated.
|
|
1372
|
+
*
|
|
1373
|
+
* @param {string} databaseId - Database ID.
|
|
1374
|
+
* @param {string} collectionId - Collection ID.
|
|
1375
|
+
* @param {object} data - Document data as JSON object. Include only attribute and value pairs to be updated.
|
|
1376
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
|
|
1377
|
+
* @param {string} transactionId - Transaction ID for staging the operation.
|
|
1378
|
+
* @throws {AppwriteException}
|
|
1379
|
+
* @returns {Promise<Models.DocumentList<Document>>}
|
|
1380
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1381
|
+
*/
|
|
1382
|
+
updateDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string): Promise<Models.DocumentList<Document>>;
|
|
1383
|
+
updateDocuments<Document extends Models.Document = Models.DefaultDocument>(
|
|
1384
|
+
paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string } | string,
|
|
1385
|
+
...rest: [(string)?, (object)?, (string[])?, (string)?]
|
|
1386
|
+
): Promise<Models.DocumentList<Document>> {
|
|
1387
|
+
let params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string };
|
|
1388
|
+
|
|
1389
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1390
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string };
|
|
1391
|
+
} else {
|
|
1392
|
+
params = {
|
|
1393
|
+
databaseId: paramsOrFirst as string,
|
|
1394
|
+
collectionId: rest[0] as string,
|
|
1395
|
+
data: rest[1] as object,
|
|
1396
|
+
queries: rest[2] as string[],
|
|
1397
|
+
transactionId: rest[3] as string
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
const databaseId = params.databaseId;
|
|
1402
|
+
const collectionId = params.collectionId;
|
|
1403
|
+
const data = params.data;
|
|
1404
|
+
const queries = params.queries;
|
|
1405
|
+
const transactionId = params.transactionId;
|
|
1406
|
+
|
|
1407
|
+
if (typeof databaseId === 'undefined') {
|
|
1408
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1409
|
+
}
|
|
1410
|
+
if (typeof collectionId === 'undefined') {
|
|
1411
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1415
|
+
const payload: Payload = {};
|
|
1416
|
+
if (typeof data !== 'undefined') {
|
|
1417
|
+
payload['data'] = data;
|
|
1418
|
+
}
|
|
1419
|
+
if (typeof queries !== 'undefined') {
|
|
1420
|
+
payload['queries'] = queries;
|
|
1421
|
+
}
|
|
1422
|
+
if (typeof transactionId !== 'undefined') {
|
|
1423
|
+
payload['transactionId'] = transactionId;
|
|
1424
|
+
}
|
|
1425
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1426
|
+
|
|
1427
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1428
|
+
'content-type': 'application/json',
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
return this.client.call(
|
|
1432
|
+
'patch',
|
|
1433
|
+
uri,
|
|
1434
|
+
apiHeaders,
|
|
1435
|
+
payload
|
|
1436
|
+
);
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* Bulk delete documents using queries, if no queries are passed then all documents are deleted.
|
|
1441
|
+
*
|
|
1442
|
+
* @param {string} params.databaseId - Database ID.
|
|
1443
|
+
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
1444
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
|
|
1445
|
+
* @param {string} params.transactionId - Transaction ID for staging the operation.
|
|
1446
|
+
* @throws {AppwriteException}
|
|
1447
|
+
* @returns {Promise<Models.DocumentList<Document>>}
|
|
1448
|
+
*/
|
|
1449
|
+
deleteDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): Promise<Models.DocumentList<Document>>;
|
|
1450
|
+
/**
|
|
1451
|
+
* Bulk delete documents using queries, if no queries are passed then all documents are deleted.
|
|
1452
|
+
*
|
|
1453
|
+
* @param {string} databaseId - Database ID.
|
|
1454
|
+
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
1455
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
|
|
1456
|
+
* @param {string} transactionId - Transaction ID for staging the operation.
|
|
1457
|
+
* @throws {AppwriteException}
|
|
1458
|
+
* @returns {Promise<Models.DocumentList<Document>>}
|
|
1459
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1460
|
+
*/
|
|
1461
|
+
deleteDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise<Models.DocumentList<Document>>;
|
|
1462
|
+
deleteDocuments<Document extends Models.Document = Models.DefaultDocument>(
|
|
1463
|
+
paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string,
|
|
1464
|
+
...rest: [(string)?, (string[])?, (string)?]
|
|
1465
|
+
): Promise<Models.DocumentList<Document>> {
|
|
1466
|
+
let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string };
|
|
1467
|
+
|
|
1468
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1469
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string };
|
|
1470
|
+
} else {
|
|
1471
|
+
params = {
|
|
1472
|
+
databaseId: paramsOrFirst as string,
|
|
1473
|
+
collectionId: rest[0] as string,
|
|
1474
|
+
queries: rest[1] as string[],
|
|
1475
|
+
transactionId: rest[2] as string
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
const databaseId = params.databaseId;
|
|
1480
|
+
const collectionId = params.collectionId;
|
|
1481
|
+
const queries = params.queries;
|
|
1482
|
+
const transactionId = params.transactionId;
|
|
1483
|
+
|
|
1484
|
+
if (typeof databaseId === 'undefined') {
|
|
1485
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1486
|
+
}
|
|
1487
|
+
if (typeof collectionId === 'undefined') {
|
|
1488
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1492
|
+
const payload: Payload = {};
|
|
1493
|
+
if (typeof queries !== 'undefined') {
|
|
1494
|
+
payload['queries'] = queries;
|
|
1495
|
+
}
|
|
1496
|
+
if (typeof transactionId !== 'undefined') {
|
|
1497
|
+
payload['transactionId'] = transactionId;
|
|
1498
|
+
}
|
|
1499
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1500
|
+
|
|
1501
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1502
|
+
'content-type': 'application/json',
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
return this.client.call(
|
|
1506
|
+
'delete',
|
|
1507
|
+
uri,
|
|
1508
|
+
apiHeaders,
|
|
1509
|
+
payload
|
|
1510
|
+
);
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
/**
|
|
1514
|
+
* Get a document by its unique ID. This endpoint response returns a JSON object with the document data.
|
|
1515
|
+
*
|
|
1516
|
+
* @param {string} params.databaseId - Database ID.
|
|
1517
|
+
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
1518
|
+
* @param {string} params.documentId - Document ID.
|
|
1519
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
|
|
1520
|
+
* @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction.
|
|
1521
|
+
* @throws {AppwriteException}
|
|
1522
|
+
* @returns {Promise<Document>}
|
|
1523
|
+
*/
|
|
1524
|
+
getDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }): Promise<Document>;
|
|
1525
|
+
/**
|
|
1526
|
+
* Get a document by its unique ID. This endpoint response returns a JSON object with the document data.
|
|
1527
|
+
*
|
|
1528
|
+
* @param {string} databaseId - Database ID.
|
|
1529
|
+
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
1530
|
+
* @param {string} documentId - Document ID.
|
|
1531
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
|
|
1532
|
+
* @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction.
|
|
1533
|
+
* @throws {AppwriteException}
|
|
1534
|
+
* @returns {Promise<Document>}
|
|
1535
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1536
|
+
*/
|
|
1537
|
+
getDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string): Promise<Document>;
|
|
1538
|
+
getDocument<Document extends Models.Document = Models.DefaultDocument>(
|
|
1539
|
+
paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string } | string,
|
|
1540
|
+
...rest: [(string)?, (string)?, (string[])?, (string)?]
|
|
1541
|
+
): Promise<Document> {
|
|
1542
|
+
let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string };
|
|
1543
|
+
|
|
1544
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1545
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string };
|
|
1546
|
+
} else {
|
|
1547
|
+
params = {
|
|
1548
|
+
databaseId: paramsOrFirst as string,
|
|
1549
|
+
collectionId: rest[0] as string,
|
|
1550
|
+
documentId: rest[1] as string,
|
|
1551
|
+
queries: rest[2] as string[],
|
|
1552
|
+
transactionId: rest[3] as string
|
|
1553
|
+
};
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
const databaseId = params.databaseId;
|
|
1557
|
+
const collectionId = params.collectionId;
|
|
1558
|
+
const documentId = params.documentId;
|
|
1559
|
+
const queries = params.queries;
|
|
1560
|
+
const transactionId = params.transactionId;
|
|
1561
|
+
|
|
1562
|
+
if (typeof databaseId === 'undefined') {
|
|
1563
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1564
|
+
}
|
|
1565
|
+
if (typeof collectionId === 'undefined') {
|
|
1566
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1567
|
+
}
|
|
1568
|
+
if (typeof documentId === 'undefined') {
|
|
1569
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
1573
|
+
const payload: Payload = {};
|
|
1574
|
+
if (typeof queries !== 'undefined') {
|
|
1575
|
+
payload['queries'] = queries;
|
|
1576
|
+
}
|
|
1577
|
+
if (typeof transactionId !== 'undefined') {
|
|
1578
|
+
payload['transactionId'] = transactionId;
|
|
1579
|
+
}
|
|
1580
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1581
|
+
|
|
1582
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
return this.client.call(
|
|
1586
|
+
'get',
|
|
1587
|
+
uri,
|
|
1588
|
+
apiHeaders,
|
|
1589
|
+
payload
|
|
1590
|
+
);
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
/**
|
|
1594
|
+
* Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console.
|
|
1595
|
+
*
|
|
1596
|
+
* @param {string} params.databaseId - Database ID.
|
|
1597
|
+
* @param {string} params.collectionId - Collection ID.
|
|
1598
|
+
* @param {string} params.documentId - Document ID.
|
|
1599
|
+
* @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include all required fields of the document to be created or updated.
|
|
1600
|
+
* @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
1601
|
+
* @param {string} params.transactionId - Transaction ID for staging the operation.
|
|
1602
|
+
* @throws {AppwriteException}
|
|
1603
|
+
* @returns {Promise<Document>}
|
|
1604
|
+
*/
|
|
1605
|
+
upsertDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string }): Promise<Document>;
|
|
1606
|
+
/**
|
|
1607
|
+
* Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console.
|
|
1608
|
+
*
|
|
1609
|
+
* @param {string} databaseId - Database ID.
|
|
1610
|
+
* @param {string} collectionId - Collection ID.
|
|
1611
|
+
* @param {string} documentId - Document ID.
|
|
1612
|
+
* @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include all required fields of the document to be created or updated.
|
|
1613
|
+
* @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
1614
|
+
* @param {string} transactionId - Transaction ID for staging the operation.
|
|
1615
|
+
* @throws {AppwriteException}
|
|
1616
|
+
* @returns {Promise<Document>}
|
|
1617
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1618
|
+
*/
|
|
1619
|
+
upsertDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string): Promise<Document>;
|
|
1620
|
+
upsertDocument<Document extends Models.Document = Models.DefaultDocument>(
|
|
1621
|
+
paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string } | string,
|
|
1622
|
+
...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, (string[])?, (string)?]
|
|
1623
|
+
): Promise<Document> {
|
|
1624
|
+
let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string };
|
|
1625
|
+
|
|
1626
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1627
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string };
|
|
1628
|
+
} else {
|
|
1629
|
+
params = {
|
|
1630
|
+
databaseId: paramsOrFirst as string,
|
|
1631
|
+
collectionId: rest[0] as string,
|
|
1632
|
+
documentId: rest[1] as string,
|
|
1633
|
+
data: rest[2] as Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>,
|
|
1634
|
+
permissions: rest[3] as string[],
|
|
1635
|
+
transactionId: rest[4] as string
|
|
1636
|
+
};
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
const databaseId = params.databaseId;
|
|
1640
|
+
const collectionId = params.collectionId;
|
|
1641
|
+
const documentId = params.documentId;
|
|
1642
|
+
const data = params.data;
|
|
1643
|
+
const permissions = params.permissions;
|
|
1644
|
+
const transactionId = params.transactionId;
|
|
1645
|
+
|
|
1646
|
+
if (typeof databaseId === 'undefined') {
|
|
1647
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1648
|
+
}
|
|
1649
|
+
if (typeof collectionId === 'undefined') {
|
|
1650
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1651
|
+
}
|
|
1652
|
+
if (typeof documentId === 'undefined') {
|
|
1653
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
1657
|
+
const payload: Payload = {};
|
|
1658
|
+
if (typeof data !== 'undefined') {
|
|
1659
|
+
payload['data'] = data;
|
|
1660
|
+
}
|
|
1661
|
+
if (typeof permissions !== 'undefined') {
|
|
1662
|
+
payload['permissions'] = permissions;
|
|
1663
|
+
}
|
|
1664
|
+
if (typeof transactionId !== 'undefined') {
|
|
1665
|
+
payload['transactionId'] = transactionId;
|
|
1666
|
+
}
|
|
1667
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1668
|
+
|
|
1669
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1670
|
+
'content-type': 'application/json',
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
return this.client.call(
|
|
1674
|
+
'put',
|
|
1675
|
+
uri,
|
|
1676
|
+
apiHeaders,
|
|
1677
|
+
payload
|
|
1678
|
+
);
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
/**
|
|
1682
|
+
* Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
|
|
1683
|
+
*
|
|
1684
|
+
* @param {string} params.databaseId - Database ID.
|
|
1685
|
+
* @param {string} params.collectionId - Collection ID.
|
|
1686
|
+
* @param {string} params.documentId - Document ID.
|
|
1687
|
+
* @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include only fields and value pairs to be updated.
|
|
1688
|
+
* @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
1689
|
+
* @param {string} params.transactionId - Transaction ID for staging the operation.
|
|
1690
|
+
* @throws {AppwriteException}
|
|
1691
|
+
* @returns {Promise<Document>}
|
|
1692
|
+
*/
|
|
1693
|
+
updateDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string }): Promise<Document>;
|
|
1694
|
+
/**
|
|
1695
|
+
* Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
|
|
1696
|
+
*
|
|
1697
|
+
* @param {string} databaseId - Database ID.
|
|
1698
|
+
* @param {string} collectionId - Collection ID.
|
|
1699
|
+
* @param {string} documentId - Document ID.
|
|
1700
|
+
* @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include only fields and value pairs to be updated.
|
|
1701
|
+
* @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
1702
|
+
* @param {string} transactionId - Transaction ID for staging the operation.
|
|
1703
|
+
* @throws {AppwriteException}
|
|
1704
|
+
* @returns {Promise<Document>}
|
|
1705
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1706
|
+
*/
|
|
1707
|
+
updateDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string): Promise<Document>;
|
|
1708
|
+
updateDocument<Document extends Models.Document = Models.DefaultDocument>(
|
|
1709
|
+
paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string } | string,
|
|
1710
|
+
...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, (string[])?, (string)?]
|
|
1711
|
+
): Promise<Document> {
|
|
1712
|
+
let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string };
|
|
1713
|
+
|
|
1714
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1715
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string };
|
|
1716
|
+
} else {
|
|
1717
|
+
params = {
|
|
1718
|
+
databaseId: paramsOrFirst as string,
|
|
1719
|
+
collectionId: rest[0] as string,
|
|
1720
|
+
documentId: rest[1] as string,
|
|
1721
|
+
data: rest[2] as Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>,
|
|
1722
|
+
permissions: rest[3] as string[],
|
|
1723
|
+
transactionId: rest[4] as string
|
|
1724
|
+
};
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
const databaseId = params.databaseId;
|
|
1728
|
+
const collectionId = params.collectionId;
|
|
1729
|
+
const documentId = params.documentId;
|
|
1730
|
+
const data = params.data;
|
|
1731
|
+
const permissions = params.permissions;
|
|
1732
|
+
const transactionId = params.transactionId;
|
|
1733
|
+
|
|
1734
|
+
if (typeof databaseId === 'undefined') {
|
|
1735
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1736
|
+
}
|
|
1737
|
+
if (typeof collectionId === 'undefined') {
|
|
1738
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1739
|
+
}
|
|
1740
|
+
if (typeof documentId === 'undefined') {
|
|
1741
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
1745
|
+
const payload: Payload = {};
|
|
1746
|
+
if (typeof data !== 'undefined') {
|
|
1747
|
+
payload['data'] = data;
|
|
1748
|
+
}
|
|
1749
|
+
if (typeof permissions !== 'undefined') {
|
|
1750
|
+
payload['permissions'] = permissions;
|
|
1751
|
+
}
|
|
1752
|
+
if (typeof transactionId !== 'undefined') {
|
|
1753
|
+
payload['transactionId'] = transactionId;
|
|
1754
|
+
}
|
|
1755
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1756
|
+
|
|
1757
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1758
|
+
'content-type': 'application/json',
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
return this.client.call(
|
|
1762
|
+
'patch',
|
|
1763
|
+
uri,
|
|
1764
|
+
apiHeaders,
|
|
1765
|
+
payload
|
|
1766
|
+
);
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
/**
|
|
1770
|
+
* Delete a document by its unique ID.
|
|
1771
|
+
*
|
|
1772
|
+
* @param {string} params.databaseId - Database ID.
|
|
1773
|
+
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
1774
|
+
* @param {string} params.documentId - Document ID.
|
|
1775
|
+
* @param {string} params.transactionId - Transaction ID for staging the operation.
|
|
1776
|
+
* @throws {AppwriteException}
|
|
1777
|
+
* @returns {Promise<{}>}
|
|
1778
|
+
*/
|
|
1779
|
+
deleteDocument(params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }): Promise<{}>;
|
|
1780
|
+
/**
|
|
1781
|
+
* Delete a document by its unique ID.
|
|
1782
|
+
*
|
|
1783
|
+
* @param {string} databaseId - Database ID.
|
|
1784
|
+
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
1785
|
+
* @param {string} documentId - Document ID.
|
|
1786
|
+
* @param {string} transactionId - Transaction ID for staging the operation.
|
|
1787
|
+
* @throws {AppwriteException}
|
|
1788
|
+
* @returns {Promise<{}>}
|
|
1789
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1790
|
+
*/
|
|
1791
|
+
deleteDocument(databaseId: string, collectionId: string, documentId: string, transactionId?: string): Promise<{}>;
|
|
1792
|
+
deleteDocument(
|
|
1793
|
+
paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, transactionId?: string } | string,
|
|
1794
|
+
...rest: [(string)?, (string)?, (string)?]
|
|
1795
|
+
): Promise<{}> {
|
|
1796
|
+
let params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string };
|
|
1797
|
+
|
|
1798
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1799
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, transactionId?: string };
|
|
1800
|
+
} else {
|
|
1801
|
+
params = {
|
|
1802
|
+
databaseId: paramsOrFirst as string,
|
|
1803
|
+
collectionId: rest[0] as string,
|
|
1804
|
+
documentId: rest[1] as string,
|
|
1805
|
+
transactionId: rest[2] as string
|
|
1806
|
+
};
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
const databaseId = params.databaseId;
|
|
1810
|
+
const collectionId = params.collectionId;
|
|
1811
|
+
const documentId = params.documentId;
|
|
1812
|
+
const transactionId = params.transactionId;
|
|
1813
|
+
|
|
1814
|
+
if (typeof databaseId === 'undefined') {
|
|
1815
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1816
|
+
}
|
|
1817
|
+
if (typeof collectionId === 'undefined') {
|
|
1818
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1819
|
+
}
|
|
1820
|
+
if (typeof documentId === 'undefined') {
|
|
1821
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
1825
|
+
const payload: Payload = {};
|
|
1826
|
+
if (typeof transactionId !== 'undefined') {
|
|
1827
|
+
payload['transactionId'] = transactionId;
|
|
1828
|
+
}
|
|
1829
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1830
|
+
|
|
1831
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1832
|
+
'content-type': 'application/json',
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
return this.client.call(
|
|
1836
|
+
'delete',
|
|
1837
|
+
uri,
|
|
1838
|
+
apiHeaders,
|
|
1839
|
+
payload
|
|
1840
|
+
);
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
/**
|
|
1844
|
+
* Get the document activity logs list by its unique ID.
|
|
1845
|
+
*
|
|
1846
|
+
* @param {string} params.databaseId - Database ID.
|
|
1847
|
+
* @param {string} params.collectionId - Collection ID.
|
|
1848
|
+
* @param {string} params.documentId - Document ID.
|
|
1849
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset
|
|
1850
|
+
* @throws {AppwriteException}
|
|
1851
|
+
* @returns {Promise<Models.LogList>}
|
|
1852
|
+
*/
|
|
1853
|
+
listDocumentLogs(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[] }): Promise<Models.LogList>;
|
|
1854
|
+
/**
|
|
1855
|
+
* Get the document activity logs list by its unique ID.
|
|
1856
|
+
*
|
|
1857
|
+
* @param {string} databaseId - Database ID.
|
|
1858
|
+
* @param {string} collectionId - Collection ID.
|
|
1859
|
+
* @param {string} documentId - Document ID.
|
|
1860
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset
|
|
1861
|
+
* @throws {AppwriteException}
|
|
1862
|
+
* @returns {Promise<Models.LogList>}
|
|
1863
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1864
|
+
*/
|
|
1865
|
+
listDocumentLogs(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Models.LogList>;
|
|
1866
|
+
listDocumentLogs(
|
|
1867
|
+
paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[] } | string,
|
|
1868
|
+
...rest: [(string)?, (string)?, (string[])?]
|
|
1869
|
+
): Promise<Models.LogList> {
|
|
1870
|
+
let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[] };
|
|
1871
|
+
|
|
1872
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1873
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[] };
|
|
1874
|
+
} else {
|
|
1875
|
+
params = {
|
|
1876
|
+
databaseId: paramsOrFirst as string,
|
|
1877
|
+
collectionId: rest[0] as string,
|
|
1878
|
+
documentId: rest[1] as string,
|
|
1879
|
+
queries: rest[2] as string[]
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
const databaseId = params.databaseId;
|
|
1884
|
+
const collectionId = params.collectionId;
|
|
1885
|
+
const documentId = params.documentId;
|
|
1886
|
+
const queries = params.queries;
|
|
1887
|
+
|
|
1888
|
+
if (typeof databaseId === 'undefined') {
|
|
1889
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1890
|
+
}
|
|
1891
|
+
if (typeof collectionId === 'undefined') {
|
|
1892
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1893
|
+
}
|
|
1894
|
+
if (typeof documentId === 'undefined') {
|
|
1895
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/logs'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
1899
|
+
const payload: Payload = {};
|
|
1900
|
+
if (typeof queries !== 'undefined') {
|
|
1901
|
+
payload['queries'] = queries;
|
|
1902
|
+
}
|
|
1903
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1904
|
+
|
|
1905
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
return this.client.call(
|
|
1909
|
+
'get',
|
|
1910
|
+
uri,
|
|
1911
|
+
apiHeaders,
|
|
1912
|
+
payload
|
|
1913
|
+
);
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
/**
|
|
1917
|
+
* Decrement a specific column of a row by a given value.
|
|
1918
|
+
*
|
|
1919
|
+
* @param {string} params.databaseId - Database ID.
|
|
1920
|
+
* @param {string} params.collectionId - Collection ID.
|
|
1921
|
+
* @param {string} params.documentId - Document ID.
|
|
1922
|
+
* @param {string} params.attribute - Attribute key.
|
|
1923
|
+
* @param {number} params.value - Value to decrement the attribute by. The value must be a number.
|
|
1924
|
+
* @param {number} params.min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.
|
|
1925
|
+
* @param {string} params.transactionId - Transaction ID for staging the operation.
|
|
1926
|
+
* @throws {AppwriteException}
|
|
1927
|
+
* @returns {Promise<Document>}
|
|
1928
|
+
*/
|
|
1929
|
+
decrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }): Promise<Document>;
|
|
1930
|
+
/**
|
|
1931
|
+
* Decrement a specific column of a row by a given value.
|
|
1932
|
+
*
|
|
1933
|
+
* @param {string} databaseId - Database ID.
|
|
1934
|
+
* @param {string} collectionId - Collection ID.
|
|
1935
|
+
* @param {string} documentId - Document ID.
|
|
1936
|
+
* @param {string} attribute - Attribute key.
|
|
1937
|
+
* @param {number} value - Value to decrement the attribute by. The value must be a number.
|
|
1938
|
+
* @param {number} min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.
|
|
1939
|
+
* @param {string} transactionId - Transaction ID for staging the operation.
|
|
1940
|
+
* @throws {AppwriteException}
|
|
1941
|
+
* @returns {Promise<Document>}
|
|
1942
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1943
|
+
*/
|
|
1944
|
+
decrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string): Promise<Document>;
|
|
1945
|
+
decrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(
|
|
1946
|
+
paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string } | string,
|
|
1947
|
+
...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?]
|
|
1948
|
+
): Promise<Document> {
|
|
1949
|
+
let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string };
|
|
1950
|
+
|
|
1951
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
1952
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string };
|
|
1953
|
+
} else {
|
|
1954
|
+
params = {
|
|
1955
|
+
databaseId: paramsOrFirst as string,
|
|
1956
|
+
collectionId: rest[0] as string,
|
|
1957
|
+
documentId: rest[1] as string,
|
|
1958
|
+
attribute: rest[2] as string,
|
|
1959
|
+
value: rest[3] as number,
|
|
1960
|
+
min: rest[4] as number,
|
|
1961
|
+
transactionId: rest[5] as string
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
const databaseId = params.databaseId;
|
|
1966
|
+
const collectionId = params.collectionId;
|
|
1967
|
+
const documentId = params.documentId;
|
|
1968
|
+
const attribute = params.attribute;
|
|
1969
|
+
const value = params.value;
|
|
1970
|
+
const min = params.min;
|
|
1971
|
+
const transactionId = params.transactionId;
|
|
1972
|
+
|
|
1973
|
+
if (typeof databaseId === 'undefined') {
|
|
1974
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1975
|
+
}
|
|
1976
|
+
if (typeof collectionId === 'undefined') {
|
|
1977
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1978
|
+
}
|
|
1979
|
+
if (typeof documentId === 'undefined') {
|
|
1980
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1981
|
+
}
|
|
1982
|
+
if (typeof attribute === 'undefined') {
|
|
1983
|
+
throw new AppwriteException('Missing required parameter: "attribute"');
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute);
|
|
1987
|
+
const payload: Payload = {};
|
|
1988
|
+
if (typeof value !== 'undefined') {
|
|
1989
|
+
payload['value'] = value;
|
|
1990
|
+
}
|
|
1991
|
+
if (typeof min !== 'undefined') {
|
|
1992
|
+
payload['min'] = min;
|
|
1993
|
+
}
|
|
1994
|
+
if (typeof transactionId !== 'undefined') {
|
|
1995
|
+
payload['transactionId'] = transactionId;
|
|
1996
|
+
}
|
|
1997
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1998
|
+
|
|
1999
|
+
const apiHeaders: { [header: string]: string } = {
|
|
2000
|
+
'content-type': 'application/json',
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
return this.client.call(
|
|
2004
|
+
'patch',
|
|
2005
|
+
uri,
|
|
2006
|
+
apiHeaders,
|
|
2007
|
+
payload
|
|
2008
|
+
);
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
/**
|
|
2012
|
+
* Increment a specific column of a row by a given value.
|
|
2013
|
+
*
|
|
2014
|
+
* @param {string} params.databaseId - Database ID.
|
|
2015
|
+
* @param {string} params.collectionId - Collection ID.
|
|
2016
|
+
* @param {string} params.documentId - Document ID.
|
|
2017
|
+
* @param {string} params.attribute - Attribute key.
|
|
2018
|
+
* @param {number} params.value - Value to increment the attribute by. The value must be a number.
|
|
2019
|
+
* @param {number} params.max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.
|
|
2020
|
+
* @param {string} params.transactionId - Transaction ID for staging the operation.
|
|
2021
|
+
* @throws {AppwriteException}
|
|
2022
|
+
* @returns {Promise<Document>}
|
|
2023
|
+
*/
|
|
2024
|
+
incrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }): Promise<Document>;
|
|
2025
|
+
/**
|
|
2026
|
+
* Increment a specific column of a row by a given value.
|
|
2027
|
+
*
|
|
2028
|
+
* @param {string} databaseId - Database ID.
|
|
2029
|
+
* @param {string} collectionId - Collection ID.
|
|
2030
|
+
* @param {string} documentId - Document ID.
|
|
2031
|
+
* @param {string} attribute - Attribute key.
|
|
2032
|
+
* @param {number} value - Value to increment the attribute by. The value must be a number.
|
|
2033
|
+
* @param {number} max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.
|
|
2034
|
+
* @param {string} transactionId - Transaction ID for staging the operation.
|
|
2035
|
+
* @throws {AppwriteException}
|
|
2036
|
+
* @returns {Promise<Document>}
|
|
2037
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
2038
|
+
*/
|
|
2039
|
+
incrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string): Promise<Document>;
|
|
2040
|
+
incrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(
|
|
2041
|
+
paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string } | string,
|
|
2042
|
+
...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?]
|
|
2043
|
+
): Promise<Document> {
|
|
2044
|
+
let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string };
|
|
2045
|
+
|
|
2046
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
2047
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string };
|
|
2048
|
+
} else {
|
|
2049
|
+
params = {
|
|
2050
|
+
databaseId: paramsOrFirst as string,
|
|
2051
|
+
collectionId: rest[0] as string,
|
|
2052
|
+
documentId: rest[1] as string,
|
|
2053
|
+
attribute: rest[2] as string,
|
|
2054
|
+
value: rest[3] as number,
|
|
2055
|
+
max: rest[4] as number,
|
|
2056
|
+
transactionId: rest[5] as string
|
|
2057
|
+
};
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
const databaseId = params.databaseId;
|
|
2061
|
+
const collectionId = params.collectionId;
|
|
2062
|
+
const documentId = params.documentId;
|
|
2063
|
+
const attribute = params.attribute;
|
|
2064
|
+
const value = params.value;
|
|
2065
|
+
const max = params.max;
|
|
2066
|
+
const transactionId = params.transactionId;
|
|
2067
|
+
|
|
2068
|
+
if (typeof databaseId === 'undefined') {
|
|
2069
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
2070
|
+
}
|
|
2071
|
+
if (typeof collectionId === 'undefined') {
|
|
2072
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
2073
|
+
}
|
|
2074
|
+
if (typeof documentId === 'undefined') {
|
|
2075
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
2076
|
+
}
|
|
2077
|
+
if (typeof attribute === 'undefined') {
|
|
2078
|
+
throw new AppwriteException('Missing required parameter: "attribute"');
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute);
|
|
2082
|
+
const payload: Payload = {};
|
|
2083
|
+
if (typeof value !== 'undefined') {
|
|
2084
|
+
payload['value'] = value;
|
|
2085
|
+
}
|
|
2086
|
+
if (typeof max !== 'undefined') {
|
|
2087
|
+
payload['max'] = max;
|
|
2088
|
+
}
|
|
2089
|
+
if (typeof transactionId !== 'undefined') {
|
|
2090
|
+
payload['transactionId'] = transactionId;
|
|
2091
|
+
}
|
|
2092
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2093
|
+
|
|
2094
|
+
const apiHeaders: { [header: string]: string } = {
|
|
2095
|
+
'content-type': 'application/json',
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
return this.client.call(
|
|
2099
|
+
'patch',
|
|
2100
|
+
uri,
|
|
2101
|
+
apiHeaders,
|
|
2102
|
+
payload
|
|
2103
|
+
);
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
/**
|
|
2107
|
+
* List indexes in the collection.
|
|
2108
|
+
*
|
|
2109
|
+
* @param {string} params.databaseId - Database ID.
|
|
2110
|
+
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
2111
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error
|
|
2112
|
+
* @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
|
|
2113
|
+
* @throws {AppwriteException}
|
|
2114
|
+
* @returns {Promise<Models.IndexList>}
|
|
2115
|
+
*/
|
|
2116
|
+
listIndexes(params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise<Models.IndexList>;
|
|
2117
|
+
/**
|
|
2118
|
+
* List indexes in the collection.
|
|
2119
|
+
*
|
|
2120
|
+
* @param {string} databaseId - Database ID.
|
|
2121
|
+
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
2122
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error
|
|
2123
|
+
* @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
|
|
2124
|
+
* @throws {AppwriteException}
|
|
2125
|
+
* @returns {Promise<Models.IndexList>}
|
|
2126
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
2127
|
+
*/
|
|
2128
|
+
listIndexes(databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise<Models.IndexList>;
|
|
2129
|
+
listIndexes(
|
|
2130
|
+
paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string,
|
|
2131
|
+
...rest: [(string)?, (string[])?, (boolean)?]
|
|
2132
|
+
): Promise<Models.IndexList> {
|
|
2133
|
+
let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean };
|
|
2134
|
+
|
|
2135
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
2136
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean };
|
|
2137
|
+
} else {
|
|
2138
|
+
params = {
|
|
2139
|
+
databaseId: paramsOrFirst as string,
|
|
2140
|
+
collectionId: rest[0] as string,
|
|
2141
|
+
queries: rest[1] as string[],
|
|
2142
|
+
total: rest[2] as boolean
|
|
2143
|
+
};
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
const databaseId = params.databaseId;
|
|
2147
|
+
const collectionId = params.collectionId;
|
|
2148
|
+
const queries = params.queries;
|
|
2149
|
+
const total = params.total;
|
|
2150
|
+
|
|
2151
|
+
if (typeof databaseId === 'undefined') {
|
|
2152
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
2153
|
+
}
|
|
2154
|
+
if (typeof collectionId === 'undefined') {
|
|
2155
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
2159
|
+
const payload: Payload = {};
|
|
2160
|
+
if (typeof queries !== 'undefined') {
|
|
2161
|
+
payload['queries'] = queries;
|
|
2162
|
+
}
|
|
2163
|
+
if (typeof total !== 'undefined') {
|
|
2164
|
+
payload['total'] = total;
|
|
2165
|
+
}
|
|
2166
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2167
|
+
|
|
2168
|
+
const apiHeaders: { [header: string]: string } = {
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
return this.client.call(
|
|
2172
|
+
'get',
|
|
2173
|
+
uri,
|
|
2174
|
+
apiHeaders,
|
|
2175
|
+
payload
|
|
2176
|
+
);
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
/**
|
|
2180
|
+
* Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request.
|
|
2181
|
+
* Attributes can be `key`, `fulltext`, and `unique`.
|
|
2182
|
+
*
|
|
2183
|
+
* @param {string} params.databaseId - Database ID.
|
|
2184
|
+
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
2185
|
+
* @param {string} params.key - Index Key.
|
|
2186
|
+
* @param {DocumentsDBIndexType} params.type - Index type.
|
|
2187
|
+
* @param {string[]} params.attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long.
|
|
2188
|
+
* @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed.
|
|
2189
|
+
* @param {number[]} params.lengths - Length of index. Maximum of 100
|
|
2190
|
+
* @throws {AppwriteException}
|
|
2191
|
+
* @returns {Promise<Models.Index>}
|
|
2192
|
+
*/
|
|
2193
|
+
createIndex(params: { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }): Promise<Models.Index>;
|
|
2194
|
+
/**
|
|
2195
|
+
* Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request.
|
|
2196
|
+
* Attributes can be `key`, `fulltext`, and `unique`.
|
|
2197
|
+
*
|
|
2198
|
+
* @param {string} databaseId - Database ID.
|
|
2199
|
+
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
2200
|
+
* @param {string} key - Index Key.
|
|
2201
|
+
* @param {DocumentsDBIndexType} type - Index type.
|
|
2202
|
+
* @param {string[]} attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long.
|
|
2203
|
+
* @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed.
|
|
2204
|
+
* @param {number[]} lengths - Length of index. Maximum of 100
|
|
2205
|
+
* @throws {AppwriteException}
|
|
2206
|
+
* @returns {Promise<Models.Index>}
|
|
2207
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
2208
|
+
*/
|
|
2209
|
+
createIndex(databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise<Models.Index>;
|
|
2210
|
+
createIndex(
|
|
2211
|
+
paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string,
|
|
2212
|
+
...rest: [(string)?, (string)?, (DocumentsDBIndexType)?, (string[])?, (OrderBy[])?, (number[])?]
|
|
2213
|
+
): Promise<Models.Index> {
|
|
2214
|
+
let params: { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] };
|
|
2215
|
+
|
|
2216
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
2217
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] };
|
|
2218
|
+
} else {
|
|
2219
|
+
params = {
|
|
2220
|
+
databaseId: paramsOrFirst as string,
|
|
2221
|
+
collectionId: rest[0] as string,
|
|
2222
|
+
key: rest[1] as string,
|
|
2223
|
+
type: rest[2] as DocumentsDBIndexType,
|
|
2224
|
+
attributes: rest[3] as string[],
|
|
2225
|
+
orders: rest[4] as OrderBy[],
|
|
2226
|
+
lengths: rest[5] as number[]
|
|
2227
|
+
};
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
const databaseId = params.databaseId;
|
|
2231
|
+
const collectionId = params.collectionId;
|
|
2232
|
+
const key = params.key;
|
|
2233
|
+
const type = params.type;
|
|
2234
|
+
const attributes = params.attributes;
|
|
2235
|
+
const orders = params.orders;
|
|
2236
|
+
const lengths = params.lengths;
|
|
2237
|
+
|
|
2238
|
+
if (typeof databaseId === 'undefined') {
|
|
2239
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
2240
|
+
}
|
|
2241
|
+
if (typeof collectionId === 'undefined') {
|
|
2242
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
2243
|
+
}
|
|
2244
|
+
if (typeof key === 'undefined') {
|
|
2245
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
2246
|
+
}
|
|
2247
|
+
if (typeof type === 'undefined') {
|
|
2248
|
+
throw new AppwriteException('Missing required parameter: "type"');
|
|
2249
|
+
}
|
|
2250
|
+
if (typeof attributes === 'undefined') {
|
|
2251
|
+
throw new AppwriteException('Missing required parameter: "attributes"');
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
2255
|
+
const payload: Payload = {};
|
|
2256
|
+
if (typeof key !== 'undefined') {
|
|
2257
|
+
payload['key'] = key;
|
|
2258
|
+
}
|
|
2259
|
+
if (typeof type !== 'undefined') {
|
|
2260
|
+
payload['type'] = type;
|
|
2261
|
+
}
|
|
2262
|
+
if (typeof attributes !== 'undefined') {
|
|
2263
|
+
payload['attributes'] = attributes;
|
|
2264
|
+
}
|
|
2265
|
+
if (typeof orders !== 'undefined') {
|
|
2266
|
+
payload['orders'] = orders;
|
|
2267
|
+
}
|
|
2268
|
+
if (typeof lengths !== 'undefined') {
|
|
2269
|
+
payload['lengths'] = lengths;
|
|
2270
|
+
}
|
|
2271
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2272
|
+
|
|
2273
|
+
const apiHeaders: { [header: string]: string } = {
|
|
2274
|
+
'content-type': 'application/json',
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
return this.client.call(
|
|
2278
|
+
'post',
|
|
2279
|
+
uri,
|
|
2280
|
+
apiHeaders,
|
|
2281
|
+
payload
|
|
2282
|
+
);
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
/**
|
|
2286
|
+
* Get index by ID.
|
|
2287
|
+
*
|
|
2288
|
+
* @param {string} params.databaseId - Database ID.
|
|
2289
|
+
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
2290
|
+
* @param {string} params.key - Index Key.
|
|
2291
|
+
* @throws {AppwriteException}
|
|
2292
|
+
* @returns {Promise<Models.Index>}
|
|
2293
|
+
*/
|
|
2294
|
+
getIndex(params: { databaseId: string, collectionId: string, key: string }): Promise<Models.Index>;
|
|
2295
|
+
/**
|
|
2296
|
+
* Get index by ID.
|
|
2297
|
+
*
|
|
2298
|
+
* @param {string} databaseId - Database ID.
|
|
2299
|
+
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
2300
|
+
* @param {string} key - Index Key.
|
|
2301
|
+
* @throws {AppwriteException}
|
|
2302
|
+
* @returns {Promise<Models.Index>}
|
|
2303
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
2304
|
+
*/
|
|
2305
|
+
getIndex(databaseId: string, collectionId: string, key: string): Promise<Models.Index>;
|
|
2306
|
+
getIndex(
|
|
2307
|
+
paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string,
|
|
2308
|
+
...rest: [(string)?, (string)?]
|
|
2309
|
+
): Promise<Models.Index> {
|
|
2310
|
+
let params: { databaseId: string, collectionId: string, key: string };
|
|
2311
|
+
|
|
2312
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
2313
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string };
|
|
2314
|
+
} else {
|
|
2315
|
+
params = {
|
|
2316
|
+
databaseId: paramsOrFirst as string,
|
|
2317
|
+
collectionId: rest[0] as string,
|
|
2318
|
+
key: rest[1] as string
|
|
2319
|
+
};
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
const databaseId = params.databaseId;
|
|
2323
|
+
const collectionId = params.collectionId;
|
|
2324
|
+
const key = params.key;
|
|
2325
|
+
|
|
2326
|
+
if (typeof databaseId === 'undefined') {
|
|
2327
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
2328
|
+
}
|
|
2329
|
+
if (typeof collectionId === 'undefined') {
|
|
2330
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
2331
|
+
}
|
|
2332
|
+
if (typeof key === 'undefined') {
|
|
2333
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
|
|
2337
|
+
const payload: Payload = {};
|
|
2338
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2339
|
+
|
|
2340
|
+
const apiHeaders: { [header: string]: string } = {
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
return this.client.call(
|
|
2344
|
+
'get',
|
|
2345
|
+
uri,
|
|
2346
|
+
apiHeaders,
|
|
2347
|
+
payload
|
|
2348
|
+
);
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
/**
|
|
2352
|
+
* Delete an index.
|
|
2353
|
+
*
|
|
2354
|
+
* @param {string} params.databaseId - Database ID.
|
|
2355
|
+
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
2356
|
+
* @param {string} params.key - Index Key.
|
|
2357
|
+
* @throws {AppwriteException}
|
|
2358
|
+
* @returns {Promise<{}>}
|
|
2359
|
+
*/
|
|
2360
|
+
deleteIndex(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>;
|
|
2361
|
+
/**
|
|
2362
|
+
* Delete an index.
|
|
2363
|
+
*
|
|
2364
|
+
* @param {string} databaseId - Database ID.
|
|
2365
|
+
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
|
|
2366
|
+
* @param {string} key - Index Key.
|
|
2367
|
+
* @throws {AppwriteException}
|
|
2368
|
+
* @returns {Promise<{}>}
|
|
2369
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
2370
|
+
*/
|
|
2371
|
+
deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}>;
|
|
2372
|
+
deleteIndex(
|
|
2373
|
+
paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string,
|
|
2374
|
+
...rest: [(string)?, (string)?]
|
|
2375
|
+
): Promise<{}> {
|
|
2376
|
+
let params: { databaseId: string, collectionId: string, key: string };
|
|
2377
|
+
|
|
2378
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
2379
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string };
|
|
2380
|
+
} else {
|
|
2381
|
+
params = {
|
|
2382
|
+
databaseId: paramsOrFirst as string,
|
|
2383
|
+
collectionId: rest[0] as string,
|
|
2384
|
+
key: rest[1] as string
|
|
2385
|
+
};
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
const databaseId = params.databaseId;
|
|
2389
|
+
const collectionId = params.collectionId;
|
|
2390
|
+
const key = params.key;
|
|
2391
|
+
|
|
2392
|
+
if (typeof databaseId === 'undefined') {
|
|
2393
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
2394
|
+
}
|
|
2395
|
+
if (typeof collectionId === 'undefined') {
|
|
2396
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
2397
|
+
}
|
|
2398
|
+
if (typeof key === 'undefined') {
|
|
2399
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
|
|
2403
|
+
const payload: Payload = {};
|
|
2404
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2405
|
+
|
|
2406
|
+
const apiHeaders: { [header: string]: string } = {
|
|
2407
|
+
'content-type': 'application/json',
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
return this.client.call(
|
|
2411
|
+
'delete',
|
|
2412
|
+
uri,
|
|
2413
|
+
apiHeaders,
|
|
2414
|
+
payload
|
|
2415
|
+
);
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
/**
|
|
2419
|
+
* Get the collection activity logs list by its unique ID.
|
|
2420
|
+
*
|
|
2421
|
+
* @param {string} params.databaseId - Database ID.
|
|
2422
|
+
* @param {string} params.collectionId - Collection ID.
|
|
2423
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset
|
|
2424
|
+
* @throws {AppwriteException}
|
|
2425
|
+
* @returns {Promise<Models.LogList>}
|
|
2426
|
+
*/
|
|
2427
|
+
listCollectionLogs(params: { databaseId: string, collectionId: string, queries?: string[] }): Promise<Models.LogList>;
|
|
2428
|
+
/**
|
|
2429
|
+
* Get the collection activity logs list by its unique ID.
|
|
2430
|
+
*
|
|
2431
|
+
* @param {string} databaseId - Database ID.
|
|
2432
|
+
* @param {string} collectionId - Collection ID.
|
|
2433
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset
|
|
2434
|
+
* @throws {AppwriteException}
|
|
2435
|
+
* @returns {Promise<Models.LogList>}
|
|
2436
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
2437
|
+
*/
|
|
2438
|
+
listCollectionLogs(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.LogList>;
|
|
2439
|
+
listCollectionLogs(
|
|
2440
|
+
paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[] } | string,
|
|
2441
|
+
...rest: [(string)?, (string[])?]
|
|
2442
|
+
): Promise<Models.LogList> {
|
|
2443
|
+
let params: { databaseId: string, collectionId: string, queries?: string[] };
|
|
2444
|
+
|
|
2445
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
2446
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[] };
|
|
2447
|
+
} else {
|
|
2448
|
+
params = {
|
|
2449
|
+
databaseId: paramsOrFirst as string,
|
|
2450
|
+
collectionId: rest[0] as string,
|
|
2451
|
+
queries: rest[1] as string[]
|
|
2452
|
+
};
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
const databaseId = params.databaseId;
|
|
2456
|
+
const collectionId = params.collectionId;
|
|
2457
|
+
const queries = params.queries;
|
|
2458
|
+
|
|
2459
|
+
if (typeof databaseId === 'undefined') {
|
|
2460
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
2461
|
+
}
|
|
2462
|
+
if (typeof collectionId === 'undefined') {
|
|
2463
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/logs'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
2467
|
+
const payload: Payload = {};
|
|
2468
|
+
if (typeof queries !== 'undefined') {
|
|
2469
|
+
payload['queries'] = queries;
|
|
2470
|
+
}
|
|
2471
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2472
|
+
|
|
2473
|
+
const apiHeaders: { [header: string]: string } = {
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
return this.client.call(
|
|
2477
|
+
'get',
|
|
2478
|
+
uri,
|
|
2479
|
+
apiHeaders,
|
|
2480
|
+
payload
|
|
2481
|
+
);
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
/**
|
|
2485
|
+
* Get usage metrics and statistics for a collection. Returning the total number of documents. The response includes both current totals and historical data over time. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, range defaults to 30 days.
|
|
2486
|
+
*
|
|
2487
|
+
* @param {string} params.databaseId - Database ID.
|
|
2488
|
+
* @param {string} params.collectionId - Collection ID.
|
|
2489
|
+
* @param {UsageRange} params.range - Date range.
|
|
2490
|
+
* @throws {AppwriteException}
|
|
2491
|
+
* @returns {Promise<Models.UsageCollection>}
|
|
2492
|
+
*/
|
|
2493
|
+
getCollectionUsage(params: { databaseId: string, collectionId: string, range?: UsageRange }): Promise<Models.UsageCollection>;
|
|
2494
|
+
/**
|
|
2495
|
+
* Get usage metrics and statistics for a collection. Returning the total number of documents. The response includes both current totals and historical data over time. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, range defaults to 30 days.
|
|
2496
|
+
*
|
|
2497
|
+
* @param {string} databaseId - Database ID.
|
|
2498
|
+
* @param {string} collectionId - Collection ID.
|
|
2499
|
+
* @param {UsageRange} range - Date range.
|
|
2500
|
+
* @throws {AppwriteException}
|
|
2501
|
+
* @returns {Promise<Models.UsageCollection>}
|
|
2502
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
2503
|
+
*/
|
|
2504
|
+
getCollectionUsage(databaseId: string, collectionId: string, range?: UsageRange): Promise<Models.UsageCollection>;
|
|
2505
|
+
getCollectionUsage(
|
|
2506
|
+
paramsOrFirst: { databaseId: string, collectionId: string, range?: UsageRange } | string,
|
|
2507
|
+
...rest: [(string)?, (UsageRange)?]
|
|
2508
|
+
): Promise<Models.UsageCollection> {
|
|
2509
|
+
let params: { databaseId: string, collectionId: string, range?: UsageRange };
|
|
2510
|
+
|
|
2511
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
2512
|
+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, range?: UsageRange };
|
|
2513
|
+
} else {
|
|
2514
|
+
params = {
|
|
2515
|
+
databaseId: paramsOrFirst as string,
|
|
2516
|
+
collectionId: rest[0] as string,
|
|
2517
|
+
range: rest[1] as UsageRange
|
|
2518
|
+
};
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
const databaseId = params.databaseId;
|
|
2522
|
+
const collectionId = params.collectionId;
|
|
2523
|
+
const range = params.range;
|
|
2524
|
+
|
|
2525
|
+
if (typeof databaseId === 'undefined') {
|
|
2526
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
2527
|
+
}
|
|
2528
|
+
if (typeof collectionId === 'undefined') {
|
|
2529
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/usage'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
2533
|
+
const payload: Payload = {};
|
|
2534
|
+
if (typeof range !== 'undefined') {
|
|
2535
|
+
payload['range'] = range;
|
|
2536
|
+
}
|
|
2537
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2538
|
+
|
|
2539
|
+
const apiHeaders: { [header: string]: string } = {
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
return this.client.call(
|
|
2543
|
+
'get',
|
|
2544
|
+
uri,
|
|
2545
|
+
apiHeaders,
|
|
2546
|
+
payload
|
|
2547
|
+
);
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
/**
|
|
2551
|
+
* Get usage metrics and statistics for a database. You can view the total number of collections, documents, and storage usage. The response includes both current totals and historical data over time. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, range defaults to 30 days.
|
|
2552
|
+
*
|
|
2553
|
+
* @param {string} params.databaseId - Database ID.
|
|
2554
|
+
* @param {UsageRange} params.range - Date range.
|
|
2555
|
+
* @throws {AppwriteException}
|
|
2556
|
+
* @returns {Promise<Models.UsageDocumentsDB>}
|
|
2557
|
+
*/
|
|
2558
|
+
getUsage(params: { databaseId: string, range?: UsageRange }): Promise<Models.UsageDocumentsDB>;
|
|
2559
|
+
/**
|
|
2560
|
+
* Get usage metrics and statistics for a database. You can view the total number of collections, documents, and storage usage. The response includes both current totals and historical data over time. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, range defaults to 30 days.
|
|
2561
|
+
*
|
|
2562
|
+
* @param {string} databaseId - Database ID.
|
|
2563
|
+
* @param {UsageRange} range - Date range.
|
|
2564
|
+
* @throws {AppwriteException}
|
|
2565
|
+
* @returns {Promise<Models.UsageDocumentsDB>}
|
|
2566
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
2567
|
+
*/
|
|
2568
|
+
getUsage(databaseId: string, range?: UsageRange): Promise<Models.UsageDocumentsDB>;
|
|
2569
|
+
getUsage(
|
|
2570
|
+
paramsOrFirst: { databaseId: string, range?: UsageRange } | string,
|
|
2571
|
+
...rest: [(UsageRange)?]
|
|
2572
|
+
): Promise<Models.UsageDocumentsDB> {
|
|
2573
|
+
let params: { databaseId: string, range?: UsageRange };
|
|
2574
|
+
|
|
2575
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
2576
|
+
params = (paramsOrFirst || {}) as { databaseId: string, range?: UsageRange };
|
|
2577
|
+
} else {
|
|
2578
|
+
params = {
|
|
2579
|
+
databaseId: paramsOrFirst as string,
|
|
2580
|
+
range: rest[0] as UsageRange
|
|
2581
|
+
};
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
const databaseId = params.databaseId;
|
|
2585
|
+
const range = params.range;
|
|
2586
|
+
|
|
2587
|
+
if (typeof databaseId === 'undefined') {
|
|
2588
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
const apiPath = '/documentsdb/{databaseId}/usage'.replace('{databaseId}', databaseId);
|
|
2592
|
+
const payload: Payload = {};
|
|
2593
|
+
if (typeof range !== 'undefined') {
|
|
2594
|
+
payload['range'] = range;
|
|
2595
|
+
}
|
|
2596
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2597
|
+
|
|
2598
|
+
const apiHeaders: { [header: string]: string } = {
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
return this.client.call(
|
|
2602
|
+
'get',
|
|
2603
|
+
uri,
|
|
2604
|
+
apiHeaders,
|
|
2605
|
+
payload
|
|
2606
|
+
);
|
|
2607
|
+
}
|
|
2608
|
+
}
|