1 | // Copyright IBM Corp. 2018. All Rights Reserved.
|
2 | // Node module: loopback-datasource-juggler
|
3 | // This file is licensed under the MIT License.
|
4 | // License text available at https://opensource.org/licenses/MIT
|
5 |
|
6 | /**
|
7 | * Operators for where clauses
|
8 | */
|
9 | export declare enum Operators {
|
10 | /**
|
11 | * Equal operator (=)
|
12 | */
|
13 | eq = 'eq',
|
14 | /**
|
15 | * Not equal operator (!=)
|
16 | */
|
17 | neq = 'neq',
|
18 | /**
|
19 | * Greater than operator (>)
|
20 | */
|
21 | gt = 'gt',
|
22 | /**
|
23 | * Greater than or equal operator (>=)
|
24 | */
|
25 | gte = 'gte',
|
26 | /**
|
27 | * Less than operator (<)
|
28 | */
|
29 | lt = 'lt',
|
30 | /**
|
31 | * Less than or equal (<=)
|
32 | */
|
33 | lte = 'lte',
|
34 | /**
|
35 | * IN operator. For example, `{type: {inq: ['a', 'b', 'c']}}`
|
36 | */
|
37 | inq = 'inq',
|
38 | /**
|
39 | * Between operator. For example, `{age: {between: [18, 40]}}`
|
40 | */
|
41 | between = 'between',
|
42 | /**
|
43 | * Exists operator
|
44 | */
|
45 | exists = 'exists',
|
46 | /**
|
47 | * AND operator
|
48 | */
|
49 | and = 'and',
|
50 | /**
|
51 | * OR operator
|
52 | */
|
53 | or = 'or',
|
54 | }
|
55 |
|
56 | /**
|
57 | * Matching criteria
|
58 | */
|
59 | export interface Condition {
|
60 | eq?: any;
|
61 | neq?: any;
|
62 | gt?: any;
|
63 | gte?: any;
|
64 | lt?: any;
|
65 | lte?: any;
|
66 | inq?: any[];
|
67 | between?: any[];
|
68 | exists?: boolean;
|
69 | and?: Where[];
|
70 | or?: Where[];
|
71 | }
|
72 |
|
73 | /**
|
74 | * Where object
|
75 | */
|
76 | export interface Where {
|
77 | and?: Where[]; // AND
|
78 | or?: Where[]; // OR
|
79 | [property: string]: Condition | any;
|
80 | }
|
81 |
|
82 | /**
|
83 | * Selection of fields
|
84 | */
|
85 | export interface Fields {
|
86 | [property: string]: boolean;
|
87 | }
|
88 |
|
89 | /**
|
90 | * Inclusion of related items
|
91 | */
|
92 | export interface Inclusion {
|
93 | relation: string;
|
94 | scope?: Filter;
|
95 | }
|
96 |
|
97 | /**
|
98 | * Query filter object
|
99 | */
|
100 | export interface Filter {
|
101 | where?: Where;
|
102 | fields?: string | string[] | Fields;
|
103 | order?: string | string[];
|
104 | limit?: number;
|
105 | skip?: number;
|
106 | offset?: number;
|
107 | include?: string | string[] | Inclusion[];
|
108 | }
|