rado 0.2.14 → 0.2.15
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/dist/define/Column.d.ts +19 -17
- package/dist/define/Column.js +33 -33
- package/dist/define/Cursor.d.ts +15 -7
- package/dist/define/Cursor.js +83 -85
- package/dist/define/Expr.d.ts +41 -28
- package/dist/define/Expr.js +202 -152
- package/dist/define/Functions.js +1 -1
- package/dist/define/Ops.js +6 -6
- package/dist/define/Schema.js +1 -1
- package/dist/define/Selection.d.ts +4 -4
- package/dist/define/Table.d.ts +8 -6
- package/dist/define/Table.js +25 -12
- package/dist/lib/Driver.js +12 -12
- package/dist/lib/Formatter.js +2 -2
- package/package.json +2 -2
package/dist/define/Cursor.js
CHANGED
|
@@ -1,109 +1,108 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
// src/define/Cursor.ts
|
|
2
9
|
import { Expr, ExprData } from "./Expr.js";
|
|
3
10
|
import { Functions } from "./Functions.js";
|
|
4
11
|
import { Query } from "./Query.js";
|
|
5
12
|
import { Schema } from "./Schema.js";
|
|
6
|
-
import {
|
|
7
|
-
import { createTable, table } from "./Table.js";
|
|
13
|
+
import { Table, createTable } from "./Table.js";
|
|
8
14
|
import { Target } from "./Target.js";
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
15
|
+
var QUERY = Symbol("Cursor.Query");
|
|
16
|
+
var _Cursor = class {
|
|
17
|
+
[QUERY];
|
|
13
18
|
constructor(query) {
|
|
14
|
-
|
|
15
|
-
enumerable: false,
|
|
16
|
-
value: () => query
|
|
17
|
-
});
|
|
19
|
+
this[QUERY] = query;
|
|
18
20
|
}
|
|
19
21
|
static all(strings, ...params) {
|
|
20
|
-
return new
|
|
21
|
-
}
|
|
22
|
-
query() {
|
|
23
|
-
throw new Error("Not implemented");
|
|
22
|
+
return new _Cursor(Query.Raw({ expectedReturn: "rows", strings, params }));
|
|
24
23
|
}
|
|
25
24
|
next(cursor) {
|
|
26
|
-
return new
|
|
25
|
+
return new _Cursor(
|
|
27
26
|
Query.Batch({
|
|
28
|
-
queries: [this
|
|
27
|
+
queries: [this[QUERY], cursor[QUERY]]
|
|
29
28
|
})
|
|
30
29
|
);
|
|
31
30
|
}
|
|
32
31
|
on(driver) {
|
|
33
|
-
return driver.executeQuery(this
|
|
32
|
+
return driver.executeQuery(this[QUERY]);
|
|
34
33
|
}
|
|
35
34
|
toSql(driver, options = { forceInline: true }) {
|
|
36
|
-
return driver.formatter.compile(this
|
|
35
|
+
return driver.formatter.compile(this[QUERY], options).sql;
|
|
37
36
|
}
|
|
38
37
|
toJSON() {
|
|
39
|
-
return this
|
|
38
|
+
return this[QUERY];
|
|
40
39
|
}
|
|
41
40
|
};
|
|
41
|
+
var Cursor = _Cursor;
|
|
42
|
+
__publicField(Cursor, "Query", QUERY);
|
|
42
43
|
function addWhere(query, where) {
|
|
43
44
|
const conditions = where.slice();
|
|
44
45
|
if (query.where)
|
|
45
46
|
conditions.push(new Expr(query.where));
|
|
46
47
|
return {
|
|
47
48
|
...query,
|
|
48
|
-
where: Expr.and(...conditions).
|
|
49
|
+
where: Expr.and(...conditions)[Expr.Data]
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
((Cursor2) => {
|
|
52
53
|
class Delete extends Cursor2 {
|
|
53
54
|
query() {
|
|
54
|
-
return super
|
|
55
|
+
return super[QUERY];
|
|
55
56
|
}
|
|
56
57
|
where(...where) {
|
|
57
|
-
return new Delete(addWhere(this
|
|
58
|
+
return new Delete(addWhere(this[QUERY], where));
|
|
58
59
|
}
|
|
59
60
|
take(limit) {
|
|
60
|
-
return new Delete({ ...this
|
|
61
|
+
return new Delete({ ...this[QUERY], limit });
|
|
61
62
|
}
|
|
62
63
|
skip(offset) {
|
|
63
|
-
return new Delete({ ...this
|
|
64
|
+
return new Delete({ ...this[QUERY], offset });
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
Cursor2.Delete = Delete;
|
|
67
|
-
class
|
|
68
|
-
query() {
|
|
69
|
-
return super.query();
|
|
70
|
-
}
|
|
68
|
+
const _Update = class extends Cursor2 {
|
|
71
69
|
set(set) {
|
|
72
|
-
return new
|
|
70
|
+
return new _Update({ ...this[QUERY], set });
|
|
73
71
|
}
|
|
74
72
|
where(...where) {
|
|
75
|
-
return new
|
|
73
|
+
return new _Update(addWhere(this[QUERY], where));
|
|
76
74
|
}
|
|
77
75
|
take(limit) {
|
|
78
|
-
return new
|
|
76
|
+
return new _Update({ ...this[QUERY], limit });
|
|
79
77
|
}
|
|
80
78
|
skip(offset) {
|
|
81
|
-
return new
|
|
79
|
+
return new _Update({ ...this[QUERY], offset });
|
|
82
80
|
}
|
|
83
|
-
}
|
|
81
|
+
};
|
|
82
|
+
let Update = _Update;
|
|
83
|
+
QUERY;
|
|
84
84
|
Cursor2.Update = Update;
|
|
85
85
|
class InsertValuesReturning extends Cursor2 {
|
|
86
86
|
}
|
|
87
87
|
Cursor2.InsertValuesReturning = InsertValuesReturning;
|
|
88
88
|
class Inserted extends Cursor2 {
|
|
89
|
-
query
|
|
90
|
-
|
|
89
|
+
constructor(query) {
|
|
90
|
+
super(query);
|
|
91
91
|
}
|
|
92
92
|
returning(selection) {
|
|
93
93
|
return new InsertValuesReturning(
|
|
94
|
-
Query.Insert({ ...this
|
|
94
|
+
Query.Insert({ ...this[QUERY], selection: ExprData.create(selection) })
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
QUERY;
|
|
98
99
|
Cursor2.Inserted = Inserted;
|
|
99
100
|
class Insert {
|
|
100
101
|
constructor(into) {
|
|
101
102
|
this.into = into;
|
|
102
103
|
}
|
|
103
104
|
selection(query) {
|
|
104
|
-
return new Inserted(
|
|
105
|
-
Query.Insert({ into: this.into, select: query.query() })
|
|
106
|
-
);
|
|
105
|
+
return new Inserted(Query.Insert({ into: this.into, select: query[QUERY] }));
|
|
107
106
|
}
|
|
108
107
|
values(...data) {
|
|
109
108
|
return new Inserted(Query.Insert({ into: this.into, data }));
|
|
@@ -111,9 +110,9 @@ function addWhere(query, where) {
|
|
|
111
110
|
}
|
|
112
111
|
Cursor2.Insert = Insert;
|
|
113
112
|
class CreateTable extends Cursor2 {
|
|
114
|
-
constructor(
|
|
115
|
-
super(Schema.create(
|
|
116
|
-
this.table =
|
|
113
|
+
constructor(table) {
|
|
114
|
+
super(Schema.create(table));
|
|
115
|
+
this.table = table;
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
Cursor2.CreateTable = CreateTable;
|
|
@@ -122,21 +121,19 @@ function addWhere(query, where) {
|
|
|
122
121
|
super(Query.Batch({ queries }));
|
|
123
122
|
this.queries = queries;
|
|
124
123
|
}
|
|
125
|
-
query() {
|
|
126
|
-
return super.query();
|
|
127
|
-
}
|
|
128
124
|
next(cursor) {
|
|
129
125
|
return new Cursor2(
|
|
130
126
|
Query.Batch({
|
|
131
|
-
queries: [...this.
|
|
127
|
+
queries: [...this[QUERY].queries, cursor[QUERY]]
|
|
132
128
|
})
|
|
133
129
|
);
|
|
134
130
|
}
|
|
135
131
|
}
|
|
132
|
+
QUERY;
|
|
136
133
|
Cursor2.Batch = Batch;
|
|
137
134
|
function joinTarget(joinType, query, to, on) {
|
|
138
|
-
const toQuery = to instanceof Cursor2 ? to
|
|
139
|
-
const target = toQuery ? toQuery.from : Target.Table(to[
|
|
135
|
+
const toQuery = to instanceof Cursor2 ? to[QUERY] : void 0;
|
|
136
|
+
const target = toQuery ? toQuery.from : Target.Table(to[Table.Data]);
|
|
140
137
|
if (!query.from || !target)
|
|
141
138
|
throw new Error("No from clause");
|
|
142
139
|
const conditions = [...on];
|
|
@@ -149,22 +146,22 @@ function addWhere(query, where) {
|
|
|
149
146
|
query.from,
|
|
150
147
|
target,
|
|
151
148
|
joinType,
|
|
152
|
-
Expr.and(...conditions).
|
|
149
|
+
Expr.and(...conditions)[Expr.Data]
|
|
153
150
|
);
|
|
154
151
|
}
|
|
155
152
|
class SelectMultiple extends Cursor2 {
|
|
156
|
-
query
|
|
157
|
-
|
|
153
|
+
constructor(query) {
|
|
154
|
+
super(query);
|
|
158
155
|
}
|
|
159
156
|
leftJoin(that, ...on) {
|
|
160
|
-
const query = this
|
|
157
|
+
const query = this[QUERY];
|
|
161
158
|
return new SelectMultiple({
|
|
162
159
|
...query,
|
|
163
160
|
from: joinTarget("left", query, that, on)
|
|
164
161
|
});
|
|
165
162
|
}
|
|
166
163
|
innerJoin(that, ...on) {
|
|
167
|
-
const query = this
|
|
164
|
+
const query = this[QUERY];
|
|
168
165
|
return new SelectMultiple({
|
|
169
166
|
...query,
|
|
170
167
|
from: joinTarget("inner", query, that, on)
|
|
@@ -172,20 +169,20 @@ function addWhere(query, where) {
|
|
|
172
169
|
}
|
|
173
170
|
select(selection) {
|
|
174
171
|
return new SelectMultiple({
|
|
175
|
-
...this
|
|
172
|
+
...this[QUERY],
|
|
176
173
|
selection: ExprData.create(selection)
|
|
177
174
|
});
|
|
178
175
|
}
|
|
179
176
|
count() {
|
|
180
177
|
return new SelectSingle({
|
|
181
|
-
...this
|
|
182
|
-
selection: Functions.count().
|
|
178
|
+
...this[QUERY],
|
|
179
|
+
selection: Functions.count()[Expr.Data],
|
|
183
180
|
singleResult: true
|
|
184
181
|
});
|
|
185
182
|
}
|
|
186
183
|
orderBy(...orderBy) {
|
|
187
184
|
return new SelectMultiple({
|
|
188
|
-
...this
|
|
185
|
+
...this[QUERY],
|
|
189
186
|
orderBy: orderBy.map((e) => {
|
|
190
187
|
return Expr.isExpr(e) ? e.asc() : e;
|
|
191
188
|
})
|
|
@@ -193,45 +190,45 @@ function addWhere(query, where) {
|
|
|
193
190
|
}
|
|
194
191
|
groupBy(...groupBy) {
|
|
195
192
|
return new SelectMultiple({
|
|
196
|
-
...this
|
|
193
|
+
...this[QUERY],
|
|
197
194
|
groupBy: groupBy.map(ExprData.create)
|
|
198
195
|
});
|
|
199
196
|
}
|
|
200
197
|
first() {
|
|
201
|
-
return new SelectSingle({ ...this
|
|
198
|
+
return new SelectSingle({ ...this[QUERY], singleResult: true });
|
|
202
199
|
}
|
|
203
200
|
sure() {
|
|
204
201
|
return new SelectSingle({
|
|
205
|
-
...this
|
|
202
|
+
...this[QUERY],
|
|
206
203
|
singleResult: true,
|
|
207
204
|
validate: true
|
|
208
205
|
});
|
|
209
206
|
}
|
|
210
207
|
where(...where) {
|
|
211
|
-
return new SelectMultiple(addWhere(this
|
|
208
|
+
return new SelectMultiple(addWhere(this[QUERY], where));
|
|
212
209
|
}
|
|
213
210
|
take(limit) {
|
|
214
|
-
return new SelectMultiple({ ...this
|
|
211
|
+
return new SelectMultiple({ ...this[QUERY], limit });
|
|
215
212
|
}
|
|
216
213
|
skip(offset) {
|
|
217
|
-
return new SelectMultiple({ ...this
|
|
214
|
+
return new SelectMultiple({ ...this[QUERY], offset });
|
|
218
215
|
}
|
|
219
|
-
[Expr.
|
|
220
|
-
return new Expr(ExprData.Query(this
|
|
216
|
+
[(QUERY, Expr.ToExpr)]() {
|
|
217
|
+
return new Expr(ExprData.Query(this[QUERY]));
|
|
221
218
|
}
|
|
222
219
|
}
|
|
223
220
|
Cursor2.SelectMultiple = SelectMultiple;
|
|
224
221
|
class TableSelect extends SelectMultiple {
|
|
225
|
-
constructor(
|
|
226
|
-
const target = Target.Table(
|
|
222
|
+
constructor(table, conditions = []) {
|
|
223
|
+
const target = Target.Table(table);
|
|
227
224
|
super(
|
|
228
225
|
Query.Select({
|
|
229
226
|
from: target,
|
|
230
227
|
selection: ExprData.Row(target),
|
|
231
|
-
where: Expr.and(...conditions).
|
|
228
|
+
where: Expr.and(...conditions)[Expr.Data]
|
|
232
229
|
})
|
|
233
230
|
);
|
|
234
|
-
this.table =
|
|
231
|
+
this.table = table;
|
|
235
232
|
}
|
|
236
233
|
as(alias) {
|
|
237
234
|
return createTable({ ...this.table, alias });
|
|
@@ -241,7 +238,7 @@ function addWhere(query, where) {
|
|
|
241
238
|
}
|
|
242
239
|
insertSelect(query) {
|
|
243
240
|
return new Cursor2.Inserted(
|
|
244
|
-
Query.Insert({ into: this.table, select: query
|
|
241
|
+
Query.Insert({ into: this.table, select: query[QUERY] })
|
|
245
242
|
);
|
|
246
243
|
}
|
|
247
244
|
insertOne(record) {
|
|
@@ -261,7 +258,7 @@ function addWhere(query, where) {
|
|
|
261
258
|
return new Cursor2.Update(
|
|
262
259
|
Query.Update({
|
|
263
260
|
table: this.table,
|
|
264
|
-
where: this.
|
|
261
|
+
where: this[QUERY].where
|
|
265
262
|
})
|
|
266
263
|
).set(data);
|
|
267
264
|
}
|
|
@@ -269,7 +266,7 @@ function addWhere(query, where) {
|
|
|
269
266
|
return new Cursor2.Delete(
|
|
270
267
|
Query.Delete({
|
|
271
268
|
table: this.table,
|
|
272
|
-
where: this.
|
|
269
|
+
where: this[QUERY].where
|
|
273
270
|
})
|
|
274
271
|
);
|
|
275
272
|
}
|
|
@@ -279,20 +276,21 @@ function addWhere(query, where) {
|
|
|
279
276
|
);
|
|
280
277
|
}
|
|
281
278
|
}
|
|
279
|
+
QUERY;
|
|
282
280
|
Cursor2.TableSelect = TableSelect;
|
|
283
281
|
class SelectSingle extends Cursor2 {
|
|
284
|
-
query
|
|
285
|
-
|
|
282
|
+
constructor(query) {
|
|
283
|
+
super(query);
|
|
286
284
|
}
|
|
287
285
|
leftJoin(that, ...on) {
|
|
288
|
-
const query = this
|
|
286
|
+
const query = this[QUERY];
|
|
289
287
|
return new SelectSingle({
|
|
290
288
|
...query,
|
|
291
289
|
from: joinTarget("left", query, that, on)
|
|
292
290
|
});
|
|
293
291
|
}
|
|
294
292
|
innerJoin(that, ...on) {
|
|
295
|
-
const query = this
|
|
293
|
+
const query = this[QUERY];
|
|
296
294
|
return new SelectSingle({
|
|
297
295
|
...query,
|
|
298
296
|
from: joinTarget("inner", query, that, on)
|
|
@@ -300,36 +298,36 @@ function addWhere(query, where) {
|
|
|
300
298
|
}
|
|
301
299
|
select(selection) {
|
|
302
300
|
return new SelectSingle({
|
|
303
|
-
...this
|
|
301
|
+
...this[QUERY],
|
|
304
302
|
selection: ExprData.create(selection)
|
|
305
303
|
});
|
|
306
304
|
}
|
|
307
305
|
orderBy(...orderBy) {
|
|
308
306
|
return new SelectSingle({
|
|
309
|
-
...this
|
|
307
|
+
...this[QUERY],
|
|
310
308
|
orderBy
|
|
311
309
|
});
|
|
312
310
|
}
|
|
313
311
|
groupBy(...groupBy) {
|
|
314
312
|
return new SelectSingle({
|
|
315
|
-
...this
|
|
313
|
+
...this[QUERY],
|
|
316
314
|
groupBy: groupBy.map(ExprData.create)
|
|
317
315
|
});
|
|
318
316
|
}
|
|
319
317
|
where(...where) {
|
|
320
|
-
return new SelectSingle(addWhere(this
|
|
318
|
+
return new SelectSingle(addWhere(this[QUERY], where));
|
|
321
319
|
}
|
|
322
320
|
take(limit) {
|
|
323
|
-
return new SelectSingle({ ...this
|
|
321
|
+
return new SelectSingle({ ...this[QUERY], limit });
|
|
324
322
|
}
|
|
325
323
|
skip(offset) {
|
|
326
|
-
return new SelectSingle({ ...this
|
|
324
|
+
return new SelectSingle({ ...this[QUERY], offset });
|
|
327
325
|
}
|
|
328
326
|
all() {
|
|
329
|
-
return new SelectMultiple({ ...this
|
|
327
|
+
return new SelectMultiple({ ...this[QUERY], singleResult: false });
|
|
330
328
|
}
|
|
331
|
-
[Expr.
|
|
332
|
-
return new Expr(ExprData.Query(this
|
|
329
|
+
[(QUERY, Expr.ToExpr)]() {
|
|
330
|
+
return new Expr(ExprData.Query(this[QUERY]));
|
|
333
331
|
}
|
|
334
332
|
}
|
|
335
333
|
Cursor2.SelectSingle = SelectSingle;
|
package/dist/define/Expr.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ import { ParamData } from './Param';
|
|
|
5
5
|
import { Query } from './Query';
|
|
6
6
|
import { Selection } from './Selection';
|
|
7
7
|
import { Target } from './Target';
|
|
8
|
+
declare const TO_EXPR: unique symbol;
|
|
9
|
+
declare const IS_EXPR: unique symbol;
|
|
10
|
+
declare const DATA: unique symbol;
|
|
8
11
|
export declare enum UnOpType {
|
|
9
12
|
Not = "Not",
|
|
10
13
|
IsNull = "IsNull"
|
|
@@ -109,41 +112,38 @@ export declare namespace ExprData {
|
|
|
109
112
|
defaultCase?: ExprData;
|
|
110
113
|
};
|
|
111
114
|
}
|
|
112
|
-
export declare
|
|
113
|
-
UnOp(op: UnOpType, expr: ExprData): ExprData;
|
|
114
|
-
BinOp(op: BinOpType, a: ExprData, b: ExprData): ExprData;
|
|
115
|
-
Field(expr: ExprData, field: string): ExprData;
|
|
116
|
-
Param(param: ParamData): ExprData;
|
|
117
|
-
Call(method: string, params: Array<ExprData>): ExprData;
|
|
118
|
-
Query(query: Query.Select): ExprData;
|
|
119
|
-
Record(fields:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
115
|
+
export declare namespace ExprData {
|
|
116
|
+
function UnOp(op: UnOpType, expr: ExprData): ExprData;
|
|
117
|
+
function BinOp(op: BinOpType, a: ExprData, b: ExprData): ExprData;
|
|
118
|
+
function Field(expr: ExprData, field: string): ExprData;
|
|
119
|
+
function Param(param: ParamData): ExprData;
|
|
120
|
+
function Call(method: string, params: Array<ExprData>): ExprData;
|
|
121
|
+
function Query(query: Query.Select): ExprData;
|
|
122
|
+
function Record(fields: {
|
|
123
|
+
[key: string]: ExprData;
|
|
124
|
+
}): ExprData;
|
|
125
|
+
function Merge(a: ExprData, b: ExprData): ExprData;
|
|
126
|
+
function Row(target: Target): ExprData;
|
|
127
|
+
function Map(target: Target, result: ExprData): ExprData;
|
|
128
|
+
function Filter(target: Target, condition: ExprData): ExprData;
|
|
129
|
+
function Case(expr: ExprData, cases: {
|
|
130
|
+
[key: string]: ExprData;
|
|
131
|
+
}, defaultCase?: ExprData): ExprData;
|
|
132
|
+
function create(input: any): ExprData;
|
|
133
|
+
}
|
|
127
134
|
/** Expression or value of type T */
|
|
128
135
|
export type EV<T> = Expr<T> | T;
|
|
129
|
-
declare const isExpr: unique symbol;
|
|
130
136
|
export declare class Expr<T> {
|
|
131
|
-
expr: ExprData;
|
|
132
|
-
static NULL: Expr<null>;
|
|
133
|
-
static toExpr: symbol;
|
|
134
|
-
static value<T>(value: T): Expr<T>;
|
|
135
|
-
static create<T>(input: EV<T>): Expr<T>;
|
|
136
|
-
static and(...conditions: Array<EV<boolean>>): Expr<boolean>;
|
|
137
|
-
static or(...conditions: Array<EV<boolean>>): Expr<boolean>;
|
|
138
|
-
static isExpr<T>(input: any): input is Expr<T>;
|
|
139
137
|
constructor(expr: ExprData);
|
|
140
|
-
[
|
|
138
|
+
[DATA]: ExprData;
|
|
139
|
+
[IS_EXPR]: boolean;
|
|
141
140
|
asc(): OrderBy;
|
|
142
141
|
desc(): OrderBy;
|
|
143
142
|
not(): Expr<boolean>;
|
|
144
143
|
or(this: Expr<boolean>, that: EV<boolean>): Expr<boolean>;
|
|
145
144
|
and(this: Expr<boolean>, that: EV<boolean>): Expr<boolean>;
|
|
146
145
|
is(that: EV<T> | Cursor.SelectSingle<T>): Expr<boolean>;
|
|
146
|
+
isConstant(value: T): boolean;
|
|
147
147
|
isNot(that: EV<T>): Expr<boolean>;
|
|
148
148
|
isNull(): Expr<boolean>;
|
|
149
149
|
isNotNull(): Expr<boolean>;
|
|
@@ -163,6 +163,13 @@ export declare class Expr<T> {
|
|
|
163
163
|
glob(this: Expr<string>, that: EV<string>): Expr<boolean>;
|
|
164
164
|
match(this: Expr<string>, that: EV<string>): Expr<boolean>;
|
|
165
165
|
with<X extends Selection>(that: X): Selection.With<T, X>;
|
|
166
|
+
/**
|
|
167
|
+
* Dynamic expressions allow accessing runtime fields of JSON properties
|
|
168
|
+
* through a Proxy.
|
|
169
|
+
*
|
|
170
|
+
* Expr.value({a: {b: 1}}).dynamic().a.b.is(1) // true
|
|
171
|
+
**/
|
|
172
|
+
dynamic<X = T>(...path: Array<string>): Fields<X>;
|
|
166
173
|
at<T>(this: Expr<Array<T>>, index: number): Expr<T | null>;
|
|
167
174
|
includes<T>(this: Expr<Array<T>>, value: EV<T>): Expr<boolean>;
|
|
168
175
|
filter<T>(this: Expr<Array<T>>, fn: (cursor: Fields<T>) => Expr<boolean>): Expr<Array<T>>;
|
|
@@ -171,8 +178,14 @@ export declare class Expr<T> {
|
|
|
171
178
|
get<T>(name: string): Expr<T>;
|
|
172
179
|
}
|
|
173
180
|
export declare namespace Expr {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
181
|
+
const NULL: Expr<null>;
|
|
182
|
+
const Data: typeof DATA;
|
|
183
|
+
const IsExpr: typeof IS_EXPR;
|
|
184
|
+
const ToExpr: typeof TO_EXPR;
|
|
185
|
+
function value<T>(value: T): Expr<T>;
|
|
186
|
+
function create<T>(input: EV<T>): Expr<T>;
|
|
187
|
+
function and(...conditions: Array<EV<boolean>>): Expr<boolean>;
|
|
188
|
+
function or(...conditions: Array<EV<boolean>>): Expr<boolean>;
|
|
189
|
+
function isExpr<T>(input: any): input is Expr<T>;
|
|
177
190
|
}
|
|
178
191
|
export {};
|