MCPcopy Index your code
hub / github.com/appwrite/sdk-for-react-native / Query

Class Query

src/query.ts:9–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7type AttributesTypes = string | string[];
8
9export class Query {
10 method: string;
11 attribute: AttributesTypes | undefined;
12 values: QueryTypesList | undefined;
13
14 constructor(
15 method: string,
16 attribute?: AttributesTypes,
17 values?: QueryTypes
18 ) {
19 this.method = method;
20 this.attribute = attribute;
21
22 if (values !== undefined) {
23 if (Array.isArray(values)) {
24 this.values = values;
25 } else {
26 this.values = [values] as QueryTypesList;
27 }
28 }
29 }
30
31 toString(): string {
32 return JSONbig.stringify({
33 method: this.method,
34 attribute: this.attribute,
35 values: this.values,
36 });
37 }
38
39 static equal = (attribute: string, value: QueryTypes): string =>
40 new Query("equal", attribute, value).toString();
41
42 static notEqual = (attribute: string, value: QueryTypes): string =>
43 new Query("notEqual", attribute, value).toString();
44
45 /**
46 * Filter resources where attribute matches a regular expression pattern.
47 *
48 * @param {string} attribute The attribute to filter on.
49 * @param {string} pattern The regular expression pattern to match.
50 * @returns {string}
51 */
52 static regex = (attribute: string, pattern: string): string =>
53 new Query("regex", attribute, pattern).toString();
54
55 static lessThan = (attribute: string, value: QueryTypes): string =>
56 new Query("lessThan", attribute, value).toString();
57
58 static lessThanEqual = (attribute: string, value: QueryTypes): string =>
59 new Query("lessThanEqual", attribute, value).toString();
60
61 static greaterThan = (attribute: string, value: QueryTypes): string =>
62 new Query("greaterThan", attribute, value).toString();
63
64 static greaterThanEqual = (attribute: string, value: QueryTypes): string =>
65 new Query("greaterThanEqual", attribute, value).toString();
66

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected