forked from kibertoad/objection-find-query
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
197 lines (176 loc) · 4.5 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/* Type definitions for objection-find-query-builder */
/* Version 1.9.0 */
/* Definitions by: Paul Hart https://github.com/valtari1h */
export interface Builder {
/**
* @function
* @param {string} field
* @param value
* @returns {Builder}
*/
equal(field: string, value: any): Builder;
/**
* Retrieve specified relationships for the found entity eagerly
*
* @function
* @param {string} relationships
* @returns {Builder}
*/
eager(relationships: string[]): Builder;
/**
* Retrieves entries where the specified field is in the given set of values
*
* @function
* @param {string} field
* @param {string[]} values
* @returns {Builder}
*/
inSet(field: string, values: string[]): Builder;
/**
* Retrieves entries that have any of the specified fields matching specified value with optional wildcards
*
* @function
* @param {string[]} fields - Fields for search that will be combined by OR operator
* @param {string} value - Value to search for. Supports wildcards, e. g. `'%Gump%'` or `'%ump'`
* @returns {Builder}
*/
anyLike(fields: string[], value: string): Builder;
/**
* Retrieves entries that have any of the specified fields matching specified value with optional wildcards
* case insensitively
*
* @function
* @param {string[]} fields - Fields for search that will be combined by OR operator
* @param {string} value - Value to search for. Supports wildcards, e. g. `'%Gump%'` or `'%ump'`
* @returns {Builder}
*/
anyLikeLower(fields: string[], value: string): Builder;
/**
* Group the result set by the unique values of the specified entry fields
*
* @function
* @param {string[]} fields
* @returns {Builder}
*/
groupBy(fields: string[]): Builder;
/**
* @function
* @param {string} field
* @param value
* @returns {Builder}
*/
greaterThan(field: string, value: any): Builder;
/**
* @function
* @param {string} field
* @param value
* @returns {Builder}
*/
greaterThanOrEqual(field: string, value: any): Builder;
/**
* @function
* @param {string} field
* @param value
* @returns {Builder}
*/
lessThan(field: string, value: any): Builder;
/**
* @function
* @param {string} field
* @param value
* @returns {Builder}
*/
lessThanOrEqual(field: string, value: any): Builder;
/**
* Specifies the beginning boundary of the result set
*
* @function
* @param {number} value
* @returns {Builder}
*/
rangeStart(value: number): Builder;
/**
* Specifies the ending boundary of the result set
*
* @function
* @param {number} value
* @returns {Builder}
*/
rangeEnd(value: number): Builder;
/**
* Count the unique values of the specified fields.
* The result set must be previously grouped by all the fields passed as parameters to this function
*
* @function
* @param {string[]} fields
* @returns {Builder}
*/
count(fields: string[]): Builder;
/**
* @function
* @param {string} field
* @returns {Builder}
*/
orderByAsc(field: string): Builder;
/**
* @function
* @param {string} field
* @returns {Builder}
*/
orderByDesc(field: string): Builder;
/**
* Builds the query into a plain object
*
* @function
* @param {string} prefix - Optional query parameter prefix for readability
* @returns {object}
*/
build(prefix?: string): object;
}
/**
* Creates a new instance of object-find-query-builder
*
* @function
* @returns {Builder}
*/
export function builder(): Builder;
/**
* @namespace
*/
export namespace eagerUtils {
/**
* @function
* @param {string} eager
* @returns {string[]}
*/
export function getElements(eager: string): string[];
/**
* Adds additional eager relationships to existing relationship string
*
* @function
* @param {string} eager - Existing `eager` relationship string
* @param {string[]} newParams - Eager relationships to add to the eager string
*/
export function appendToEagerParam(eager: string, newParams: string[]): string;
/**
* @function
* @param {string} eager - Existing `eager` relationship string
* @param {string[]} removeParams - Eager relationships to remove from the eager string
* @returns {string}
*/
export function removeFromEagerParam(eager: string, removeParams: string[]): string;
}
/**
* @namespace
*/
export namespace formatter {
/**
* Generates query params from given parameter tree (see README.md for format details)
*
* @function
* @param {object} fieldTree
* @param {string} prefix
* @returns {object}
*/
export function format(fieldTree: object, prefix: string): object;
}