Skip to content

Commit 8a5d716

Browse files
authored
Merge pull request #136 from appwrite/dev
Add time between queries
2 parents f4f0f16 + f6b6421 commit 8a5d716

File tree

13 files changed

+186
-30
lines changed

13 files changed

+186
-30
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { Client, Account } from "appwrite";
3333
To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:
3434

3535
```html
36-
<script src="https://cdn.jsdelivr.net/npm/appwrite@19.0.0"></script>
36+
<script src="https://cdn.jsdelivr.net/npm/appwrite@20.0.0"></script>
3737
```
3838

3939

docs/examples/account/update-prefs.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ const client = new Client()
77
const account = new Account(client);
88

99
const result = await account.updatePrefs({
10-
prefs: {}
10+
prefs: {
11+
"language": "en",
12+
"timezone": "UTC",
13+
"darkTheme": true
14+
}
1115
});
1216

1317
console.log(result);

docs/examples/databases/create-document.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ const result = await databases.createDocument({
1010
databaseId: '<DATABASE_ID>',
1111
collectionId: '<COLLECTION_ID>',
1212
documentId: '<DOCUMENT_ID>',
13-
data: {},
13+
data: {
14+
"username": "walter.obrien",
15+
"email": "[email protected]",
16+
"fullName": "Walter O'Brien",
17+
"age": 30,
18+
"isAdmin": false
19+
},
1420
permissions: ["read("any")"] // optional
1521
});
1622

docs/examples/tablesdb/create-row.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ const result = await tablesDB.createRow({
1010
databaseId: '<DATABASE_ID>',
1111
tableId: '<TABLE_ID>',
1212
rowId: '<ROW_ID>',
13-
data: {},
13+
data: {
14+
"username": "walter.obrien",
15+
"email": "[email protected]",
16+
"fullName": "Walter O'Brien",
17+
"age": 30,
18+
"isAdmin": false
19+
},
1420
permissions: ["read("any")"] // optional
1521
});
1622

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "appwrite",
33
"homepage": "https://appwrite.io/support",
44
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5-
"version": "19.0.0",
5+
"version": "20.0.0",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {

src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class Client {
316316
'x-sdk-name': 'Web',
317317
'x-sdk-platform': 'client',
318318
'x-sdk-language': 'web',
319-
'x-sdk-version': '19.0.0',
319+
'x-sdk-version': '20.0.0',
320320
'X-Appwrite-Response-Format': '1.8.0',
321321
};
322322

src/enums/credit-card.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export enum CreditCard {
1111
Mastercard = 'mastercard',
1212
Naranja = 'naranja',
1313
TarjetaShopping = 'targeta-shopping',
14-
UnionChinaPay = 'union-china-pay',
14+
UnionPay = 'unionpay',
1515
Visa = 'visa',
1616
MIR = 'mir',
1717
Maestro = 'maestro',

src/enums/execution-method.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export enum ExecutionMethod {
55
PATCH = 'PATCH',
66
DELETE = 'DELETE',
77
OPTIONS = 'OPTIONS',
8+
HEAD = 'HEAD',
89
}

src/query.ts

Lines changed: 156 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
type QueryTypesSingle = string | number | boolean;
2-
export type QueryTypesList = string[] | number[] | boolean[] | Query[];
2+
export type QueryTypesList = string[] | number[] | boolean[] | Query[] | any[];
33
export type QueryTypes = QueryTypesSingle | QueryTypesList;
44
type AttributesTypes = string | string[];
55

@@ -52,20 +52,20 @@ export class Query {
5252
* Filter resources where attribute is equal to value.
5353
*
5454
* @param {string} attribute
55-
* @param {QueryTypes} value
55+
* @param {QueryTypes | any[]} value
5656
* @returns {string}
5757
*/
58-
static equal = (attribute: string, value: QueryTypes): string =>
58+
static equal = (attribute: string, value: QueryTypes | any[]): string =>
5959
new Query("equal", attribute, value).toString();
6060

6161
/**
6262
* Filter resources where attribute is not equal to value.
6363
*
6464
* @param {string} attribute
65-
* @param {QueryTypes} value
65+
* @param {QueryTypes | any[]} value
6666
* @returns {string}
6767
*/
68-
static notEqual = (attribute: string, value: QueryTypes): string =>
68+
static notEqual = (attribute: string, value: QueryTypes | any[]): string =>
6969
new Query("notEqual", attribute, value).toString();
7070

7171
/**
@@ -238,17 +238,17 @@ export class Query {
238238
* @param {string | string[]} value
239239
* @returns {string}
240240
*/
241-
static contains = (attribute: string, value: string | string[]): string =>
241+
static contains = (attribute: string, value: string | any[]): string =>
242242
new Query("contains", attribute, value).toString();
243243

244244
/**
245245
* Filter resources where attribute does not contain the specified value.
246246
*
247247
* @param {string} attribute
248-
* @param {string | string[]} value
248+
* @param {string | any[]} value
249249
* @returns {string}
250250
*/
251-
static notContains = (attribute: string, value: string | string[]): string =>
251+
static notContains = (attribute: string, value: string | any[]): string =>
252252
new Query("notContains", attribute, value).toString();
253253

254254
/**
@@ -311,6 +311,16 @@ export class Query {
311311
static createdAfter = (value: string): string =>
312312
new Query("createdAfter", undefined, value).toString();
313313

314+
/**
315+
* Filter resources where document was created between dates.
316+
*
317+
* @param {string} start
318+
* @param {string} end
319+
* @returns {string}
320+
*/
321+
static createdBetween = (start: string, end: string): string =>
322+
new Query("createdBetween", undefined, [start, end] as QueryTypesList).toString();
323+
314324
/**
315325
* Filter resources where document was updated before date.
316326
*
@@ -329,6 +339,16 @@ export class Query {
329339
static updatedAfter = (value: string): string =>
330340
new Query("updatedAfter", undefined, value).toString();
331341

342+
/**
343+
* Filter resources where document was updated between dates.
344+
*
345+
* @param {string} start
346+
* @param {string} end
347+
* @returns {string}
348+
*/
349+
static updatedBetween = (start: string, end: string): string =>
350+
new Query("updatedBetween", undefined, [start, end] as QueryTypesList).toString();
351+
332352
/**
333353
* Combine multiple queries using logical OR operator.
334354
*
@@ -346,4 +366,132 @@ export class Query {
346366
*/
347367
static and = (queries: string[]) =>
348368
new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString();
369+
370+
/**
371+
* Filter resources where attribute is at a specific distance from the given coordinates.
372+
*
373+
* @param {string} attribute
374+
* @param {any[]} values
375+
* @param {number} distance
376+
* @param {boolean} meters
377+
* @returns {string}
378+
*/
379+
static distanceEqual = (attribute: string, values: any[], distance: number, meters: boolean = true): string =>
380+
new Query("distanceEqual", attribute, [[values, distance, meters]] as QueryTypesList).toString();
381+
382+
/**
383+
* Filter resources where attribute is not at a specific distance from the given coordinates.
384+
*
385+
* @param {string} attribute
386+
* @param {any[]} values
387+
* @param {number} distance
388+
* @param {boolean} meters
389+
* @returns {string}
390+
*/
391+
static distanceNotEqual = (attribute: string, values: any[], distance: number, meters: boolean = true): string =>
392+
new Query("distanceNotEqual", attribute, [[values, distance, meters]] as QueryTypesList).toString();
393+
394+
/**
395+
* Filter resources where attribute is at a distance greater than the specified value from the given coordinates.
396+
*
397+
* @param {string} attribute
398+
* @param {any[]} values
399+
* @param {number} distance
400+
* @param {boolean} meters
401+
* @returns {string}
402+
*/
403+
static distanceGreaterThan = (attribute: string, values: any[], distance: number, meters: boolean = true): string =>
404+
new Query("distanceGreaterThan", attribute, [[values, distance, meters]] as QueryTypesList).toString();
405+
406+
/**
407+
* Filter resources where attribute is at a distance less than the specified value from the given coordinates.
408+
*
409+
* @param {string} attribute
410+
* @param {any[]} values
411+
* @param {number} distance
412+
* @param {boolean} meters
413+
* @returns {string}
414+
*/
415+
static distanceLessThan = (attribute: string, values: any[], distance: number, meters: boolean = true): string =>
416+
new Query("distanceLessThan", attribute, [[values, distance, meters]] as QueryTypesList).toString();
417+
418+
/**
419+
* Filter resources where attribute intersects with the given geometry.
420+
*
421+
* @param {string} attribute
422+
* @param {any[]} values
423+
* @returns {string}
424+
*/
425+
static intersects = (attribute: string, values: any[]): string =>
426+
new Query("intersects", attribute, [values]).toString();
427+
428+
/**
429+
* Filter resources where attribute does not intersect with the given geometry.
430+
*
431+
* @param {string} attribute
432+
* @param {any[]} values
433+
* @returns {string}
434+
*/
435+
static notIntersects = (attribute: string, values: any[]): string =>
436+
new Query("notIntersects", attribute, [values]).toString();
437+
438+
/**
439+
* Filter resources where attribute crosses the given geometry.
440+
*
441+
* @param {string} attribute
442+
* @param {any[]} values
443+
* @returns {string}
444+
*/
445+
static crosses = (attribute: string, values: any[]): string =>
446+
new Query("crosses", attribute, [values]).toString();
447+
448+
/**
449+
* Filter resources where attribute does not cross the given geometry.
450+
*
451+
* @param {string} attribute
452+
* @param {any[]} values
453+
* @returns {string}
454+
*/
455+
static notCrosses = (attribute: string, values: any[]): string =>
456+
new Query("notCrosses", attribute, [values]).toString();
457+
458+
/**
459+
* Filter resources where attribute overlaps with the given geometry.
460+
*
461+
* @param {string} attribute
462+
* @param {any[]} values
463+
* @returns {string}
464+
*/
465+
static overlaps = (attribute: string, values: any[]): string =>
466+
new Query("overlaps", attribute, [values]).toString();
467+
468+
/**
469+
* Filter resources where attribute does not overlap with the given geometry.
470+
*
471+
* @param {string} attribute
472+
* @param {any[]} values
473+
* @returns {string}
474+
*/
475+
static notOverlaps = (attribute: string, values: any[]): string =>
476+
new Query("notOverlaps", attribute, [values]).toString();
477+
478+
/**
479+
* Filter resources where attribute touches the given geometry.
480+
*
481+
* @param {string} attribute
482+
* @param {any[]} values
483+
* @returns {string}
484+
*/
485+
static touches = (attribute: string, values: any[]): string =>
486+
new Query("touches", attribute, [values]).toString();
487+
488+
/**
489+
* Filter resources where attribute does not touch the given geometry.
490+
*
491+
* @param {string} attribute
492+
* @param {any[]} values
493+
* @returns {string}
494+
*/
495+
static notTouches = (attribute: string, values: any[]): string =>
496+
new Query("notTouches", attribute, [values]).toString();
349497
}

src/services/account.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,7 @@ export class Account {
17511751
* @param {string} params.secret - Valid verification token.
17521752
* @throws {AppwriteException}
17531753
* @returns {Promise<Models.Session>}
1754-
* @deprecated This API has been deprecated.
1754+
* @deprecated This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.
17551755
*/
17561756
updateMagicURLSession(params: { userId: string, secret: string }): Promise<Models.Session>;
17571757
/**
@@ -1907,7 +1907,7 @@ export class Account {
19071907
* @param {string} params.secret - Valid verification token.
19081908
* @throws {AppwriteException}
19091909
* @returns {Promise<Models.Session>}
1910-
* @deprecated This API has been deprecated.
1910+
* @deprecated This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.
19111911
*/
19121912
updatePhoneSession(params: { userId: string, secret: string }): Promise<Models.Session>;
19131913
/**

0 commit comments

Comments
 (0)