prostgles-server 4.2.180 → 4.2.182
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 +48 -52
- package/dist/DBSchemaBuilder.d.ts +2 -2
- package/dist/DBSchemaBuilder.d.ts.map +1 -1
- package/dist/DBSchemaBuilder.js +34 -26
- package/dist/DBSchemaBuilder.js.map +1 -1
- package/dist/DboBuilder/getColumns.d.ts.map +1 -1
- package/dist/DboBuilder/getColumns.js +41 -16
- package/dist/DboBuilder/getColumns.js.map +1 -1
- package/dist/Prostgles.d.ts.map +1 -1
- package/dist/Prostgles.js +1 -2
- package/dist/Prostgles.js.map +1 -1
- package/dist/ProstglesTypes.d.ts +7 -5
- package/dist/ProstglesTypes.d.ts.map +1 -1
- package/dist/initProstgles.js +12 -12
- package/dist/initProstgles.js.map +1 -1
- package/dist/typeTests/dboTypeCheck.d.ts.map +1 -1
- package/dist/typeTests/dboTypeCheck.js +11 -11
- package/dist/typeTests/dboTypeCheck.js.map +1 -1
- package/documentation/METHODS.md +1467 -0
- package/documentation/SERVER.md +6 -7
- package/documentation/utils/clientTypes.ts +8602 -2623
- package/documentation/utils/dist/clientTypes.d.ts +7307 -1801
- package/documentation/utils/dist/clientTypes.d.ts.map +1 -1
- package/documentation/utils/dist/clientTypes.js +8602 -2623
- package/documentation/utils/dist/generateClientDocs.d.ts +0 -1
- package/documentation/utils/dist/generateClientDocs.d.ts.map +1 -1
- package/documentation/utils/dist/generateClientDocs.js +85 -35
- package/documentation/utils/dist/generateServerDocs.d.ts.map +1 -1
- package/documentation/utils/dist/generateServerDocs.js +11 -10
- package/documentation/utils/dist/getResolvedTypes.js +1 -1
- package/documentation/utils/dist/getSerializableType.d.ts +1 -1
- package/documentation/utils/dist/getSerializableType.d.ts.map +1 -1
- package/documentation/utils/dist/getSerializableType.js +29 -23
- package/documentation/utils/dist/loadTsFile.d.ts.map +1 -1
- package/documentation/utils/dist/loadTsFile.js +0 -4
- package/documentation/utils/dist/serverTypes.d.ts +3 -9
- package/documentation/utils/dist/serverTypes.d.ts.map +1 -1
- package/documentation/utils/dist/serverTypes.js +3 -9
- package/documentation/utils/generateClientDocs.ts +99 -31
- package/documentation/utils/generateServerDocs.ts +12 -10
- package/documentation/utils/getSerializableType.ts +13 -3
- package/documentation/utils/loadTsFile.ts +0 -4
- package/documentation/utils/serverTypes.ts +3 -9
- package/documentation/utils/tsconfig.json +2 -2
- package/lib/DBSchemaBuilder.ts +148 -118
- package/lib/DboBuilder/getColumns.ts +63 -31
- package/lib/Prostgles.ts +1 -2
- package/lib/ProstglesTypes.ts +7 -4
- package/lib/initProstgles.ts +50 -51
- package/lib/typeTests/DBoGenerated.d.ts +23 -19
- package/lib/typeTests/dboTypeCheck.ts +49 -35
- package/package.json +4 -3
- package/documentation/CLIENT.md +0 -542
|
@@ -0,0 +1,1467 @@
|
|
|
1
|
+
# Isomorphic Methods
|
|
2
|
+
|
|
3
|
+
The following methods are available on the client and server.
|
|
4
|
+
|
|
5
|
+
## getInfo<span style="opacity: 0.6;">(lang?: string): Promise<TableInfo></span>
|
|
6
|
+
Retrieves the table/view info
|
|
7
|
+
```typescript
|
|
8
|
+
getInfo: ():
|
|
9
|
+
```
|
|
10
|
+
#### Parameters
|
|
11
|
+
|
|
12
|
+
- **lang**: `string`
|
|
13
|
+
|
|
14
|
+
Language code for i18n data. "en" by default
|
|
15
|
+
#### `TableInfo`
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
- **oid**: `number`
|
|
19
|
+
|
|
20
|
+
OID from the postgres database
|
|
21
|
+
Useful in handling renamed tables
|
|
22
|
+
- **comment**: `string`
|
|
23
|
+
|
|
24
|
+
Comment from the postgres database
|
|
25
|
+
- **isFileTable**: `FileTableConfig`
|
|
26
|
+
|
|
27
|
+
Defined if this is the fileTable
|
|
28
|
+
- **allowedNestedInserts**: `{ table: string; column: string; }`
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
- **table**: `string`
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
- **column**: `string`
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
- **hasFiles**: `false`
|
|
38
|
+
|
|
39
|
+
True if fileTable is enabled and this table references the fileTable
|
|
40
|
+
Used in UI
|
|
41
|
+
- **isView**: `false`
|
|
42
|
+
|
|
43
|
+
True if this is a view.
|
|
44
|
+
Table methods (insert, update, delete) are undefined for views
|
|
45
|
+
- **fileTableName**: `string`
|
|
46
|
+
|
|
47
|
+
Name of the fileTable (if enabled)
|
|
48
|
+
Used in UI
|
|
49
|
+
- **dynamicRules**: `{ update?: boolean | undefined; }`
|
|
50
|
+
|
|
51
|
+
Used for getColumns in cases where the columns are dynamic based on the request.
|
|
52
|
+
See dynamicFields from Update rules
|
|
53
|
+
- **update**: `false`
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
- **info**: `{ label?: string | undefined; }`
|
|
57
|
+
|
|
58
|
+
Additional table info provided through TableConfig
|
|
59
|
+
- **label**: `string`
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
- **uniqueColumnGroups**: `string[][] | undefined`
|
|
63
|
+
|
|
64
|
+
List of unique column indexes/constraints.
|
|
65
|
+
Column groups where at least a column is not allowed to be viewed (selected) are omitted.
|
|
66
|
+
|
|
67
|
+
## getColumns<span style="opacity: 0.6;">(lang?: string, params?: GetColumnsParams): Promise<ValidatedColumnInfo[]></span>
|
|
68
|
+
Retrieves columns metadata of the table/view
|
|
69
|
+
```typescript
|
|
70
|
+
getColumns: ():
|
|
71
|
+
```
|
|
72
|
+
#### Parameters
|
|
73
|
+
|
|
74
|
+
- **lang**: `string`
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
- **params**: `GetColumnsParams`
|
|
78
|
+
|
|
79
|
+
Dynamic/filter based rules allow limit what columns can be updated based on the request data/filter
|
|
80
|
+
This allows parameter allows identifying the columns that can be updated based on the request data
|
|
81
|
+
- **rule**: `"update"`
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
- **data**: `AnyObject`
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
- **filter**: `FullFilter`
|
|
89
|
+
|
|
90
|
+
Data filter
|
|
91
|
+
- `{ status: 'live' }`
|
|
92
|
+
- `{ $or: [{ id: 1 }, { status: 'live' }] }`
|
|
93
|
+
- `{ $existsJoined: { referencedTable: { id: 1 } } }`
|
|
94
|
+
- `{
|
|
95
|
+
$filter: [
|
|
96
|
+
{ $age: ["created_at"] },
|
|
97
|
+
"<",
|
|
98
|
+
'1 year'
|
|
99
|
+
]
|
|
100
|
+
}`
|
|
101
|
+
#### `ValidatedColumnInfo`
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
- **name**: `string`
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
- **label**: `string`
|
|
108
|
+
|
|
109
|
+
Column display name. Will be first non empty value from i18n data, comment, name
|
|
110
|
+
- **comment**: `string | undefined`
|
|
111
|
+
|
|
112
|
+
Column description (if provided)
|
|
113
|
+
- **ordinal_position**: `number`
|
|
114
|
+
|
|
115
|
+
Ordinal position of the column within the table (count starts at 1)
|
|
116
|
+
- **is_nullable**: `boolean`
|
|
117
|
+
|
|
118
|
+
True if column is nullable
|
|
119
|
+
- **is_updatable**: `boolean`
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
- **is_generated**: `boolean`
|
|
123
|
+
|
|
124
|
+
If the column is a generated column (converted to boolean from ALWAYS and NEVER)
|
|
125
|
+
- **data_type**: `string`
|
|
126
|
+
|
|
127
|
+
Simplified data type
|
|
128
|
+
- **udt_name**: `PG_COLUMN_UDT_DATA_TYPE`
|
|
129
|
+
|
|
130
|
+
Postgres data type name.
|
|
131
|
+
Array types start with an underscore
|
|
132
|
+
- **element_type**: `string | undefined`
|
|
133
|
+
|
|
134
|
+
Element data type
|
|
135
|
+
- **element_udt_name**: `string | undefined`
|
|
136
|
+
|
|
137
|
+
Element data type name
|
|
138
|
+
- **is_pkey**: `boolean`
|
|
139
|
+
|
|
140
|
+
PRIMARY KEY constraint on column.
|
|
141
|
+
A table can have a multi column primary key
|
|
142
|
+
- **references**: `ReferenceTable`
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
- **ftable**: `string`
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
- **fcols**: `string`
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
- **cols**: `string`
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
- **has_default**: `boolean`
|
|
155
|
+
|
|
156
|
+
true if column has a default value
|
|
157
|
+
Used for excluding pkey from insert
|
|
158
|
+
- **column_default**: `any`
|
|
159
|
+
|
|
160
|
+
Column default value
|
|
161
|
+
- **min**: `string | number | undefined`
|
|
162
|
+
|
|
163
|
+
Extracted from tableConfig
|
|
164
|
+
Used in SmartForm
|
|
165
|
+
- **max**: `string | number | undefined`
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
- **hint**: `string`
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
- **jsonbSchema**: `JSONBSchema`
|
|
172
|
+
|
|
173
|
+
JSONB schema (a simplified version of json schema) for the column (if defined in the tableConfig)
|
|
174
|
+
A check constraint will use this schema for runtime data validation and apropriate TS types will be generated
|
|
175
|
+
- **nullable**: `any`
|
|
176
|
+
|
|
177
|
+
False by default
|
|
178
|
+
- **description**: `any`
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
- **title**: `any`
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
- **type**: `any`
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
- **allowedValues**: `any`
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
- **oneOf**: `any`
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
- **oneOfType**: `any`
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
- **arrayOf**: `any`
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
- **arrayOfType**: `any`
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
- **enum**: `any`
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
- **record**: `any`
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
- **lookup**: `any`
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
- **defaultValue**: `any`
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
- **file**: `FileColumnConfig | undefined`
|
|
215
|
+
|
|
216
|
+
If degined then this column is referencing the file table
|
|
217
|
+
Extracted from FileTable config
|
|
218
|
+
Used in SmartForm
|
|
219
|
+
- **tsDataType**: `"string" | "number" | "boolean" | "any" | "number[]" | "boolean[]" | "string[]" | "any[]"`
|
|
220
|
+
|
|
221
|
+
TypeScript data type
|
|
222
|
+
- **select**: `boolean`
|
|
223
|
+
|
|
224
|
+
Can be viewed/selected
|
|
225
|
+
Based on access rules and postgres policies
|
|
226
|
+
- **orderBy**: `boolean`
|
|
227
|
+
|
|
228
|
+
Can be ordered by
|
|
229
|
+
Based on access rules
|
|
230
|
+
- **filter**: `boolean`
|
|
231
|
+
|
|
232
|
+
Can be filtered by
|
|
233
|
+
Based on access rules
|
|
234
|
+
- **insert**: `boolean`
|
|
235
|
+
|
|
236
|
+
Can be inserted
|
|
237
|
+
Based on access rules and postgres policies
|
|
238
|
+
- **update**: `boolean`
|
|
239
|
+
|
|
240
|
+
Can be updated
|
|
241
|
+
Based on access rules and postgres policies
|
|
242
|
+
- **delete**: `boolean`
|
|
243
|
+
|
|
244
|
+
Can be used in the delete filter
|
|
245
|
+
Based on access rules
|
|
246
|
+
|
|
247
|
+
## find<span style="opacity: 0.6;">(filter?: undefined | ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): Promise<GetSelectReturnType<S, P, T, true>></span>
|
|
248
|
+
Retrieves a list of matching records from the view/table
|
|
249
|
+
```typescript
|
|
250
|
+
find: ():
|
|
251
|
+
```
|
|
252
|
+
#### Parameters
|
|
253
|
+
|
|
254
|
+
- **filter**: `FullFilter<T, S> | undefined`
|
|
255
|
+
|
|
256
|
+
Filter to apply. Undefined will return all records
|
|
257
|
+
- { "field": "value" }
|
|
258
|
+
- { "field": { $in: ["value", "value2"] } }
|
|
259
|
+
- { $or: [
|
|
260
|
+
{ "field1": "value" },
|
|
261
|
+
{ "field2": "value" }
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
- { $existsJoined: { linkedTable: { "linkedTableField": "value" } } }
|
|
265
|
+
- **selectParams**: `SelectParams`
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
- **limit**: `number | null | undefined`
|
|
269
|
+
|
|
270
|
+
Max number of rows to return. Defaults to 1000
|
|
271
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
272
|
+
- **offset**: `number`
|
|
273
|
+
|
|
274
|
+
Number of rows to skip
|
|
275
|
+
- **groupBy**: `false`
|
|
276
|
+
|
|
277
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
278
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
279
|
+
|
|
280
|
+
Result data structure/type:
|
|
281
|
+
- **row**: the first row as an object
|
|
282
|
+
- **value**: the first value from of first field
|
|
283
|
+
- **values**: array of values from the selected field
|
|
284
|
+
- **statement**: sql statement
|
|
285
|
+
- **statement-no-rls**: sql statement without row level security
|
|
286
|
+
- **statement-where**: sql statement where condition
|
|
287
|
+
- **select**: `Select`
|
|
288
|
+
|
|
289
|
+
Fields/expressions/linked data to select
|
|
290
|
+
- `"*"` or empty will return all fields
|
|
291
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
292
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
293
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
294
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
295
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
296
|
+
- **orderBy**: `OrderBy`
|
|
297
|
+
|
|
298
|
+
Order by options
|
|
299
|
+
- Order is maintained in arrays
|
|
300
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
301
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
302
|
+
|
|
303
|
+
Filter applied after any aggregations (group by)
|
|
304
|
+
#### `GetSelectReturnType`
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
## findOne<span style="opacity: 0.6;">(filter?: undefined | ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): Promise<GetSelectReturnType<S, P, T, false> | undefined></span>
|
|
309
|
+
Retrieves a record from the view/table
|
|
310
|
+
```typescript
|
|
311
|
+
findOne: ():
|
|
312
|
+
```
|
|
313
|
+
#### Parameters
|
|
314
|
+
|
|
315
|
+
- **filter**: `FullFilter<T, S> | undefined`
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
- **selectParams**: `SelectParams`
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
- **limit**: `number | null | undefined`
|
|
322
|
+
|
|
323
|
+
Max number of rows to return. Defaults to 1000
|
|
324
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
325
|
+
- **offset**: `number`
|
|
326
|
+
|
|
327
|
+
Number of rows to skip
|
|
328
|
+
- **groupBy**: `false`
|
|
329
|
+
|
|
330
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
331
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
332
|
+
|
|
333
|
+
Result data structure/type:
|
|
334
|
+
- **row**: the first row as an object
|
|
335
|
+
- **value**: the first value from of first field
|
|
336
|
+
- **values**: array of values from the selected field
|
|
337
|
+
- **statement**: sql statement
|
|
338
|
+
- **statement-no-rls**: sql statement without row level security
|
|
339
|
+
- **statement-where**: sql statement where condition
|
|
340
|
+
- **select**: `Select`
|
|
341
|
+
|
|
342
|
+
Fields/expressions/linked data to select
|
|
343
|
+
- `"*"` or empty will return all fields
|
|
344
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
345
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
346
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
347
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
348
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
349
|
+
- **orderBy**: `OrderBy`
|
|
350
|
+
|
|
351
|
+
Order by options
|
|
352
|
+
- Order is maintained in arrays
|
|
353
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
354
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
355
|
+
|
|
356
|
+
Filter applied after any aggregations (group by)
|
|
357
|
+
#### `GetSelectReturnType<S, P, T, false> | undefined`
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
## subscribe<span style="opacity: 0.6;">(filter: ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, params: SelectParams, onData: SubscribeCallback, onError?: SubscribeOnError): Promise<SubscriptionHandler></span>
|
|
362
|
+
Retrieves a list of matching records from the view/table and subscribes to changes
|
|
363
|
+
```typescript
|
|
364
|
+
subscribe: ():
|
|
365
|
+
```
|
|
366
|
+
#### Parameters
|
|
367
|
+
|
|
368
|
+
- **filter**: `FullFilter`
|
|
369
|
+
|
|
370
|
+
Data filter
|
|
371
|
+
- `{ status: 'live' }`
|
|
372
|
+
- `{ $or: [{ id: 1 }, { status: 'live' }] }`
|
|
373
|
+
- `{ $existsJoined: { referencedTable: { id: 1 } } }`
|
|
374
|
+
- `{
|
|
375
|
+
$filter: [
|
|
376
|
+
{ $age: ["created_at"] },
|
|
377
|
+
"<",
|
|
378
|
+
'1 year'
|
|
379
|
+
]
|
|
380
|
+
}`
|
|
381
|
+
- **params**: `SelectParams`
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
- **limit**: `number | null | undefined`
|
|
385
|
+
|
|
386
|
+
Max number of rows to return. Defaults to 1000
|
|
387
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
388
|
+
- **offset**: `number`
|
|
389
|
+
|
|
390
|
+
Number of rows to skip
|
|
391
|
+
- **groupBy**: `false`
|
|
392
|
+
|
|
393
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
394
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
395
|
+
|
|
396
|
+
Result data structure/type:
|
|
397
|
+
- **row**: the first row as an object
|
|
398
|
+
- **value**: the first value from of first field
|
|
399
|
+
- **values**: array of values from the selected field
|
|
400
|
+
- **statement**: sql statement
|
|
401
|
+
- **statement-no-rls**: sql statement without row level security
|
|
402
|
+
- **statement-where**: sql statement where condition
|
|
403
|
+
- **select**: `Select`
|
|
404
|
+
|
|
405
|
+
Fields/expressions/linked data to select
|
|
406
|
+
- `"*"` or empty will return all fields
|
|
407
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
408
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
409
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
410
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
411
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
412
|
+
- **orderBy**: `OrderBy`
|
|
413
|
+
|
|
414
|
+
Order by options
|
|
415
|
+
- Order is maintained in arrays
|
|
416
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
417
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
418
|
+
|
|
419
|
+
Filter applied after any aggregations (group by)
|
|
420
|
+
- **onData**: `SubscribeCallback`
|
|
421
|
+
|
|
422
|
+
Callback fired once after subscribing and then every time the data matching the filter changes
|
|
423
|
+
- **onError**: `SubscribeOnError`
|
|
424
|
+
|
|
425
|
+
Error handler that may fire due to schema changes or other post subscribe issues
|
|
426
|
+
Column or filter issues are thrown during the subscribe call
|
|
427
|
+
#### `SubscriptionHandler`
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
- **unsubscribe**: `() => Promise<any>`
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
- **filter**: `{} | FullFilter<void, void>`
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
## subscribeOne<span style="opacity: 0.6;">(filter: ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, params: SelectParams, onData: SubscribeOneCallback, onError?: SubscribeOnError): Promise<SubscriptionHandler></span>
|
|
438
|
+
Retrieves first matching record from the view/table and subscribes to changes
|
|
439
|
+
```typescript
|
|
440
|
+
subscribeOne: ():
|
|
441
|
+
```
|
|
442
|
+
#### Parameters
|
|
443
|
+
|
|
444
|
+
- **filter**: `FullFilter`
|
|
445
|
+
|
|
446
|
+
Data filter
|
|
447
|
+
- `{ status: 'live' }`
|
|
448
|
+
- `{ $or: [{ id: 1 }, { status: 'live' }] }`
|
|
449
|
+
- `{ $existsJoined: { referencedTable: { id: 1 } } }`
|
|
450
|
+
- `{
|
|
451
|
+
$filter: [
|
|
452
|
+
{ $age: ["created_at"] },
|
|
453
|
+
"<",
|
|
454
|
+
'1 year'
|
|
455
|
+
]
|
|
456
|
+
}`
|
|
457
|
+
- **params**: `SelectParams`
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
- **limit**: `number | null | undefined`
|
|
461
|
+
|
|
462
|
+
Max number of rows to return. Defaults to 1000
|
|
463
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
464
|
+
- **offset**: `number`
|
|
465
|
+
|
|
466
|
+
Number of rows to skip
|
|
467
|
+
- **groupBy**: `false`
|
|
468
|
+
|
|
469
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
470
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
471
|
+
|
|
472
|
+
Result data structure/type:
|
|
473
|
+
- **row**: the first row as an object
|
|
474
|
+
- **value**: the first value from of first field
|
|
475
|
+
- **values**: array of values from the selected field
|
|
476
|
+
- **statement**: sql statement
|
|
477
|
+
- **statement-no-rls**: sql statement without row level security
|
|
478
|
+
- **statement-where**: sql statement where condition
|
|
479
|
+
- **select**: `Select`
|
|
480
|
+
|
|
481
|
+
Fields/expressions/linked data to select
|
|
482
|
+
- `"*"` or empty will return all fields
|
|
483
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
484
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
485
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
486
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
487
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
488
|
+
- **orderBy**: `OrderBy`
|
|
489
|
+
|
|
490
|
+
Order by options
|
|
491
|
+
- Order is maintained in arrays
|
|
492
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
493
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
494
|
+
|
|
495
|
+
Filter applied after any aggregations (group by)
|
|
496
|
+
- **onData**: `SubscribeOneCallback`
|
|
497
|
+
|
|
498
|
+
Callback fired once after subscribing and then every time the data matching the filter changes
|
|
499
|
+
- **onError**: `SubscribeOnError`
|
|
500
|
+
|
|
501
|
+
Error handler that may fire due to schema changes or other post subscribe issues
|
|
502
|
+
Column or filter issues are thrown during the subscribe call
|
|
503
|
+
#### `SubscriptionHandler`
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
- **unsubscribe**: `() => Promise<any>`
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
- **filter**: `{} | FullFilter<void, void>`
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
## count<span style="opacity: 0.6;">(filter?: undefined | ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): Promise<number></span>
|
|
514
|
+
Returns the number of rows that match the filter
|
|
515
|
+
```typescript
|
|
516
|
+
count: ():
|
|
517
|
+
```
|
|
518
|
+
#### Parameters
|
|
519
|
+
|
|
520
|
+
- **filter**: `FullFilter<T, S> | undefined`
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
- **selectParams**: `SelectParams`
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
- **limit**: `number | null | undefined`
|
|
527
|
+
|
|
528
|
+
Max number of rows to return. Defaults to 1000
|
|
529
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
530
|
+
- **offset**: `number`
|
|
531
|
+
|
|
532
|
+
Number of rows to skip
|
|
533
|
+
- **groupBy**: `false`
|
|
534
|
+
|
|
535
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
536
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
537
|
+
|
|
538
|
+
Result data structure/type:
|
|
539
|
+
- **row**: the first row as an object
|
|
540
|
+
- **value**: the first value from of first field
|
|
541
|
+
- **values**: array of values from the selected field
|
|
542
|
+
- **statement**: sql statement
|
|
543
|
+
- **statement-no-rls**: sql statement without row level security
|
|
544
|
+
- **statement-where**: sql statement where condition
|
|
545
|
+
- **select**: `Select`
|
|
546
|
+
|
|
547
|
+
Fields/expressions/linked data to select
|
|
548
|
+
- `"*"` or empty will return all fields
|
|
549
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
550
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
551
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
552
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
553
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
554
|
+
- **orderBy**: `OrderBy`
|
|
555
|
+
|
|
556
|
+
Order by options
|
|
557
|
+
- Order is maintained in arrays
|
|
558
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
559
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
560
|
+
|
|
561
|
+
Filter applied after any aggregations (group by)
|
|
562
|
+
#### `number`
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
## size<span style="opacity: 0.6;">(filter?: undefined | ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): Promise<string></span>
|
|
567
|
+
Returns result size in bits
|
|
568
|
+
```typescript
|
|
569
|
+
size: ():
|
|
570
|
+
```
|
|
571
|
+
#### Parameters
|
|
572
|
+
|
|
573
|
+
- **filter**: `FullFilter<T, S> | undefined`
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
- **selectParams**: `SelectParams`
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
- **limit**: `number | null | undefined`
|
|
580
|
+
|
|
581
|
+
Max number of rows to return. Defaults to 1000
|
|
582
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
583
|
+
- **offset**: `number`
|
|
584
|
+
|
|
585
|
+
Number of rows to skip
|
|
586
|
+
- **groupBy**: `false`
|
|
587
|
+
|
|
588
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
589
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
590
|
+
|
|
591
|
+
Result data structure/type:
|
|
592
|
+
- **row**: the first row as an object
|
|
593
|
+
- **value**: the first value from of first field
|
|
594
|
+
- **values**: array of values from the selected field
|
|
595
|
+
- **statement**: sql statement
|
|
596
|
+
- **statement-no-rls**: sql statement without row level security
|
|
597
|
+
- **statement-where**: sql statement where condition
|
|
598
|
+
- **select**: `Select`
|
|
599
|
+
|
|
600
|
+
Fields/expressions/linked data to select
|
|
601
|
+
- `"*"` or empty will return all fields
|
|
602
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
603
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
604
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
605
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
606
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
607
|
+
- **orderBy**: `OrderBy`
|
|
608
|
+
|
|
609
|
+
Order by options
|
|
610
|
+
- Order is maintained in arrays
|
|
611
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
612
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
613
|
+
|
|
614
|
+
Filter applied after any aggregations (group by)
|
|
615
|
+
#### `string`
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
## update<span style="opacity: 0.6;">(filter: ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, newData: Partial, params?: SelectParams): Promise<GetUpdateReturnType<P, T, S> | undefined></span>
|
|
620
|
+
Updates a record in the table based on the specified filter criteria
|
|
621
|
+
- Use { multi: false } to ensure no more than one row is updated
|
|
622
|
+
```typescript
|
|
623
|
+
update: ():
|
|
624
|
+
```
|
|
625
|
+
#### Parameters
|
|
626
|
+
|
|
627
|
+
- **filter**: `FullFilter`
|
|
628
|
+
|
|
629
|
+
Data filter
|
|
630
|
+
- `{ status: 'live' }`
|
|
631
|
+
- `{ $or: [{ id: 1 }, { status: 'live' }] }`
|
|
632
|
+
- `{ $existsJoined: { referencedTable: { id: 1 } } }`
|
|
633
|
+
- `{
|
|
634
|
+
$filter: [
|
|
635
|
+
{ $age: ["created_at"] },
|
|
636
|
+
"<",
|
|
637
|
+
'1 year'
|
|
638
|
+
]
|
|
639
|
+
}`
|
|
640
|
+
- **newData**: `Partial`
|
|
641
|
+
|
|
642
|
+
Make all properties in T optional
|
|
643
|
+
|
|
644
|
+
- **params**: `SelectParams`
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
- **limit**: `number | null | undefined`
|
|
648
|
+
|
|
649
|
+
Max number of rows to return. Defaults to 1000
|
|
650
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
651
|
+
- **offset**: `number`
|
|
652
|
+
|
|
653
|
+
Number of rows to skip
|
|
654
|
+
- **groupBy**: `false`
|
|
655
|
+
|
|
656
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
657
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
658
|
+
|
|
659
|
+
Result data structure/type:
|
|
660
|
+
- **row**: the first row as an object
|
|
661
|
+
- **value**: the first value from of first field
|
|
662
|
+
- **values**: array of values from the selected field
|
|
663
|
+
- **statement**: sql statement
|
|
664
|
+
- **statement-no-rls**: sql statement without row level security
|
|
665
|
+
- **statement-where**: sql statement where condition
|
|
666
|
+
- **select**: `Select`
|
|
667
|
+
|
|
668
|
+
Fields/expressions/linked data to select
|
|
669
|
+
- `"*"` or empty will return all fields
|
|
670
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
671
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
672
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
673
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
674
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
675
|
+
- **orderBy**: `OrderBy`
|
|
676
|
+
|
|
677
|
+
Order by options
|
|
678
|
+
- Order is maintained in arrays
|
|
679
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
680
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
681
|
+
|
|
682
|
+
Filter applied after any aggregations (group by)
|
|
683
|
+
#### `GetUpdateReturnType<P, T, S> | undefined`
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
## updateBatch<span style="opacity: 0.6;">(data: [FullFilter<T, S>, Partial<UpsertDataToPGCast<T>>][], params?: SelectParams): Promise<void | GetUpdateReturnType<P, T, S>></span>
|
|
688
|
+
Updates multiple records in the table in a batch operation.
|
|
689
|
+
- Each item in the `data` array contains a filter and the corresponding data to update.
|
|
690
|
+
```typescript
|
|
691
|
+
updateBatch: ():
|
|
692
|
+
```
|
|
693
|
+
#### Parameters
|
|
694
|
+
|
|
695
|
+
- **data**: `[FullFilter<T, S>, Partial<UpsertDataToPGCast<T>>][]`
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
- **params**: `SelectParams`
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
- **limit**: `number | null | undefined`
|
|
702
|
+
|
|
703
|
+
Max number of rows to return. Defaults to 1000
|
|
704
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
705
|
+
- **offset**: `number`
|
|
706
|
+
|
|
707
|
+
Number of rows to skip
|
|
708
|
+
- **groupBy**: `false`
|
|
709
|
+
|
|
710
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
711
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
712
|
+
|
|
713
|
+
Result data structure/type:
|
|
714
|
+
- **row**: the first row as an object
|
|
715
|
+
- **value**: the first value from of first field
|
|
716
|
+
- **values**: array of values from the selected field
|
|
717
|
+
- **statement**: sql statement
|
|
718
|
+
- **statement-no-rls**: sql statement without row level security
|
|
719
|
+
- **statement-where**: sql statement where condition
|
|
720
|
+
- **select**: `Select`
|
|
721
|
+
|
|
722
|
+
Fields/expressions/linked data to select
|
|
723
|
+
- `"*"` or empty will return all fields
|
|
724
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
725
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
726
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
727
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
728
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
729
|
+
- **orderBy**: `OrderBy`
|
|
730
|
+
|
|
731
|
+
Order by options
|
|
732
|
+
- Order is maintained in arrays
|
|
733
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
734
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
735
|
+
|
|
736
|
+
Filter applied after any aggregations (group by)
|
|
737
|
+
#### `void | GetUpdateReturnType<P, T, S>`
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
## insert<span style="opacity: 0.6;">(data: UpsertDataToPGCast | UpsertDataToPGCast<T>[], params?: SelectParams): Promise<GetInsertReturnType<D, P, T, S>></span>
|
|
742
|
+
Inserts a new record into the table.
|
|
743
|
+
```typescript
|
|
744
|
+
insert: ():
|
|
745
|
+
```
|
|
746
|
+
#### Parameters
|
|
747
|
+
|
|
748
|
+
- **data**: `InsertData`
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
- **params**: `SelectParams`
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
- **limit**: `number | null | undefined`
|
|
755
|
+
|
|
756
|
+
Max number of rows to return. Defaults to 1000
|
|
757
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
758
|
+
- **offset**: `number`
|
|
759
|
+
|
|
760
|
+
Number of rows to skip
|
|
761
|
+
- **groupBy**: `false`
|
|
762
|
+
|
|
763
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
764
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
765
|
+
|
|
766
|
+
Result data structure/type:
|
|
767
|
+
- **row**: the first row as an object
|
|
768
|
+
- **value**: the first value from of first field
|
|
769
|
+
- **values**: array of values from the selected field
|
|
770
|
+
- **statement**: sql statement
|
|
771
|
+
- **statement-no-rls**: sql statement without row level security
|
|
772
|
+
- **statement-where**: sql statement where condition
|
|
773
|
+
- **select**: `Select`
|
|
774
|
+
|
|
775
|
+
Fields/expressions/linked data to select
|
|
776
|
+
- `"*"` or empty will return all fields
|
|
777
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
778
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
779
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
780
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
781
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
782
|
+
- **orderBy**: `OrderBy`
|
|
783
|
+
|
|
784
|
+
Order by options
|
|
785
|
+
- Order is maintained in arrays
|
|
786
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
787
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
788
|
+
|
|
789
|
+
Filter applied after any aggregations (group by)
|
|
790
|
+
#### `GetInsertReturnType`
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
## upsert<span style="opacity: 0.6;">(filter: ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, newData: Partial, params?: SelectParams): Promise<GetUpdateReturnType<P, T, S> | undefined></span>
|
|
795
|
+
Inserts or updates a record in the table.
|
|
796
|
+
- If a record matching the `filter` exists, it updates the record.
|
|
797
|
+
- If no matching record exists, it inserts a new record.
|
|
798
|
+
```typescript
|
|
799
|
+
upsert: ():
|
|
800
|
+
```
|
|
801
|
+
#### Parameters
|
|
802
|
+
|
|
803
|
+
- **filter**: `FullFilter`
|
|
804
|
+
|
|
805
|
+
Data filter
|
|
806
|
+
- `{ status: 'live' }`
|
|
807
|
+
- `{ $or: [{ id: 1 }, { status: 'live' }] }`
|
|
808
|
+
- `{ $existsJoined: { referencedTable: { id: 1 } } }`
|
|
809
|
+
- `{
|
|
810
|
+
$filter: [
|
|
811
|
+
{ $age: ["created_at"] },
|
|
812
|
+
"<",
|
|
813
|
+
'1 year'
|
|
814
|
+
]
|
|
815
|
+
}`
|
|
816
|
+
- **newData**: `Partial`
|
|
817
|
+
|
|
818
|
+
Make all properties in T optional
|
|
819
|
+
|
|
820
|
+
- **params**: `SelectParams`
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
- **limit**: `number | null | undefined`
|
|
824
|
+
|
|
825
|
+
Max number of rows to return. Defaults to 1000
|
|
826
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
827
|
+
- **offset**: `number`
|
|
828
|
+
|
|
829
|
+
Number of rows to skip
|
|
830
|
+
- **groupBy**: `false`
|
|
831
|
+
|
|
832
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
833
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
834
|
+
|
|
835
|
+
Result data structure/type:
|
|
836
|
+
- **row**: the first row as an object
|
|
837
|
+
- **value**: the first value from of first field
|
|
838
|
+
- **values**: array of values from the selected field
|
|
839
|
+
- **statement**: sql statement
|
|
840
|
+
- **statement-no-rls**: sql statement without row level security
|
|
841
|
+
- **statement-where**: sql statement where condition
|
|
842
|
+
- **select**: `Select`
|
|
843
|
+
|
|
844
|
+
Fields/expressions/linked data to select
|
|
845
|
+
- `"*"` or empty will return all fields
|
|
846
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
847
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
848
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
849
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
850
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
851
|
+
- **orderBy**: `OrderBy`
|
|
852
|
+
|
|
853
|
+
Order by options
|
|
854
|
+
- Order is maintained in arrays
|
|
855
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
856
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
857
|
+
|
|
858
|
+
Filter applied after any aggregations (group by)
|
|
859
|
+
#### `GetUpdateReturnType<P, T, S> | undefined`
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
## delete<span style="opacity: 0.6;">(filter?: undefined | ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, params?: SelectParams): Promise<GetUpdateReturnType<P, T, S> | undefined></span>
|
|
864
|
+
Deletes records from the table based on the specified filter criteria.
|
|
865
|
+
- If no filter is provided, all records may be deleted (use with caution).
|
|
866
|
+
```typescript
|
|
867
|
+
delete: ():
|
|
868
|
+
```
|
|
869
|
+
#### Parameters
|
|
870
|
+
|
|
871
|
+
- **filter**: `FullFilter<T, S> | undefined`
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
- **params**: `SelectParams`
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
- **limit**: `number | null | undefined`
|
|
878
|
+
|
|
879
|
+
Max number of rows to return. Defaults to 1000
|
|
880
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
881
|
+
- **offset**: `number`
|
|
882
|
+
|
|
883
|
+
Number of rows to skip
|
|
884
|
+
- **groupBy**: `false`
|
|
885
|
+
|
|
886
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
887
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
888
|
+
|
|
889
|
+
Result data structure/type:
|
|
890
|
+
- **row**: the first row as an object
|
|
891
|
+
- **value**: the first value from of first field
|
|
892
|
+
- **values**: array of values from the selected field
|
|
893
|
+
- **statement**: sql statement
|
|
894
|
+
- **statement-no-rls**: sql statement without row level security
|
|
895
|
+
- **statement-where**: sql statement where condition
|
|
896
|
+
- **select**: `Select`
|
|
897
|
+
|
|
898
|
+
Fields/expressions/linked data to select
|
|
899
|
+
- `"*"` or empty will return all fields
|
|
900
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
901
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
902
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
903
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
904
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
905
|
+
- **orderBy**: `OrderBy`
|
|
906
|
+
|
|
907
|
+
Order by options
|
|
908
|
+
- Order is maintained in arrays
|
|
909
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
910
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
911
|
+
|
|
912
|
+
Filter applied after any aggregations (group by)
|
|
913
|
+
#### `GetUpdateReturnType<P, T, S> | undefined`
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
# Client Methods
|
|
917
|
+
|
|
918
|
+
The following methods are available on the client.
|
|
919
|
+
|
|
920
|
+
## getJoinedTables<span style="opacity: 0.6;">(): string[]</span>
|
|
921
|
+
|
|
922
|
+
```typescript
|
|
923
|
+
getJoinedTables: ():
|
|
924
|
+
```
|
|
925
|
+
#### Parameters
|
|
926
|
+
|
|
927
|
+
#### `string`
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
## sync<span style="opacity: 0.6;">(basicFilter: EqualityFilter, options: SyncOptions, onChange: (data: SyncDataItem<Required<T>, false>[], delta?: Partial<T>[] | undefined) => any, onError?: (error: any) => void): Promise<{ $unsync: () => void; $upsert: (newData: T[]) => any; getItems: () => T[]; }></span>
|
|
936
|
+
|
|
937
|
+
```typescript
|
|
938
|
+
sync: ():
|
|
939
|
+
```
|
|
940
|
+
#### Parameters
|
|
941
|
+
|
|
942
|
+
- **basicFilter**: `EqualityFilter`
|
|
943
|
+
|
|
944
|
+
Equality filter used for sync
|
|
945
|
+
Multiple columns are combined with AND
|
|
946
|
+
|
|
947
|
+
- **options**: `SyncOptions`
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
- **onChange**: `(data: SyncDataItem<Required<T>, false>[], delta?: Partial<T>[] | undefined) => any`
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
- **onError**: `(error: any) => void`
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
#### `{ $unsync: () => void; $upsert: (newData: T[]) => any; getItems: () => T[]; }`
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
- **$unsync**: `() => void`
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
- **$upsert**: `(newData: T[]) => any`
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
- **getItems**: `() => T[]`
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
## useSync<span style="opacity: 0.6;">(basicFilter: EqualityFilter, syncOptions: SyncOptions): { data: SyncDataItem<Required<T>>[] | undefined; isLoading: boolean; error?: any; }</span>
|
|
970
|
+
Retrieves rows matching the filter and keeps them in sync
|
|
971
|
+
- use { handlesOnData: true } to get optimistic updates method: $update
|
|
972
|
+
- any changes to the row using the $update method will be reflected instantly
|
|
973
|
+
to all sync subscribers that were initiated with the same syncOptions
|
|
974
|
+
```typescript
|
|
975
|
+
useSync: ():
|
|
976
|
+
```
|
|
977
|
+
#### Parameters
|
|
978
|
+
|
|
979
|
+
- **basicFilter**: `EqualityFilter`
|
|
980
|
+
|
|
981
|
+
Equality filter used for sync
|
|
982
|
+
Multiple columns are combined with AND
|
|
983
|
+
|
|
984
|
+
- **syncOptions**: `SyncOptions`
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
#### `{ data: SyncDataItem<Required<T>>[] | undefined; isLoading: boolean; error?: any; }`
|
|
988
|
+
|
|
989
|
+
|
|
990
|
+
- **data**: `SyncDataItem<Required<T>>[] | undefined`
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
- **isLoading**: `boolean`
|
|
994
|
+
|
|
995
|
+
|
|
996
|
+
- **error**: `any`
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
## syncOne<span style="opacity: 0.6;">(basicFilter: Partial, options: SyncOneOptions, onChange: (data: SyncDataItem<Required<T>, false>, delta?: Partial<T> | undefined) => any, onError?: (error: any) => void): Promise<SingleSyncHandles<T, false>></span>
|
|
1001
|
+
|
|
1002
|
+
```typescript
|
|
1003
|
+
syncOne: ():
|
|
1004
|
+
```
|
|
1005
|
+
#### Parameters
|
|
1006
|
+
|
|
1007
|
+
- **basicFilter**: `Partial`
|
|
1008
|
+
|
|
1009
|
+
Make all properties in T optional
|
|
1010
|
+
|
|
1011
|
+
- **options**: `SyncOneOptions`
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
- **onChange**: `(data: SyncDataItem<Required<T>, false>, delta?: Partial<T> | undefined) => any`
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
- **onError**: `(error: any) => void`
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
#### `SingleSyncHandles`
|
|
1021
|
+
|
|
1022
|
+
CRUD handles added if initialised with handlesOnData = true
|
|
1023
|
+
- **$get**: `() => T | undefined`
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
- **$find**: `(idObj: Partial<T>) => T | undefined`
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
- **$unsync**: `() => any`
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
- **$delete**: `() => void`
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
- **$update**: `<OPTS extends $UpdateOpts>(newData: OPTS extends { deepMerge: true; } ? DeepPartial<T> : Partial<T>, opts?: OPTS | undefined) => any`
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
- **$cloneSync**: `CloneSync`
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
- **$cloneMultiSync**: `CloneMultiSync`
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
## useSyncOne<span style="opacity: 0.6;">(basicFilter: EqualityFilter, syncOptions: SyncOneOptions): { data: SyncDataItem<Required<T>> | undefined; isLoading: boolean; error?: any; }</span>
|
|
1046
|
+
Retrieves the first row matching the filter and keeps it in sync
|
|
1047
|
+
- use { handlesOnData: true } to get optimistic updates method: $update
|
|
1048
|
+
- any changes to the row using the $update method will be reflected instantly
|
|
1049
|
+
to all sync subscribers that were initiated with the same syncOptions
|
|
1050
|
+
```typescript
|
|
1051
|
+
useSyncOne: ():
|
|
1052
|
+
```
|
|
1053
|
+
#### Parameters
|
|
1054
|
+
|
|
1055
|
+
- **basicFilter**: `EqualityFilter`
|
|
1056
|
+
|
|
1057
|
+
Equality filter used for sync
|
|
1058
|
+
Multiple columns are combined with AND
|
|
1059
|
+
|
|
1060
|
+
- **syncOptions**: `SyncOneOptions`
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+
#### `{ data: SyncDataItem<Required<T>> | undefined; isLoading: boolean; error?: any; }`
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
- **data**: `SyncDataItem<Required<T>> | undefined`
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
- **isLoading**: `boolean`
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
- **error**: `any`
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
## useSubscribe<span style="opacity: 0.6;">(filter?: undefined | ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, options?: SubscribeParams): { data: GetSelectReturnType<S, SubParams, T, true> | undefined; error?: any; isLoading: boolean; }</span>
|
|
1079
|
+
Retrieves a list of matching records from the view/table and subscribes to changes
|
|
1080
|
+
```typescript
|
|
1081
|
+
useSubscribe: ():
|
|
1082
|
+
```
|
|
1083
|
+
#### Parameters
|
|
1084
|
+
|
|
1085
|
+
- **filter**: `FullFilter<T, S> | undefined`
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
- **options**: `SubscribeParams`
|
|
1089
|
+
|
|
1090
|
+
|
|
1091
|
+
- **limit**: `number | null | undefined`
|
|
1092
|
+
|
|
1093
|
+
Max number of rows to return. Defaults to 1000
|
|
1094
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
1095
|
+
- **offset**: `number`
|
|
1096
|
+
|
|
1097
|
+
Number of rows to skip
|
|
1098
|
+
- **groupBy**: `false`
|
|
1099
|
+
|
|
1100
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
1101
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
1102
|
+
|
|
1103
|
+
Result data structure/type:
|
|
1104
|
+
- **row**: the first row as an object
|
|
1105
|
+
- **value**: the first value from of first field
|
|
1106
|
+
- **values**: array of values from the selected field
|
|
1107
|
+
- **statement**: sql statement
|
|
1108
|
+
- **statement-no-rls**: sql statement without row level security
|
|
1109
|
+
- **statement-where**: sql statement where condition
|
|
1110
|
+
- **select**: `Select`
|
|
1111
|
+
|
|
1112
|
+
Fields/expressions/linked data to select
|
|
1113
|
+
- `"*"` or empty will return all fields
|
|
1114
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
1115
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
1116
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
1117
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
1118
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
1119
|
+
- **orderBy**: `OrderBy`
|
|
1120
|
+
|
|
1121
|
+
Order by options
|
|
1122
|
+
- Order is maintained in arrays
|
|
1123
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
1124
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
1125
|
+
|
|
1126
|
+
Filter applied after any aggregations (group by)
|
|
1127
|
+
- **throttle**: `number`
|
|
1128
|
+
|
|
1129
|
+
If true then the subscription will be throttled to the provided number of milliseconds
|
|
1130
|
+
- **throttleOpts**: `{ skipFirst?: boolean | undefined; }`
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
- **skipFirst**: `false`
|
|
1134
|
+
|
|
1135
|
+
False by default.
|
|
1136
|
+
If true then the first value will be emitted at the end of the interval. Instant otherwise
|
|
1137
|
+
#### `{ data: GetSelectReturnType<S, SubParams, T, true> | undefined; error?: any; isLoading: boolean; }`
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
- **data**: `GetSelectReturnType<S, SubParams, T, true> | undefined`
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
- **error**: `any`
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
- **isLoading**: `boolean`
|
|
1147
|
+
|
|
1148
|
+
|
|
1149
|
+
|
|
1150
|
+
## useSubscribeOne<span style="opacity: 0.6;">(filter?: undefined | ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, options?: SubscribeParams): { data: GetSelectReturnType<S, SubParams, T, false> | undefined; error?: any; isLoading: boolean; }</span>
|
|
1151
|
+
Retrieves a matching record from the view/table and subscribes to changes
|
|
1152
|
+
```typescript
|
|
1153
|
+
useSubscribeOne: ():
|
|
1154
|
+
```
|
|
1155
|
+
#### Parameters
|
|
1156
|
+
|
|
1157
|
+
- **filter**: `FullFilter<T, S> | undefined`
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
- **options**: `SubscribeParams`
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
- **limit**: `number | null | undefined`
|
|
1164
|
+
|
|
1165
|
+
Max number of rows to return. Defaults to 1000
|
|
1166
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
1167
|
+
- **offset**: `number`
|
|
1168
|
+
|
|
1169
|
+
Number of rows to skip
|
|
1170
|
+
- **groupBy**: `false`
|
|
1171
|
+
|
|
1172
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
1173
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
1174
|
+
|
|
1175
|
+
Result data structure/type:
|
|
1176
|
+
- **row**: the first row as an object
|
|
1177
|
+
- **value**: the first value from of first field
|
|
1178
|
+
- **values**: array of values from the selected field
|
|
1179
|
+
- **statement**: sql statement
|
|
1180
|
+
- **statement-no-rls**: sql statement without row level security
|
|
1181
|
+
- **statement-where**: sql statement where condition
|
|
1182
|
+
- **select**: `Select`
|
|
1183
|
+
|
|
1184
|
+
Fields/expressions/linked data to select
|
|
1185
|
+
- `"*"` or empty will return all fields
|
|
1186
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
1187
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
1188
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
1189
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
1190
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
1191
|
+
- **orderBy**: `OrderBy`
|
|
1192
|
+
|
|
1193
|
+
Order by options
|
|
1194
|
+
- Order is maintained in arrays
|
|
1195
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
1196
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
1197
|
+
|
|
1198
|
+
Filter applied after any aggregations (group by)
|
|
1199
|
+
- **throttle**: `number`
|
|
1200
|
+
|
|
1201
|
+
If true then the subscription will be throttled to the provided number of milliseconds
|
|
1202
|
+
- **throttleOpts**: `{ skipFirst?: boolean | undefined; }`
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
- **skipFirst**: `false`
|
|
1206
|
+
|
|
1207
|
+
False by default.
|
|
1208
|
+
If true then the first value will be emitted at the end of the interval. Instant otherwise
|
|
1209
|
+
#### `{ data: GetSelectReturnType<S, SubParams, T, false> | undefined; error?: any; isLoading: boolean; }`
|
|
1210
|
+
|
|
1211
|
+
|
|
1212
|
+
- **data**: `GetSelectReturnType<S, SubParams, T, false> | undefined`
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
- **error**: `any`
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
- **isLoading**: `boolean`
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
## useFind<span style="opacity: 0.6;">(filter?: undefined | ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): { data: GetSelectReturnType<S, P, T, true> | undefined; isLoading: boolean; error?: any; }</span>
|
|
1223
|
+
Retrieves a list of matching records from the view/table
|
|
1224
|
+
```typescript
|
|
1225
|
+
useFind: ():
|
|
1226
|
+
```
|
|
1227
|
+
#### Parameters
|
|
1228
|
+
|
|
1229
|
+
- **filter**: `FullFilter<T, S> | undefined`
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
- **selectParams**: `SelectParams`
|
|
1233
|
+
|
|
1234
|
+
|
|
1235
|
+
- **limit**: `number | null | undefined`
|
|
1236
|
+
|
|
1237
|
+
Max number of rows to return. Defaults to 1000
|
|
1238
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
1239
|
+
- **offset**: `number`
|
|
1240
|
+
|
|
1241
|
+
Number of rows to skip
|
|
1242
|
+
- **groupBy**: `false`
|
|
1243
|
+
|
|
1244
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
1245
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
1246
|
+
|
|
1247
|
+
Result data structure/type:
|
|
1248
|
+
- **row**: the first row as an object
|
|
1249
|
+
- **value**: the first value from of first field
|
|
1250
|
+
- **values**: array of values from the selected field
|
|
1251
|
+
- **statement**: sql statement
|
|
1252
|
+
- **statement-no-rls**: sql statement without row level security
|
|
1253
|
+
- **statement-where**: sql statement where condition
|
|
1254
|
+
- **select**: `Select`
|
|
1255
|
+
|
|
1256
|
+
Fields/expressions/linked data to select
|
|
1257
|
+
- `"*"` or empty will return all fields
|
|
1258
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
1259
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
1260
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
1261
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
1262
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
1263
|
+
- **orderBy**: `OrderBy`
|
|
1264
|
+
|
|
1265
|
+
Order by options
|
|
1266
|
+
- Order is maintained in arrays
|
|
1267
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
1268
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
1269
|
+
|
|
1270
|
+
Filter applied after any aggregations (group by)
|
|
1271
|
+
#### `{ data: GetSelectReturnType<S, P, T, true> | undefined; isLoading: boolean; error?: any; }`
|
|
1272
|
+
|
|
1273
|
+
|
|
1274
|
+
- **data**: `GetSelectReturnType<S, P, T, true> | undefined`
|
|
1275
|
+
|
|
1276
|
+
|
|
1277
|
+
- **isLoading**: `boolean`
|
|
1278
|
+
|
|
1279
|
+
|
|
1280
|
+
- **error**: `any`
|
|
1281
|
+
|
|
1282
|
+
|
|
1283
|
+
|
|
1284
|
+
## useFindOne<span style="opacity: 0.6;">(filter?: undefined | ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): { data: GetSelectReturnType<S, P, T, false> | undefined; isLoading: boolean; error?: any; }</span>
|
|
1285
|
+
Retrieves first matching record from the view/table
|
|
1286
|
+
```typescript
|
|
1287
|
+
useFindOne: ():
|
|
1288
|
+
```
|
|
1289
|
+
#### Parameters
|
|
1290
|
+
|
|
1291
|
+
- **filter**: `FullFilter<T, S> | undefined`
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
- **selectParams**: `SelectParams`
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
- **limit**: `number | null | undefined`
|
|
1298
|
+
|
|
1299
|
+
Max number of rows to return. Defaults to 1000
|
|
1300
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
1301
|
+
- **offset**: `number`
|
|
1302
|
+
|
|
1303
|
+
Number of rows to skip
|
|
1304
|
+
- **groupBy**: `false`
|
|
1305
|
+
|
|
1306
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
1307
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
1308
|
+
|
|
1309
|
+
Result data structure/type:
|
|
1310
|
+
- **row**: the first row as an object
|
|
1311
|
+
- **value**: the first value from of first field
|
|
1312
|
+
- **values**: array of values from the selected field
|
|
1313
|
+
- **statement**: sql statement
|
|
1314
|
+
- **statement-no-rls**: sql statement without row level security
|
|
1315
|
+
- **statement-where**: sql statement where condition
|
|
1316
|
+
- **select**: `Select`
|
|
1317
|
+
|
|
1318
|
+
Fields/expressions/linked data to select
|
|
1319
|
+
- `"*"` or empty will return all fields
|
|
1320
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
1321
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
1322
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
1323
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
1324
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
1325
|
+
- **orderBy**: `OrderBy`
|
|
1326
|
+
|
|
1327
|
+
Order by options
|
|
1328
|
+
- Order is maintained in arrays
|
|
1329
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
1330
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
1331
|
+
|
|
1332
|
+
Filter applied after any aggregations (group by)
|
|
1333
|
+
#### `{ data: GetSelectReturnType<S, P, T, false> | undefined; isLoading: boolean; error?: any; }`
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
- **data**: `GetSelectReturnType<S, P, T, false> | undefined`
|
|
1337
|
+
|
|
1338
|
+
|
|
1339
|
+
- **isLoading**: `boolean`
|
|
1340
|
+
|
|
1341
|
+
|
|
1342
|
+
- **error**: `any`
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
## useCount<span style="opacity: 0.6;">(filter?: undefined | ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): { data: number | undefined; isLoading: boolean; error?: any; }</span>
|
|
1347
|
+
Returns the total number of rows matching the filter
|
|
1348
|
+
```typescript
|
|
1349
|
+
useCount: ():
|
|
1350
|
+
```
|
|
1351
|
+
#### Parameters
|
|
1352
|
+
|
|
1353
|
+
- **filter**: `FullFilter<T, S> | undefined`
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
- **selectParams**: `SelectParams`
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
- **limit**: `number | null | undefined`
|
|
1360
|
+
|
|
1361
|
+
Max number of rows to return. Defaults to 1000
|
|
1362
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
1363
|
+
- **offset**: `number`
|
|
1364
|
+
|
|
1365
|
+
Number of rows to skip
|
|
1366
|
+
- **groupBy**: `false`
|
|
1367
|
+
|
|
1368
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
1369
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
1370
|
+
|
|
1371
|
+
Result data structure/type:
|
|
1372
|
+
- **row**: the first row as an object
|
|
1373
|
+
- **value**: the first value from of first field
|
|
1374
|
+
- **values**: array of values from the selected field
|
|
1375
|
+
- **statement**: sql statement
|
|
1376
|
+
- **statement-no-rls**: sql statement without row level security
|
|
1377
|
+
- **statement-where**: sql statement where condition
|
|
1378
|
+
- **select**: `Select`
|
|
1379
|
+
|
|
1380
|
+
Fields/expressions/linked data to select
|
|
1381
|
+
- `"*"` or empty will return all fields
|
|
1382
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
1383
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
1384
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
1385
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
1386
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
1387
|
+
- **orderBy**: `OrderBy`
|
|
1388
|
+
|
|
1389
|
+
Order by options
|
|
1390
|
+
- Order is maintained in arrays
|
|
1391
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
1392
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
1393
|
+
|
|
1394
|
+
Filter applied after any aggregations (group by)
|
|
1395
|
+
#### `{ data: number | undefined; isLoading: boolean; error?: any; }`
|
|
1396
|
+
|
|
1397
|
+
|
|
1398
|
+
- **data**: `number | undefined`
|
|
1399
|
+
|
|
1400
|
+
|
|
1401
|
+
- **isLoading**: `boolean`
|
|
1402
|
+
|
|
1403
|
+
|
|
1404
|
+
- **error**: `any`
|
|
1405
|
+
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
## useSize<span style="opacity: 0.6;">(filter?: undefined | ComplexFilter | { $and: FullFilter<T, S>[]; } | { $or: FullFilter<T, S>[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): { data: string | undefined; isLoading: boolean; error?: any; }</span>
|
|
1409
|
+
Returns result size in bits matching the filter and selectParams
|
|
1410
|
+
```typescript
|
|
1411
|
+
useSize: ():
|
|
1412
|
+
```
|
|
1413
|
+
#### Parameters
|
|
1414
|
+
|
|
1415
|
+
- **filter**: `FullFilter<T, S> | undefined`
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
- **selectParams**: `SelectParams`
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
- **limit**: `number | null | undefined`
|
|
1422
|
+
|
|
1423
|
+
Max number of rows to return. Defaults to 1000
|
|
1424
|
+
- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
|
|
1425
|
+
- **offset**: `number`
|
|
1426
|
+
|
|
1427
|
+
Number of rows to skip
|
|
1428
|
+
- **groupBy**: `false`
|
|
1429
|
+
|
|
1430
|
+
Will group by all non aggregated fields specified in select (or all fields by default)
|
|
1431
|
+
- **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined`
|
|
1432
|
+
|
|
1433
|
+
Result data structure/type:
|
|
1434
|
+
- **row**: the first row as an object
|
|
1435
|
+
- **value**: the first value from of first field
|
|
1436
|
+
- **values**: array of values from the selected field
|
|
1437
|
+
- **statement**: sql statement
|
|
1438
|
+
- **statement-no-rls**: sql statement without row level security
|
|
1439
|
+
- **statement-where**: sql statement where condition
|
|
1440
|
+
- **select**: `Select`
|
|
1441
|
+
|
|
1442
|
+
Fields/expressions/linked data to select
|
|
1443
|
+
- `"*"` or empty will return all fields
|
|
1444
|
+
- `{ field: 0 }` - all fields except the specified field will be selected
|
|
1445
|
+
- `{ field: 1 }` - only the specified field will be selected
|
|
1446
|
+
- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied
|
|
1447
|
+
- `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected
|
|
1448
|
+
- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable
|
|
1449
|
+
- **orderBy**: `OrderBy`
|
|
1450
|
+
|
|
1451
|
+
Order by options
|
|
1452
|
+
- Order is maintained in arrays
|
|
1453
|
+
- `[{ key: "field", asc: true, nulls: "last" }]`
|
|
1454
|
+
- **having**: `FullFilter<T, S> | undefined`
|
|
1455
|
+
|
|
1456
|
+
Filter applied after any aggregations (group by)
|
|
1457
|
+
#### `{ data: string | undefined; isLoading: boolean; error?: any; }`
|
|
1458
|
+
|
|
1459
|
+
|
|
1460
|
+
- **data**: `string | undefined`
|
|
1461
|
+
|
|
1462
|
+
|
|
1463
|
+
- **isLoading**: `boolean`
|
|
1464
|
+
|
|
1465
|
+
|
|
1466
|
+
- **error**: `any`
|
|
1467
|
+
|