react-native-appwrite 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -3
- package/dist/cjs/sdk.js +1854 -1121
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +1854 -1122
- package/dist/esm/sdk.js.map +1 -1
- package/docs/examples/account/create-email-password-session.md +4 -4
- package/docs/examples/account/create-email-token.md +5 -5
- package/docs/examples/account/{create-magic-u-r-l-token.md → create-magic-url-token.md} +6 -6
- package/docs/examples/account/create-mfa-authenticator.md +3 -3
- package/docs/examples/account/create-mfa-challenge.md +3 -3
- package/docs/examples/account/create-mfa-recovery-codes.md +1 -1
- package/docs/examples/account/{create-o-auth2token.md → create-o-auth-2-session.md} +6 -6
- package/docs/examples/account/{create-o-auth2session.md → create-o-auth-2-token.md} +6 -6
- package/docs/examples/account/create-phone-token.md +4 -4
- package/docs/examples/account/create-push-target.md +5 -5
- package/docs/examples/account/create-recovery.md +4 -4
- package/docs/examples/account/create-session.md +4 -4
- package/docs/examples/account/create-verification.md +3 -3
- package/docs/examples/account/create.md +6 -6
- package/docs/examples/account/delete-identity.md +3 -3
- package/docs/examples/account/delete-mfa-authenticator.md +3 -3
- package/docs/examples/account/delete-push-target.md +3 -3
- package/docs/examples/account/delete-session.md +3 -3
- package/docs/examples/account/get-mfa-recovery-codes.md +1 -1
- package/docs/examples/account/get-session.md +3 -3
- package/docs/examples/account/list-identities.md +3 -3
- package/docs/examples/account/list-logs.md +3 -3
- package/docs/examples/account/list-mfa-factors.md +1 -1
- package/docs/examples/account/update-email.md +4 -4
- package/docs/examples/account/{update-magic-u-r-l-session.md → update-magic-url-session.md} +4 -4
- package/docs/examples/account/update-mfa-authenticator.md +4 -4
- package/docs/examples/account/update-mfa-challenge.md +4 -4
- package/docs/examples/account/update-mfa-recovery-codes.md +1 -1
- package/docs/examples/account/{update-m-f-a.md → update-mfa.md} +3 -3
- package/docs/examples/account/update-name.md +3 -3
- package/docs/examples/account/update-password.md +4 -4
- package/docs/examples/account/update-phone-session.md +4 -4
- package/docs/examples/account/update-phone-verification.md +4 -4
- package/docs/examples/account/update-phone.md +4 -4
- package/docs/examples/account/update-prefs.md +7 -3
- package/docs/examples/account/update-push-target.md +4 -4
- package/docs/examples/account/update-recovery.md +5 -5
- package/docs/examples/account/update-session.md +3 -3
- package/docs/examples/account/update-verification.md +4 -4
- package/docs/examples/avatars/get-browser.md +6 -6
- package/docs/examples/avatars/get-credit-card.md +6 -6
- package/docs/examples/avatars/get-favicon.md +3 -3
- package/docs/examples/avatars/get-flag.md +6 -6
- package/docs/examples/avatars/get-image.md +5 -5
- package/docs/examples/avatars/get-initials.md +6 -6
- package/docs/examples/avatars/{get-q-r.md → get-qr.md} +6 -6
- package/docs/examples/databases/create-document.md +13 -7
- package/docs/examples/databases/decrement-document-attribute.md +8 -8
- package/docs/examples/databases/delete-document.md +5 -5
- package/docs/examples/databases/get-document.md +6 -6
- package/docs/examples/databases/increment-document-attribute.md +8 -8
- package/docs/examples/databases/list-documents.md +5 -5
- package/docs/examples/databases/update-document.md +7 -7
- package/docs/examples/databases/upsert-document.md +7 -7
- package/docs/examples/functions/create-execution.md +9 -9
- package/docs/examples/functions/get-execution.md +4 -4
- package/docs/examples/functions/list-executions.md +4 -4
- package/docs/examples/graphql/mutation.md +3 -3
- package/docs/examples/graphql/query.md +3 -3
- package/docs/examples/messaging/create-subscriber.md +5 -5
- package/docs/examples/messaging/delete-subscriber.md +4 -4
- package/docs/examples/storage/create-file.md +6 -6
- package/docs/examples/storage/delete-file.md +4 -4
- package/docs/examples/storage/get-file-download.md +5 -5
- package/docs/examples/storage/get-file-preview.md +16 -16
- package/docs/examples/storage/get-file-view.md +5 -5
- package/docs/examples/storage/get-file.md +4 -4
- package/docs/examples/storage/list-files.md +5 -5
- package/docs/examples/storage/update-file.md +6 -6
- package/docs/examples/tablesdb/create-row.md +23 -0
- package/docs/examples/tablesdb/decrement-row-column.md +18 -0
- package/docs/examples/tablesdb/delete-row.md +15 -0
- package/docs/examples/tablesdb/get-row.md +16 -0
- package/docs/examples/tablesdb/increment-row-column.md +18 -0
- package/docs/examples/tablesdb/list-rows.md +15 -0
- package/docs/examples/tablesdb/update-row.md +17 -0
- package/docs/examples/tablesdb/upsert-row.md +17 -0
- package/docs/examples/teams/create-membership.md +9 -9
- package/docs/examples/teams/create.md +5 -5
- package/docs/examples/teams/delete-membership.md +4 -4
- package/docs/examples/teams/delete.md +3 -3
- package/docs/examples/teams/get-membership.md +4 -4
- package/docs/examples/teams/get-prefs.md +3 -3
- package/docs/examples/teams/get.md +3 -3
- package/docs/examples/teams/list-memberships.md +5 -5
- package/docs/examples/teams/list.md +4 -4
- package/docs/examples/teams/update-membership-status.md +6 -6
- package/docs/examples/teams/update-membership.md +5 -5
- package/docs/examples/teams/update-name.md +4 -4
- package/docs/examples/teams/update-prefs.md +4 -4
- package/package.json +1 -1
- package/src/client.ts +2 -2
- package/src/enums/credit-card.ts +1 -1
- package/src/enums/execution-method.ts +1 -0
- package/src/index.ts +1 -0
- package/src/models.ts +72 -27
- package/src/query.ts +247 -4
- package/src/services/account.ts +1469 -315
- package/src/services/avatars.ts +289 -80
- package/src/services/databases.ts +345 -63
- package/src/services/functions.ts +115 -20
- package/src/services/graphql.ts +52 -4
- package/src/services/locale.ts +8 -19
- package/src/services/messaging.ts +66 -7
- package/src/services/storage.ts +345 -76
- package/src/services/tables-db.ts +621 -0
- package/src/services/teams.ts +454 -93
- package/types/enums/credit-card.d.ts +1 -1
- package/types/enums/execution-method.d.ts +2 -1
- package/types/index.d.ts +1 -0
- package/types/models.d.ts +69 -25
- package/types/query.d.ts +201 -4
- package/types/services/account.d.ts +734 -280
- package/types/services/avatars.d.ts +168 -73
- package/types/services/databases.d.ts +199 -58
- package/types/services/functions.d.ts +62 -17
- package/types/services/graphql.d.ts +24 -2
- package/types/services/locale.d.ts +8 -19
- package/types/services/messaging.d.ts +33 -5
- package/types/services/storage.d.ts +201 -68
- package/types/services/tables-db.d.ts +245 -0
- package/types/services/teams.d.ts +242 -80
- /package/docs/examples/account/{create-j-w-t.md → create-jwt.md} +0 -0
- /package/docs/examples/locale/{list-countries-e-u.md → list-countries-eu.md} +0 -0
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
import { Service } from '../service';
|
|
2
|
+
import { AppwriteException, Client } from '../client';
|
|
3
|
+
import type { Models } from '../models';
|
|
4
|
+
import type { UploadProgress, Payload } from '../client';
|
|
5
|
+
import * as FileSystem from 'expo-file-system';
|
|
6
|
+
import { Platform } from 'react-native';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export class TablesDB extends Service {
|
|
10
|
+
|
|
11
|
+
constructor(client: Client)
|
|
12
|
+
{
|
|
13
|
+
super(client);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get a list of all the user's rows in a given table. You can use the query params to filter your results.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} params.databaseId - Database ID.
|
|
20
|
+
* @param {string} params.tableId - Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate).
|
|
21
|
+
* @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.
|
|
22
|
+
* @throws {AppwriteException}
|
|
23
|
+
* @returns {Promise}
|
|
24
|
+
*/
|
|
25
|
+
listRows<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, queries?: string[] }): Promise<Models.RowList<Row>>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a list of all the user's rows in a given table. You can use the query params to filter your results.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} databaseId - Database ID.
|
|
30
|
+
* @param {string} tableId - Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate).
|
|
31
|
+
* @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.
|
|
32
|
+
* @throws {AppwriteException}
|
|
33
|
+
* @returns {Promise<Models.RowList<Row>>}
|
|
34
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
35
|
+
*/
|
|
36
|
+
listRows<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, queries?: string[]): Promise<Models.RowList<Row>>;
|
|
37
|
+
listRows<Row extends Models.Row = Models.DefaultRow>(
|
|
38
|
+
paramsOrFirst: { databaseId: string, tableId: string, queries?: string[] } | string,
|
|
39
|
+
...rest: [(string)?, (string[])?]
|
|
40
|
+
): Promise<Models.RowList<Row>> {
|
|
41
|
+
let params: { databaseId: string, tableId: string, queries?: string[] };
|
|
42
|
+
|
|
43
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
44
|
+
params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[] };
|
|
45
|
+
} else {
|
|
46
|
+
params = {
|
|
47
|
+
databaseId: paramsOrFirst as string,
|
|
48
|
+
tableId: rest[0] as string,
|
|
49
|
+
queries: rest[1] as string[]
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const databaseId = params.databaseId;
|
|
54
|
+
const tableId = params.tableId;
|
|
55
|
+
const queries = params.queries;
|
|
56
|
+
|
|
57
|
+
if (typeof databaseId === 'undefined') {
|
|
58
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (typeof tableId === 'undefined') {
|
|
62
|
+
throw new AppwriteException('Missing required parameter: "tableId"');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId);
|
|
66
|
+
const payload: Payload = {};
|
|
67
|
+
|
|
68
|
+
if (typeof queries !== 'undefined') {
|
|
69
|
+
payload['queries'] = queries;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
73
|
+
return this.client.call('get', uri, {
|
|
74
|
+
}, payload);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} params.databaseId - Database ID.
|
|
81
|
+
* @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows.
|
|
82
|
+
* @param {string} params.rowId - Row 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.
|
|
83
|
+
* @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} params.data - Row data as JSON object.
|
|
84
|
+
* @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).
|
|
85
|
+
* @throws {AppwriteException}
|
|
86
|
+
* @returns {Promise}
|
|
87
|
+
*/
|
|
88
|
+
createRow<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[] }): Promise<Row>;
|
|
89
|
+
/**
|
|
90
|
+
* Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console.
|
|
91
|
+
*
|
|
92
|
+
* @param {string} databaseId - Database ID.
|
|
93
|
+
* @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows.
|
|
94
|
+
* @param {string} rowId - Row 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.
|
|
95
|
+
* @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} data - Row data as JSON object.
|
|
96
|
+
* @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).
|
|
97
|
+
* @throws {AppwriteException}
|
|
98
|
+
* @returns {Promise<Row>}
|
|
99
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
100
|
+
*/
|
|
101
|
+
createRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[]): Promise<Row>;
|
|
102
|
+
createRow<Row extends Models.Row = Models.DefaultRow>(
|
|
103
|
+
paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[] } | string,
|
|
104
|
+
...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>)?, (string[])?]
|
|
105
|
+
): Promise<Row> {
|
|
106
|
+
let params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[] };
|
|
107
|
+
|
|
108
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
109
|
+
params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[] };
|
|
110
|
+
} else {
|
|
111
|
+
params = {
|
|
112
|
+
databaseId: paramsOrFirst as string,
|
|
113
|
+
tableId: rest[0] as string,
|
|
114
|
+
rowId: rest[1] as string,
|
|
115
|
+
data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>,
|
|
116
|
+
permissions: rest[3] as string[]
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const databaseId = params.databaseId;
|
|
121
|
+
const tableId = params.tableId;
|
|
122
|
+
const rowId = params.rowId;
|
|
123
|
+
const data = params.data;
|
|
124
|
+
const permissions = params.permissions;
|
|
125
|
+
|
|
126
|
+
if (typeof databaseId === 'undefined') {
|
|
127
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (typeof tableId === 'undefined') {
|
|
131
|
+
throw new AppwriteException('Missing required parameter: "tableId"');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (typeof rowId === 'undefined') {
|
|
135
|
+
throw new AppwriteException('Missing required parameter: "rowId"');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (typeof data === 'undefined') {
|
|
139
|
+
throw new AppwriteException('Missing required parameter: "data"');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId);
|
|
143
|
+
const payload: Payload = {};
|
|
144
|
+
|
|
145
|
+
if (typeof rowId !== 'undefined') {
|
|
146
|
+
payload['rowId'] = rowId;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (typeof data !== 'undefined') {
|
|
150
|
+
payload['data'] = data;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (typeof permissions !== 'undefined') {
|
|
154
|
+
payload['permissions'] = permissions;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
158
|
+
return this.client.call('post', uri, {
|
|
159
|
+
'content-type': 'application/json',
|
|
160
|
+
}, payload);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Get a row by its unique ID. This endpoint response returns a JSON object with the row data.
|
|
165
|
+
*
|
|
166
|
+
* @param {string} params.databaseId - Database ID.
|
|
167
|
+
* @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
|
|
168
|
+
* @param {string} params.rowId - Row ID.
|
|
169
|
+
* @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.
|
|
170
|
+
* @throws {AppwriteException}
|
|
171
|
+
* @returns {Promise}
|
|
172
|
+
*/
|
|
173
|
+
getRow<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, queries?: string[] }): Promise<Row>;
|
|
174
|
+
/**
|
|
175
|
+
* Get a row by its unique ID. This endpoint response returns a JSON object with the row data.
|
|
176
|
+
*
|
|
177
|
+
* @param {string} databaseId - Database ID.
|
|
178
|
+
* @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
|
|
179
|
+
* @param {string} rowId - Row ID.
|
|
180
|
+
* @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.
|
|
181
|
+
* @throws {AppwriteException}
|
|
182
|
+
* @returns {Promise<Row>}
|
|
183
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
184
|
+
*/
|
|
185
|
+
getRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, queries?: string[]): Promise<Row>;
|
|
186
|
+
getRow<Row extends Models.Row = Models.DefaultRow>(
|
|
187
|
+
paramsOrFirst: { databaseId: string, tableId: string, rowId: string, queries?: string[] } | string,
|
|
188
|
+
...rest: [(string)?, (string)?, (string[])?]
|
|
189
|
+
): Promise<Row> {
|
|
190
|
+
let params: { databaseId: string, tableId: string, rowId: string, queries?: string[] };
|
|
191
|
+
|
|
192
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
193
|
+
params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, queries?: string[] };
|
|
194
|
+
} else {
|
|
195
|
+
params = {
|
|
196
|
+
databaseId: paramsOrFirst as string,
|
|
197
|
+
tableId: rest[0] as string,
|
|
198
|
+
rowId: rest[1] as string,
|
|
199
|
+
queries: rest[2] as string[]
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const databaseId = params.databaseId;
|
|
204
|
+
const tableId = params.tableId;
|
|
205
|
+
const rowId = params.rowId;
|
|
206
|
+
const queries = params.queries;
|
|
207
|
+
|
|
208
|
+
if (typeof databaseId === 'undefined') {
|
|
209
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (typeof tableId === 'undefined') {
|
|
213
|
+
throw new AppwriteException('Missing required parameter: "tableId"');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (typeof rowId === 'undefined') {
|
|
217
|
+
throw new AppwriteException('Missing required parameter: "rowId"');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId);
|
|
221
|
+
const payload: Payload = {};
|
|
222
|
+
|
|
223
|
+
if (typeof queries !== 'undefined') {
|
|
224
|
+
payload['queries'] = queries;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
228
|
+
return this.client.call('get', uri, {
|
|
229
|
+
}, payload);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console.
|
|
234
|
+
*
|
|
235
|
+
* @param {string} params.databaseId - Database ID.
|
|
236
|
+
* @param {string} params.tableId - Table ID.
|
|
237
|
+
* @param {string} params.rowId - Row ID.
|
|
238
|
+
* @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include all required columns of the row to be created or updated.
|
|
239
|
+
* @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).
|
|
240
|
+
* @throws {AppwriteException}
|
|
241
|
+
* @returns {Promise}
|
|
242
|
+
*/
|
|
243
|
+
upsertRow<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] }): Promise<Row>;
|
|
244
|
+
/**
|
|
245
|
+
* Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console.
|
|
246
|
+
*
|
|
247
|
+
* @param {string} databaseId - Database ID.
|
|
248
|
+
* @param {string} tableId - Table ID.
|
|
249
|
+
* @param {string} rowId - Row ID.
|
|
250
|
+
* @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include all required columns of the row to be created or updated.
|
|
251
|
+
* @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
252
|
+
* @throws {AppwriteException}
|
|
253
|
+
* @returns {Promise<Row>}
|
|
254
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
255
|
+
*/
|
|
256
|
+
upsertRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[]): Promise<Row>;
|
|
257
|
+
upsertRow<Row extends Models.Row = Models.DefaultRow>(
|
|
258
|
+
paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] } | string,
|
|
259
|
+
...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, (string[])?]
|
|
260
|
+
): Promise<Row> {
|
|
261
|
+
let params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] };
|
|
262
|
+
|
|
263
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
264
|
+
params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] };
|
|
265
|
+
} else {
|
|
266
|
+
params = {
|
|
267
|
+
databaseId: paramsOrFirst as string,
|
|
268
|
+
tableId: rest[0] as string,
|
|
269
|
+
rowId: rest[1] as string,
|
|
270
|
+
data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>,
|
|
271
|
+
permissions: rest[3] as string[]
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const databaseId = params.databaseId;
|
|
276
|
+
const tableId = params.tableId;
|
|
277
|
+
const rowId = params.rowId;
|
|
278
|
+
const data = params.data;
|
|
279
|
+
const permissions = params.permissions;
|
|
280
|
+
|
|
281
|
+
if (typeof databaseId === 'undefined') {
|
|
282
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (typeof tableId === 'undefined') {
|
|
286
|
+
throw new AppwriteException('Missing required parameter: "tableId"');
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (typeof rowId === 'undefined') {
|
|
290
|
+
throw new AppwriteException('Missing required parameter: "rowId"');
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId);
|
|
294
|
+
const payload: Payload = {};
|
|
295
|
+
|
|
296
|
+
if (typeof data !== 'undefined') {
|
|
297
|
+
payload['data'] = data;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (typeof permissions !== 'undefined') {
|
|
301
|
+
payload['permissions'] = permissions;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
305
|
+
return this.client.call('put', uri, {
|
|
306
|
+
'content-type': 'application/json',
|
|
307
|
+
}, payload);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated.
|
|
312
|
+
*
|
|
313
|
+
* @param {string} params.databaseId - Database ID.
|
|
314
|
+
* @param {string} params.tableId - Table ID.
|
|
315
|
+
* @param {string} params.rowId - Row ID.
|
|
316
|
+
* @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include only columns and value pairs to be updated.
|
|
317
|
+
* @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).
|
|
318
|
+
* @throws {AppwriteException}
|
|
319
|
+
* @returns {Promise}
|
|
320
|
+
*/
|
|
321
|
+
updateRow<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] }): Promise<Row>;
|
|
322
|
+
/**
|
|
323
|
+
* Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated.
|
|
324
|
+
*
|
|
325
|
+
* @param {string} databaseId - Database ID.
|
|
326
|
+
* @param {string} tableId - Table ID.
|
|
327
|
+
* @param {string} rowId - Row ID.
|
|
328
|
+
* @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include only columns and value pairs to be updated.
|
|
329
|
+
* @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
330
|
+
* @throws {AppwriteException}
|
|
331
|
+
* @returns {Promise<Row>}
|
|
332
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
333
|
+
*/
|
|
334
|
+
updateRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[]): Promise<Row>;
|
|
335
|
+
updateRow<Row extends Models.Row = Models.DefaultRow>(
|
|
336
|
+
paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] } | string,
|
|
337
|
+
...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, (string[])?]
|
|
338
|
+
): Promise<Row> {
|
|
339
|
+
let params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] };
|
|
340
|
+
|
|
341
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
342
|
+
params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] };
|
|
343
|
+
} else {
|
|
344
|
+
params = {
|
|
345
|
+
databaseId: paramsOrFirst as string,
|
|
346
|
+
tableId: rest[0] as string,
|
|
347
|
+
rowId: rest[1] as string,
|
|
348
|
+
data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>,
|
|
349
|
+
permissions: rest[3] as string[]
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const databaseId = params.databaseId;
|
|
354
|
+
const tableId = params.tableId;
|
|
355
|
+
const rowId = params.rowId;
|
|
356
|
+
const data = params.data;
|
|
357
|
+
const permissions = params.permissions;
|
|
358
|
+
|
|
359
|
+
if (typeof databaseId === 'undefined') {
|
|
360
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (typeof tableId === 'undefined') {
|
|
364
|
+
throw new AppwriteException('Missing required parameter: "tableId"');
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (typeof rowId === 'undefined') {
|
|
368
|
+
throw new AppwriteException('Missing required parameter: "rowId"');
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId);
|
|
372
|
+
const payload: Payload = {};
|
|
373
|
+
|
|
374
|
+
if (typeof data !== 'undefined') {
|
|
375
|
+
payload['data'] = data;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (typeof permissions !== 'undefined') {
|
|
379
|
+
payload['permissions'] = permissions;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
383
|
+
return this.client.call('patch', uri, {
|
|
384
|
+
'content-type': 'application/json',
|
|
385
|
+
}, payload);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Delete a row by its unique ID.
|
|
390
|
+
*
|
|
391
|
+
* @param {string} params.databaseId - Database ID.
|
|
392
|
+
* @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
|
|
393
|
+
* @param {string} params.rowId - Row ID.
|
|
394
|
+
* @throws {AppwriteException}
|
|
395
|
+
* @returns {Promise}
|
|
396
|
+
*/
|
|
397
|
+
deleteRow(params: { databaseId: string, tableId: string, rowId: string }): Promise<{}>;
|
|
398
|
+
/**
|
|
399
|
+
* Delete a row by its unique ID.
|
|
400
|
+
*
|
|
401
|
+
* @param {string} databaseId - Database ID.
|
|
402
|
+
* @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
|
|
403
|
+
* @param {string} rowId - Row ID.
|
|
404
|
+
* @throws {AppwriteException}
|
|
405
|
+
* @returns {Promise<{}>}
|
|
406
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
407
|
+
*/
|
|
408
|
+
deleteRow(databaseId: string, tableId: string, rowId: string): Promise<{}>;
|
|
409
|
+
deleteRow(
|
|
410
|
+
paramsOrFirst: { databaseId: string, tableId: string, rowId: string } | string,
|
|
411
|
+
...rest: [(string)?, (string)?]
|
|
412
|
+
): Promise<{}> {
|
|
413
|
+
let params: { databaseId: string, tableId: string, rowId: string };
|
|
414
|
+
|
|
415
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
416
|
+
params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string };
|
|
417
|
+
} else {
|
|
418
|
+
params = {
|
|
419
|
+
databaseId: paramsOrFirst as string,
|
|
420
|
+
tableId: rest[0] as string,
|
|
421
|
+
rowId: rest[1] as string
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const databaseId = params.databaseId;
|
|
426
|
+
const tableId = params.tableId;
|
|
427
|
+
const rowId = params.rowId;
|
|
428
|
+
|
|
429
|
+
if (typeof databaseId === 'undefined') {
|
|
430
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (typeof tableId === 'undefined') {
|
|
434
|
+
throw new AppwriteException('Missing required parameter: "tableId"');
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (typeof rowId === 'undefined') {
|
|
438
|
+
throw new AppwriteException('Missing required parameter: "rowId"');
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId);
|
|
442
|
+
const payload: Payload = {};
|
|
443
|
+
|
|
444
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
445
|
+
return this.client.call('delete', uri, {
|
|
446
|
+
'content-type': 'application/json',
|
|
447
|
+
}, payload);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Decrement a specific column of a row by a given value.
|
|
452
|
+
*
|
|
453
|
+
* @param {string} params.databaseId - Database ID.
|
|
454
|
+
* @param {string} params.tableId - Table ID.
|
|
455
|
+
* @param {string} params.rowId - Row ID.
|
|
456
|
+
* @param {string} params.column - Column key.
|
|
457
|
+
* @param {number} params.value - Value to increment the column by. The value must be a number.
|
|
458
|
+
* @param {number} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.
|
|
459
|
+
* @throws {AppwriteException}
|
|
460
|
+
* @returns {Promise}
|
|
461
|
+
*/
|
|
462
|
+
decrementRowColumn<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number }): Promise<Row>;
|
|
463
|
+
/**
|
|
464
|
+
* Decrement a specific column of a row by a given value.
|
|
465
|
+
*
|
|
466
|
+
* @param {string} databaseId - Database ID.
|
|
467
|
+
* @param {string} tableId - Table ID.
|
|
468
|
+
* @param {string} rowId - Row ID.
|
|
469
|
+
* @param {string} column - Column key.
|
|
470
|
+
* @param {number} value - Value to increment the column by. The value must be a number.
|
|
471
|
+
* @param {number} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.
|
|
472
|
+
* @throws {AppwriteException}
|
|
473
|
+
* @returns {Promise<Row>}
|
|
474
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
475
|
+
*/
|
|
476
|
+
decrementRowColumn<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number): Promise<Row>;
|
|
477
|
+
decrementRowColumn<Row extends Models.Row = Models.DefaultRow>(
|
|
478
|
+
paramsOrFirst: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number } | string,
|
|
479
|
+
...rest: [(string)?, (string)?, (string)?, (number)?, (number)?]
|
|
480
|
+
): Promise<Row> {
|
|
481
|
+
let params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number };
|
|
482
|
+
|
|
483
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
484
|
+
params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number };
|
|
485
|
+
} else {
|
|
486
|
+
params = {
|
|
487
|
+
databaseId: paramsOrFirst as string,
|
|
488
|
+
tableId: rest[0] as string,
|
|
489
|
+
rowId: rest[1] as string,
|
|
490
|
+
column: rest[2] as string,
|
|
491
|
+
value: rest[3] as number,
|
|
492
|
+
min: rest[4] as number
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
const databaseId = params.databaseId;
|
|
497
|
+
const tableId = params.tableId;
|
|
498
|
+
const rowId = params.rowId;
|
|
499
|
+
const column = params.column;
|
|
500
|
+
const value = params.value;
|
|
501
|
+
const min = params.min;
|
|
502
|
+
|
|
503
|
+
if (typeof databaseId === 'undefined') {
|
|
504
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (typeof tableId === 'undefined') {
|
|
508
|
+
throw new AppwriteException('Missing required parameter: "tableId"');
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (typeof rowId === 'undefined') {
|
|
512
|
+
throw new AppwriteException('Missing required parameter: "rowId"');
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if (typeof column === 'undefined') {
|
|
516
|
+
throw new AppwriteException('Missing required parameter: "column"');
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId).replace('{column}', column);
|
|
520
|
+
const payload: Payload = {};
|
|
521
|
+
|
|
522
|
+
if (typeof value !== 'undefined') {
|
|
523
|
+
payload['value'] = value;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (typeof min !== 'undefined') {
|
|
527
|
+
payload['min'] = min;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
531
|
+
return this.client.call('patch', uri, {
|
|
532
|
+
'content-type': 'application/json',
|
|
533
|
+
}, payload);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Increment a specific column of a row by a given value.
|
|
538
|
+
*
|
|
539
|
+
* @param {string} params.databaseId - Database ID.
|
|
540
|
+
* @param {string} params.tableId - Table ID.
|
|
541
|
+
* @param {string} params.rowId - Row ID.
|
|
542
|
+
* @param {string} params.column - Column key.
|
|
543
|
+
* @param {number} params.value - Value to increment the column by. The value must be a number.
|
|
544
|
+
* @param {number} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown.
|
|
545
|
+
* @throws {AppwriteException}
|
|
546
|
+
* @returns {Promise}
|
|
547
|
+
*/
|
|
548
|
+
incrementRowColumn<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number }): Promise<Row>;
|
|
549
|
+
/**
|
|
550
|
+
* Increment a specific column of a row by a given value.
|
|
551
|
+
*
|
|
552
|
+
* @param {string} databaseId - Database ID.
|
|
553
|
+
* @param {string} tableId - Table ID.
|
|
554
|
+
* @param {string} rowId - Row ID.
|
|
555
|
+
* @param {string} column - Column key.
|
|
556
|
+
* @param {number} value - Value to increment the column by. The value must be a number.
|
|
557
|
+
* @param {number} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown.
|
|
558
|
+
* @throws {AppwriteException}
|
|
559
|
+
* @returns {Promise<Row>}
|
|
560
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
561
|
+
*/
|
|
562
|
+
incrementRowColumn<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number): Promise<Row>;
|
|
563
|
+
incrementRowColumn<Row extends Models.Row = Models.DefaultRow>(
|
|
564
|
+
paramsOrFirst: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number } | string,
|
|
565
|
+
...rest: [(string)?, (string)?, (string)?, (number)?, (number)?]
|
|
566
|
+
): Promise<Row> {
|
|
567
|
+
let params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number };
|
|
568
|
+
|
|
569
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
570
|
+
params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number };
|
|
571
|
+
} else {
|
|
572
|
+
params = {
|
|
573
|
+
databaseId: paramsOrFirst as string,
|
|
574
|
+
tableId: rest[0] as string,
|
|
575
|
+
rowId: rest[1] as string,
|
|
576
|
+
column: rest[2] as string,
|
|
577
|
+
value: rest[3] as number,
|
|
578
|
+
max: rest[4] as number
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
const databaseId = params.databaseId;
|
|
583
|
+
const tableId = params.tableId;
|
|
584
|
+
const rowId = params.rowId;
|
|
585
|
+
const column = params.column;
|
|
586
|
+
const value = params.value;
|
|
587
|
+
const max = params.max;
|
|
588
|
+
|
|
589
|
+
if (typeof databaseId === 'undefined') {
|
|
590
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if (typeof tableId === 'undefined') {
|
|
594
|
+
throw new AppwriteException('Missing required parameter: "tableId"');
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
if (typeof rowId === 'undefined') {
|
|
598
|
+
throw new AppwriteException('Missing required parameter: "rowId"');
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (typeof column === 'undefined') {
|
|
602
|
+
throw new AppwriteException('Missing required parameter: "column"');
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId).replace('{column}', column);
|
|
606
|
+
const payload: Payload = {};
|
|
607
|
+
|
|
608
|
+
if (typeof value !== 'undefined') {
|
|
609
|
+
payload['value'] = value;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
if (typeof max !== 'undefined') {
|
|
613
|
+
payload['max'] = max;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
617
|
+
return this.client.call('patch', uri, {
|
|
618
|
+
'content-type': 'application/json',
|
|
619
|
+
}, payload);
|
|
620
|
+
}
|
|
621
|
+
};
|