objection 3.0.0-alpha.3 → 3.0.0-rc.1
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 +2 -1
- package/lib/model/Model.js +3 -41
- package/lib/model/modelTableMetadata.js +4 -0
- package/lib/objection.js +0 -8
- package/lib/queryBuilder/QueryBuilder.js +1 -367
- package/lib/queryBuilder/QueryBuilderOperationSupport.js +0 -9
- package/lib/queryBuilder/ReferenceBuilder.js +0 -8
- package/lib/relations/RelationOwner.js +2 -0
- package/lib/utils/objectUtils.js +19 -3
- package/package.json +10 -36
- package/typings/objection/index.d.ts +14 -176
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
[](https://github.com/Vincit/objection.js)
|
|
2
|
+
[](https://gitter.im/Vincit/objection.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
2
3
|
|
|
3
4
|
# [Objection.js](https://vincit.github.io/objection.js)
|
|
4
5
|
|
package/lib/model/Model.js
CHANGED
|
@@ -4,8 +4,6 @@ const { clone } = require('./modelClone');
|
|
|
4
4
|
const { bindKnex } = require('./modelBindKnex');
|
|
5
5
|
const { validate } = require('./modelValidate');
|
|
6
6
|
const { isMsSql } = require('../utils/knexUtils');
|
|
7
|
-
const { deprecate } = require('../utils/deprecate');
|
|
8
|
-
const { omit, pick } = require('./modelFilter');
|
|
9
7
|
const { visitModels } = require('./modelVisitor');
|
|
10
8
|
const { hasId, getSetId } = require('./modelId');
|
|
11
9
|
const { map: promiseMap } = require('../utils/promiseUtils');
|
|
@@ -79,11 +77,6 @@ class Model {
|
|
|
79
77
|
}).for(this);
|
|
80
78
|
}
|
|
81
79
|
|
|
82
|
-
$loadRelated(relationExpression, modifiers, transaction) {
|
|
83
|
-
deprecate('$loadRelated is deprected and will be removed in 3.0. Use $fetchGraph instead');
|
|
84
|
-
return this.$fetchGraph(relationExpression, { transaction }).modifiers(modifiers);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
80
|
$fetchGraph(relationExpression, options) {
|
|
88
81
|
return this.constructor.fetchGraph(this, relationExpression, options);
|
|
89
82
|
}
|
|
@@ -179,7 +172,7 @@ class Model {
|
|
|
179
172
|
// Do nothing by default.
|
|
180
173
|
}
|
|
181
174
|
|
|
182
|
-
// TODO: Deprecate & remove
|
|
175
|
+
// TODO: Deprecate & remove
|
|
183
176
|
$afterGet(queryContext) {
|
|
184
177
|
// Do nothing by default.
|
|
185
178
|
}
|
|
@@ -196,16 +189,6 @@ class Model {
|
|
|
196
189
|
// Do nothing by default.
|
|
197
190
|
}
|
|
198
191
|
|
|
199
|
-
$omit(...args) {
|
|
200
|
-
deprecate('Model#$omit is deprected and will be removed in 3.0.');
|
|
201
|
-
return omit(this, args);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
$pick(...args) {
|
|
205
|
-
deprecate('Model#$pick is deprected and will be removed in 3.0.');
|
|
206
|
-
return pick(this, args);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
192
|
$values(props) {
|
|
210
193
|
return values(this, props);
|
|
211
194
|
}
|
|
@@ -427,7 +410,7 @@ class Model {
|
|
|
427
410
|
}
|
|
428
411
|
|
|
429
412
|
static getModifiers() {
|
|
430
|
-
return this.modifiers ||
|
|
413
|
+
return this.modifiers || {};
|
|
431
414
|
}
|
|
432
415
|
|
|
433
416
|
static columnNameToPropertyName(columnName) {
|
|
@@ -503,22 +486,14 @@ class Model {
|
|
|
503
486
|
}
|
|
504
487
|
|
|
505
488
|
static getDefaultGraphOptions() {
|
|
506
|
-
return this.defaultGraphOptions
|
|
489
|
+
return this.defaultGraphOptions;
|
|
507
490
|
}
|
|
508
491
|
|
|
509
492
|
static getRelatedFindQueryMutates() {
|
|
510
|
-
if (this.relatedFindQueryMutates) {
|
|
511
|
-
deprecate('Model.relatedFindQueryMutates is deprected and will be removed in 3.0.');
|
|
512
|
-
}
|
|
513
|
-
|
|
514
493
|
return this.relatedFindQueryMutates;
|
|
515
494
|
}
|
|
516
495
|
|
|
517
496
|
static getRelatedInsertQueryMutates() {
|
|
518
|
-
if (this.relatedInsertQueryMutates) {
|
|
519
|
-
deprecate('Model.relatedInsertQueryMutates is deprected and will be removed in 3.0.');
|
|
520
|
-
}
|
|
521
|
-
|
|
522
497
|
return this.relatedInsertQueryMutates;
|
|
523
498
|
}
|
|
524
499
|
|
|
@@ -662,11 +637,6 @@ class Model {
|
|
|
662
637
|
return relation;
|
|
663
638
|
}
|
|
664
639
|
|
|
665
|
-
static loadRelated(models, expression, modifiers, transaction) {
|
|
666
|
-
deprecate('loadRelated is deprected and will be removed in 3.0. Use fetchGraph instead');
|
|
667
|
-
return this.fetchGraph(models, expression, { transaction }).modifiers(modifiers);
|
|
668
|
-
}
|
|
669
|
-
|
|
670
640
|
static fetchGraph($models, expression, options = {}) {
|
|
671
641
|
return this.query(options.transaction)
|
|
672
642
|
.resolve(this.ensureModelArray($models))
|
|
@@ -765,20 +735,12 @@ Model.virtualAttributes = null;
|
|
|
765
735
|
Model.relationMappings = null;
|
|
766
736
|
Model.modelPaths = [];
|
|
767
737
|
Model.pickJsonSchemaProperties = false;
|
|
768
|
-
// Deprecated.
|
|
769
|
-
Model.defaultEagerAlgorithm = Model.WhereInEagerAlgorithm;
|
|
770
|
-
// Deprecated.
|
|
771
|
-
Model.defaultEagerOptions = Object.freeze({ minimize: false, separator: ':', aliases: {} });
|
|
772
738
|
Model.defaultGraphOptions = null;
|
|
773
739
|
Model.defaultFindOptions = Object.freeze({});
|
|
774
740
|
Model.modifiers = null;
|
|
775
|
-
// Deprecated.
|
|
776
|
-
Model.namedFilters = null;
|
|
777
741
|
Model.useLimitInFirst = false;
|
|
778
742
|
Model.columnNameMappers = null;
|
|
779
|
-
// Deprecated.
|
|
780
743
|
Model.relatedFindQueryMutates = false;
|
|
781
|
-
// Deprecated.
|
|
782
744
|
Model.relatedInsertQueryMutates = false;
|
|
783
745
|
Model.concurrency = null;
|
|
784
746
|
|
package/lib/objection.js
CHANGED
|
@@ -29,9 +29,7 @@ const { ref } = require('./queryBuilder/ReferenceBuilder');
|
|
|
29
29
|
const { val } = require('./queryBuilder/ValueBuilder');
|
|
30
30
|
const { raw } = require('./queryBuilder/RawBuilder');
|
|
31
31
|
const { fn } = require('./queryBuilder/FunctionBuilder');
|
|
32
|
-
|
|
33
32
|
const { inherit } = require('../lib/utils/classUtils');
|
|
34
|
-
const { deprecate } = require('../lib/utils/deprecate');
|
|
35
33
|
|
|
36
34
|
// We need to wrap the classes, that people can inherit, with ES5 classes
|
|
37
35
|
// so that babel is able to use ES5 inheritance. sigh... Maybe people
|
|
@@ -86,12 +84,6 @@ module.exports = {
|
|
|
86
84
|
val,
|
|
87
85
|
raw,
|
|
88
86
|
fn,
|
|
89
|
-
|
|
90
|
-
get lit() {
|
|
91
|
-
deprecate('`lit` is deprecated. Use `val` instead. `lit` will be removed in 3.0');
|
|
92
|
-
return val;
|
|
93
|
-
},
|
|
94
|
-
|
|
95
87
|
snakeCaseMappers,
|
|
96
88
|
knexSnakeCaseMappers,
|
|
97
89
|
knexIdentifierMapping,
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
const { wrapError } = require('db-errors');
|
|
4
4
|
|
|
5
5
|
const { raw } = require('./RawBuilder');
|
|
6
|
-
const { deprecate } = require('../utils/deprecate');
|
|
7
6
|
const { createModifier } = require('../utils/createModifier');
|
|
8
7
|
const { ValidationErrorType } = require('../model/ValidationError');
|
|
9
8
|
const { isObject, isString, isFunction, last, flatten } = require('../utils/objectUtils');
|
|
@@ -112,22 +111,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
112
111
|
return this.fullIdColumnFor(this.modelClass());
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
applyModifier(...args) {
|
|
116
|
-
deprecate(
|
|
117
|
-
'applyModifier is deprecated. Use the modify method instead. applyModifier will be removed in objection 3.0'
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
return this.modify(flatten(args));
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
applyFilter(...args) {
|
|
124
|
-
deprecate(
|
|
125
|
-
'applyFilter is deprecated. Use the modify method instead. applyFilter will be removed in objection 3.0'
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
return this.modify(flatten(args));
|
|
129
|
-
}
|
|
130
|
-
|
|
131
114
|
modifiers(modifiers) {
|
|
132
115
|
if (arguments.length === 0) {
|
|
133
116
|
return { ...this._modifiers };
|
|
@@ -224,102 +207,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
224
207
|
return this;
|
|
225
208
|
}
|
|
226
209
|
|
|
227
|
-
eagerAlgorithm(...args) {
|
|
228
|
-
deprecate(
|
|
229
|
-
'`QueryBuilder#eagerAlgorithm` method is deprecated. You should explicitly use either withGraphFetched or withGraphJoined methods. `eagerAlgoritm` method will be removed in 3.0'
|
|
230
|
-
);
|
|
231
|
-
|
|
232
|
-
return this._eagerAlgorithm(...args);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
_eagerAlgorithm(algorithm, eagerOptions) {
|
|
236
|
-
ensureEagerOperation(this, algorithm);
|
|
237
|
-
|
|
238
|
-
if (eagerOptions) {
|
|
239
|
-
this._eagerOptions(eagerOptions);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return this;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
eager(...args) {
|
|
246
|
-
deprecate(
|
|
247
|
-
'`QueryBuilder#eager` method is deprecated. You should use the `withGraphFetched` method instead. `eager` method will be removed in 3.0'
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
return this._eager(...args);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
_eager(exp, modifiers) {
|
|
254
|
-
const eagerOp = ensureEagerOperation(this);
|
|
255
|
-
|
|
256
|
-
eagerOp.expression = parseRelationExpression(this.modelClass(), exp);
|
|
257
|
-
checkEager(this);
|
|
258
|
-
|
|
259
|
-
if (modifiers) {
|
|
260
|
-
this.clearModifiers().modifiers(modifiers);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return this;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
joinEager(exp, modifiers) {
|
|
267
|
-
deprecate(
|
|
268
|
-
'`QueryBuilder#joinEager` method is deprecated. You should use the `withGraphJoined` method instead. `joinEager` method will be removed in 3.0'
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
return this._eagerAlgorithm(getJoinEagerAlgorithm(this))._eager(exp, modifiers);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
naiveEager(exp, modifiers) {
|
|
275
|
-
deprecate(
|
|
276
|
-
'`QueryBuilder#naiveEager` method is deprecated. You should use the `withGraphFetched` method with the `maxBatchSize: 1` option instead. `naiveEager` method will be removed in 3.0'
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
return this._eagerAlgorithm(getNaiveEagerAlgorithm(this))._eager(exp, modifiers);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
mergeEager(...args) {
|
|
283
|
-
deprecate(
|
|
284
|
-
'`QueryBuilder#mergeEager` method is deprecated. You should use the `withGraphFetched` method instead. `mergeEager` method will be removed in 3.0'
|
|
285
|
-
);
|
|
286
|
-
|
|
287
|
-
return this._mergeEager(...args);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
_mergeEager(exp, modifiers) {
|
|
291
|
-
const eagerOp = ensureEagerOperation(this);
|
|
292
|
-
|
|
293
|
-
eagerOp.expression = eagerOp.expression.merge(parseRelationExpression(this.modelClass(), exp));
|
|
294
|
-
checkEager(this);
|
|
295
|
-
|
|
296
|
-
return this.modifiers(modifiers);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
mergeJoinEager(exp, modifiers) {
|
|
300
|
-
deprecate(
|
|
301
|
-
'`QueryBuilder#mergeJoinEager` method is deprecated. You should use the `withGraphJoined` method instead. `mergeJoinEager` method will be removed in 3.0'
|
|
302
|
-
);
|
|
303
|
-
|
|
304
|
-
return this._eagerAlgorithm(this.modelClass().JoinEagerAlgorithm)._mergeEager(exp, modifiers);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
mergeNaiveEager(exp, modifiers) {
|
|
308
|
-
deprecate(
|
|
309
|
-
'`QueryBuilder#mergeNaiveEager` method is deprecated. You should use the `withGraphFetched` method with the `maxBatchSize: 1` option instead. `mergeNaiveEager` method will be removed in 3.0'
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
return this._eagerAlgorithm(this.modelClass().NaiveEagerAlgorithm)._mergeEager(exp, modifiers);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
allowEager(exp) {
|
|
316
|
-
deprecate(
|
|
317
|
-
'`QueryBuilder#allowEager` method is deprecated. You should use `allowGraph` instead. `allowEager` method will be removed in 3.0'
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
return this.clearAllowGraph().allowGraph(exp);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
210
|
allowGraph(exp) {
|
|
324
211
|
const currentExpr = this._allowedGraphExpression || RelationExpression.create();
|
|
325
212
|
|
|
@@ -335,22 +222,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
335
222
|
return this._allowedGraphExpression;
|
|
336
223
|
}
|
|
337
224
|
|
|
338
|
-
mergeAllowEager(exp) {
|
|
339
|
-
deprecate(
|
|
340
|
-
'`QueryBuilder#mergeAllowEager` method is deprecated. You should use `allowGraph` instead. `mergeAllowEager` method will be removed in 3.0'
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
return this.allowGraph(exp);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
eagerObject() {
|
|
347
|
-
deprecate(
|
|
348
|
-
'`QueryBuilder#eagerObject` method is deprecated. You should use `graphExpressionObject` instead. `eagerObject` method will be removed in 3.0'
|
|
349
|
-
);
|
|
350
|
-
|
|
351
|
-
return this.graphExpressionObject();
|
|
352
|
-
}
|
|
353
|
-
|
|
354
225
|
graphExpressionObject() {
|
|
355
226
|
const eagerOp = this.findOperation(EagerOperation);
|
|
356
227
|
|
|
@@ -361,22 +232,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
361
232
|
}
|
|
362
233
|
}
|
|
363
234
|
|
|
364
|
-
eagerModifiers() {
|
|
365
|
-
deprecate(
|
|
366
|
-
'`QueryBuilder#eagerModifiers` method is deprecated. You should use `modifiers` instead. `eagerModifiers` method will be removed in 3.0'
|
|
367
|
-
);
|
|
368
|
-
|
|
369
|
-
return this.modifiers();
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
eagerModifiersAtPath() {
|
|
373
|
-
deprecate(
|
|
374
|
-
'`QueryBuilder#eagerModifiersAtPath` method is deprecated. You should use `graphModifiersAtPath` instead. `eagerModifiersAtPath` method will be removed in 3.0'
|
|
375
|
-
);
|
|
376
|
-
|
|
377
|
-
return this.graphModifiersAtPath();
|
|
378
|
-
}
|
|
379
|
-
|
|
380
235
|
graphModifiersAtPath() {
|
|
381
236
|
const eagerOp = this.findOperation(EagerOperation);
|
|
382
237
|
|
|
@@ -387,58 +242,12 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
387
242
|
}
|
|
388
243
|
}
|
|
389
244
|
|
|
390
|
-
modifyEager(...args) {
|
|
391
|
-
deprecate(
|
|
392
|
-
'`QueryBuilder#modifyEager` method is deprecated. You should use `modifyGraph` instead. `modifyEager` method will be removed in 3.0'
|
|
393
|
-
);
|
|
394
|
-
|
|
395
|
-
return this.modifyGraph(...args);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
245
|
modifyGraph(path, modifier) {
|
|
399
246
|
const eagerOp = ensureEagerOperation(this);
|
|
400
247
|
eagerOp.modifiersAtPath.push({ path, modifier });
|
|
401
248
|
return this;
|
|
402
249
|
}
|
|
403
250
|
|
|
404
|
-
filterEager(...args) {
|
|
405
|
-
deprecate(
|
|
406
|
-
'`QueryBuilder#filterEager` method is deprecated. You should use `modifyGraph` instead. `filterEager` method will be removed in 3.0'
|
|
407
|
-
);
|
|
408
|
-
|
|
409
|
-
return this.modifyGraph(...args);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
allowUpsert(exp) {
|
|
413
|
-
deprecate(
|
|
414
|
-
'`QueryBuilder#allowUpsert` method is deprecated. You should use `allowGraph` instead. `allowUpsert` method will be removed in 3.0'
|
|
415
|
-
);
|
|
416
|
-
|
|
417
|
-
return this.clearAllowGraph().allowGraph(exp);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
allowInsert(exp) {
|
|
421
|
-
deprecate(
|
|
422
|
-
'`QueryBuilder#allowInsert` method is deprecated. You should use `allowGraph` instead. `allowInsert` method will be removed in 3.0'
|
|
423
|
-
);
|
|
424
|
-
|
|
425
|
-
return this.clearAllowGraph().allowGraph(exp);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
eagerOptions(...args) {
|
|
429
|
-
deprecate(
|
|
430
|
-
'`QueryBuilder#eagerOptions` method is deprecated. You should use `withGraphFetched` or `withGraphJoined` and pass options in the second argument. `eagerOptions` method will be removed in 3.0'
|
|
431
|
-
);
|
|
432
|
-
|
|
433
|
-
return this._eagerOptions(...args);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
_eagerOptions(opt) {
|
|
437
|
-
const eagerOp = ensureEagerOperation(this);
|
|
438
|
-
eagerOp.graphOptions = Object.assign({}, eagerOp.graphOptions, opt);
|
|
439
|
-
return this;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
251
|
findOptions(opt) {
|
|
443
252
|
if (arguments.length !== 0) {
|
|
444
253
|
this._findOperationOptions = Object.assign({}, this._findOperationOptions, opt);
|
|
@@ -491,14 +300,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
491
300
|
return this.has(QueryBuilderBase.SelectSelector);
|
|
492
301
|
}
|
|
493
302
|
|
|
494
|
-
hasEager() {
|
|
495
|
-
deprecate(
|
|
496
|
-
`QueryBuilder#hasEager is deprecated. Use hasWithGraph instead. This method will be removed in version 3.0`
|
|
497
|
-
);
|
|
498
|
-
|
|
499
|
-
return this.hasWithGraph();
|
|
500
|
-
}
|
|
501
|
-
|
|
502
303
|
hasWithGraph() {
|
|
503
304
|
const eagerOp = this.findOperation(EagerOperation);
|
|
504
305
|
return !!eagerOp && !eagerOp.expression.isEmpty;
|
|
@@ -532,20 +333,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
532
333
|
});
|
|
533
334
|
}
|
|
534
335
|
|
|
535
|
-
isFindQuery() {
|
|
536
|
-
deprecate(
|
|
537
|
-
`isFindQuery is deprecated. Use isFind instead. This method will be removed in version 2.0`
|
|
538
|
-
);
|
|
539
|
-
return this.isFind();
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
isEagerQuery() {
|
|
543
|
-
deprecate(
|
|
544
|
-
`isEagerQuery is deprecated. Use hasWithGraph instead. This method will be removed in version 2.0`
|
|
545
|
-
);
|
|
546
|
-
return this.hasEager();
|
|
547
|
-
}
|
|
548
|
-
|
|
549
336
|
toString() {
|
|
550
337
|
return '[object QueryBuilder]';
|
|
551
338
|
}
|
|
@@ -584,14 +371,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
584
371
|
return builder;
|
|
585
372
|
}
|
|
586
373
|
|
|
587
|
-
clearEager() {
|
|
588
|
-
deprecate(
|
|
589
|
-
'`QueryBuilder#clearEager` method is deprecated. You should use `clearWithGraph` instead. `clearEager` method will be removed in 3.0'
|
|
590
|
-
);
|
|
591
|
-
|
|
592
|
-
return this.clearWithGraph();
|
|
593
|
-
}
|
|
594
|
-
|
|
595
374
|
clearWithGraph() {
|
|
596
375
|
this.clear(EagerOperation);
|
|
597
376
|
return this;
|
|
@@ -671,20 +450,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
671
450
|
}
|
|
672
451
|
}
|
|
673
452
|
|
|
674
|
-
pluck(propertyName) {
|
|
675
|
-
deprecate(`QueryBuilder#pluck is deprecated. This method will be removed in version 3.0`);
|
|
676
|
-
|
|
677
|
-
return this.runAfter((result) => {
|
|
678
|
-
if (Array.isArray(result)) {
|
|
679
|
-
return result.map((it) => it && it[propertyName]);
|
|
680
|
-
} else if (isObject(result)) {
|
|
681
|
-
return result[propertyName];
|
|
682
|
-
} else {
|
|
683
|
-
return result;
|
|
684
|
-
}
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
|
|
688
453
|
throwIfNotFound(data = {}) {
|
|
689
454
|
return this.runAfter((result) => {
|
|
690
455
|
if (
|
|
@@ -776,47 +541,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
776
541
|
});
|
|
777
542
|
}
|
|
778
543
|
|
|
779
|
-
pick(modelClass, properties) {
|
|
780
|
-
deprecate(`QueryBuilder#pick is deprecated. This method will be removed in version 3.0`);
|
|
781
|
-
|
|
782
|
-
if (typeof properties === 'undefined') {
|
|
783
|
-
properties = modelClass;
|
|
784
|
-
modelClass = null;
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
// Turn the properties into a hash for performance.
|
|
788
|
-
properties = properties.reduce((obj, prop) => {
|
|
789
|
-
obj[prop] = true;
|
|
790
|
-
return obj;
|
|
791
|
-
}, {});
|
|
792
|
-
|
|
793
|
-
return this.traverse(modelClass, (model) => {
|
|
794
|
-
model.$pick(properties);
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
omit(modelClass, properties) {
|
|
799
|
-
deprecate(`QueryBuilder#omit is deprecated. This method will be removed in version 3.0`);
|
|
800
|
-
|
|
801
|
-
if (typeof properties === 'undefined') {
|
|
802
|
-
properties = modelClass;
|
|
803
|
-
modelClass = null;
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
if (Array.isArray(properties)) {
|
|
807
|
-
// Turn the properties into a hash for performance.
|
|
808
|
-
properties = properties.reduce((obj, prop) => {
|
|
809
|
-
obj[prop] = true;
|
|
810
|
-
return obj;
|
|
811
|
-
}, {});
|
|
812
|
-
} else {
|
|
813
|
-
properties = { [properties]: true };
|
|
814
|
-
}
|
|
815
|
-
return this.traverse(modelClass, (model) => {
|
|
816
|
-
model.$omit(properties);
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
|
|
820
544
|
page(page, pageSize) {
|
|
821
545
|
return this.range(+page * +pageSize, (+page + 1) * +pageSize - 1);
|
|
822
546
|
}
|
|
@@ -897,13 +621,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
897
621
|
});
|
|
898
622
|
}
|
|
899
623
|
|
|
900
|
-
insertWithRelated(...args) {
|
|
901
|
-
deprecate(
|
|
902
|
-
`insertWithRelated is deprecated. Use insertGraph instead. This method will be removed in version 2.0`
|
|
903
|
-
);
|
|
904
|
-
return this.insertGraph(...args);
|
|
905
|
-
}
|
|
906
|
-
|
|
907
624
|
insertGraphAndFetch(modelsOrObjects, opt) {
|
|
908
625
|
return writeOperation(this, () => {
|
|
909
626
|
const insertOperation = this._insertOperationFactory(this);
|
|
@@ -921,13 +638,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
921
638
|
});
|
|
922
639
|
}
|
|
923
640
|
|
|
924
|
-
insertWithRelatedAndFetch(...args) {
|
|
925
|
-
deprecate(
|
|
926
|
-
`insertWithRelatedAndFetch is deprecated. Use insertGraphAndFetch instead. This method will be removed in version 2.0`
|
|
927
|
-
);
|
|
928
|
-
return this.insertGraphAndFetch(...args);
|
|
929
|
-
}
|
|
930
|
-
|
|
931
641
|
update(modelOrObject) {
|
|
932
642
|
return writeOperation(this, () => {
|
|
933
643
|
const updateOperation = this._updateOperationFactory(this);
|
|
@@ -1107,14 +817,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
1107
817
|
return this;
|
|
1108
818
|
}
|
|
1109
819
|
|
|
1110
|
-
joinRelation(...args) {
|
|
1111
|
-
deprecate(
|
|
1112
|
-
`joinRelation is deprecated. Use joinRelated instead. This method will be removed in version 3.0`
|
|
1113
|
-
);
|
|
1114
|
-
|
|
1115
|
-
return this.joinRelated(...args);
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
820
|
innerJoinRelated(expression, options) {
|
|
1119
821
|
ensureJoinRelatedOperation(this, 'innerJoin').addCall({
|
|
1120
822
|
expression,
|
|
@@ -1124,14 +826,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
1124
826
|
return this;
|
|
1125
827
|
}
|
|
1126
828
|
|
|
1127
|
-
innerJoinRelation(...args) {
|
|
1128
|
-
deprecate(
|
|
1129
|
-
`innerJoinRelation is deprecated. Use innerJoinRelated instead. This method will be removed in version 3.0`
|
|
1130
|
-
);
|
|
1131
|
-
|
|
1132
|
-
return this.innerJoinRelated(...args);
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
829
|
outerJoinRelated(expression, options) {
|
|
1136
830
|
ensureJoinRelatedOperation(this, 'outerJoin').addCall({
|
|
1137
831
|
expression,
|
|
@@ -1141,14 +835,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
1141
835
|
return this;
|
|
1142
836
|
}
|
|
1143
837
|
|
|
1144
|
-
outerJoinRelation(...args) {
|
|
1145
|
-
deprecate(
|
|
1146
|
-
`outerJoinRelation is deprecated. Use outerJoinRelated instead. This method will be removed in version 3.0`
|
|
1147
|
-
);
|
|
1148
|
-
|
|
1149
|
-
return this.outerJoinRelated(...args);
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
838
|
fullOuterJoinRelated(expression, options) {
|
|
1153
839
|
ensureJoinRelatedOperation(this, 'fullOuterJoin').addCall({
|
|
1154
840
|
expression,
|
|
@@ -1158,14 +844,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
1158
844
|
return this;
|
|
1159
845
|
}
|
|
1160
846
|
|
|
1161
|
-
fullOuterJoinRelation(...args) {
|
|
1162
|
-
deprecate(
|
|
1163
|
-
`fullOuterJoinRelation is deprecated. Use fullOuterJoinRelated instead. This method will be removed in version 3.0`
|
|
1164
|
-
);
|
|
1165
|
-
|
|
1166
|
-
return this.fullOuterJoinRelated(...args);
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
847
|
leftJoinRelated(expression, options) {
|
|
1170
848
|
ensureJoinRelatedOperation(this, 'leftJoin').addCall({
|
|
1171
849
|
expression,
|
|
@@ -1175,14 +853,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
1175
853
|
return this;
|
|
1176
854
|
}
|
|
1177
855
|
|
|
1178
|
-
leftJoinRelation(...args) {
|
|
1179
|
-
deprecate(
|
|
1180
|
-
`leftJoinRelation is deprecated. Use leftJoinRelated instead. This method will be removed in version 3.0`
|
|
1181
|
-
);
|
|
1182
|
-
|
|
1183
|
-
return this.leftJoinRelated(...args);
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
856
|
leftOuterJoinRelated(expression, options) {
|
|
1187
857
|
ensureJoinRelatedOperation(this, 'leftOuterJoin').addCall({
|
|
1188
858
|
expression,
|
|
@@ -1192,14 +862,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
1192
862
|
return this;
|
|
1193
863
|
}
|
|
1194
864
|
|
|
1195
|
-
leftOuterJoinRelation(...args) {
|
|
1196
|
-
deprecate(
|
|
1197
|
-
`leftOuterJoinRelation is deprecated. Use leftOuterJoinRelated instead. This method will be removed in version 3.0`
|
|
1198
|
-
);
|
|
1199
|
-
|
|
1200
|
-
return this.leftOuterJoinRelated(...args);
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
865
|
rightJoinRelated(expression, options) {
|
|
1204
866
|
ensureJoinRelatedOperation(this, 'rightJoin').addCall({
|
|
1205
867
|
expression,
|
|
@@ -1209,14 +871,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
1209
871
|
return this;
|
|
1210
872
|
}
|
|
1211
873
|
|
|
1212
|
-
rightJoinRelation(...args) {
|
|
1213
|
-
deprecate(
|
|
1214
|
-
`rightJoinRelation is deprecated. Use rightJoinRelated instead. This method will be removed in version 3.0`
|
|
1215
|
-
);
|
|
1216
|
-
|
|
1217
|
-
return this.rightJoinRelated(...args);
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
874
|
rightOuterJoinRelated(expression, options) {
|
|
1221
875
|
ensureJoinRelatedOperation(this, 'rightOuterJoin').addCall({
|
|
1222
876
|
expression,
|
|
@@ -1226,14 +880,6 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
1226
880
|
return this;
|
|
1227
881
|
}
|
|
1228
882
|
|
|
1229
|
-
rightOuterJoinRelation(...args) {
|
|
1230
|
-
deprecate(
|
|
1231
|
-
`rightOuterJoinRelation is deprecated. Use rightOuterJoinRelated instead. This method will be removed in version 3.0`
|
|
1232
|
-
);
|
|
1233
|
-
|
|
1234
|
-
return this.rightOuterJoinRelated(...args);
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
883
|
deleteById(id) {
|
|
1238
884
|
return this.findById(id)
|
|
1239
885
|
.delete()
|
|
@@ -1336,7 +982,7 @@ function ensureEagerOperation(builder, algorithm = null) {
|
|
|
1336
982
|
} else {
|
|
1337
983
|
const EagerOperationClass = getOperationClassForEagerAlgorithm(
|
|
1338
984
|
builder,
|
|
1339
|
-
|
|
985
|
+
getWhereInEagerAlgorithm(builder)
|
|
1340
986
|
);
|
|
1341
987
|
|
|
1342
988
|
const newEagerOp = new EagerOperationClass('eager', {
|
|
@@ -1350,18 +996,6 @@ function ensureEagerOperation(builder, algorithm = null) {
|
|
|
1350
996
|
}
|
|
1351
997
|
}
|
|
1352
998
|
|
|
1353
|
-
function getDefaultEagerAlgorithm(builder) {
|
|
1354
|
-
const eagerAlgorithm = builder.modelClass().defaultEagerAlgorithm;
|
|
1355
|
-
|
|
1356
|
-
if (eagerAlgorithm !== getWhereInEagerAlgorithm(builder)) {
|
|
1357
|
-
deprecate(
|
|
1358
|
-
'Model.defaultEagerAlgorithm is deprecated. You need to use `withGraphFetched` or `withGraphJoined` explicitly. `defaultEagerAlgorithm` will be removed in 3.0'
|
|
1359
|
-
);
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
return eagerAlgorithm;
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
999
|
function getWhereInEagerAlgorithm(builder) {
|
|
1366
1000
|
return builder.modelClass().WhereInEagerAlgorithm;
|
|
1367
1001
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { deprecate } = require('../utils/deprecate');
|
|
4
3
|
const { isString, isFunction, isRegExp, last } = require('../utils/objectUtils');
|
|
5
4
|
const { QueryBuilderContextBase } = require('./QueryBuilderContextBase');
|
|
6
5
|
const { QueryBuilderUserContext } = require('./QueryBuilderUserContext');
|
|
@@ -83,14 +82,6 @@ class QueryBuilderOperationSupport {
|
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
mergeContext(obj) {
|
|
87
|
-
deprecate(
|
|
88
|
-
'`QueryBuilder#mergeContext` method is deprecated. The `context` method now behaves just like `mergeContext`. `mergeContext` method will be removed in 3.0'
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
return this.context(obj || {});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
85
|
clearContext() {
|
|
95
86
|
const ctx = this._context;
|
|
96
87
|
ctx.userContext = new this.constructor.QueryBuilderUserContext(this);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const { parseFieldExpression } = require('../utils/parseFieldExpression');
|
|
4
4
|
const { isObject } = require('../utils/objectUtils');
|
|
5
|
-
const { deprecate } = require('../utils/deprecate');
|
|
6
5
|
|
|
7
6
|
class ReferenceBuilder {
|
|
8
7
|
constructor(expr) {
|
|
@@ -120,13 +119,6 @@ class ReferenceBuilder {
|
|
|
120
119
|
return this;
|
|
121
120
|
}
|
|
122
121
|
|
|
123
|
-
castType(sqlType) {
|
|
124
|
-
deprecate(
|
|
125
|
-
'castType(type) is deprecated. Use castTo(type) instead. castType(type) will be removed in 2.0'
|
|
126
|
-
);
|
|
127
|
-
return this.castTo(sqlType);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
122
|
castTo(sqlType) {
|
|
131
123
|
this._cast = sqlType;
|
|
132
124
|
return this;
|
package/lib/utils/objectUtils.js
CHANGED
|
@@ -189,7 +189,6 @@ function once(func) {
|
|
|
189
189
|
|
|
190
190
|
function flatten(arrays) {
|
|
191
191
|
const out = [];
|
|
192
|
-
let outIdx = 0;
|
|
193
192
|
|
|
194
193
|
for (let i = 0, l = arrays.length; i < l; ++i) {
|
|
195
194
|
const value = arrays[i];
|
|
@@ -225,6 +224,11 @@ function set(obj, path, value) {
|
|
|
225
224
|
|
|
226
225
|
for (let i = 0, l = path.length - 1; i < l; ++i) {
|
|
227
226
|
const key = path[i];
|
|
227
|
+
|
|
228
|
+
if (!isSafeKey(key)) {
|
|
229
|
+
return inputObj;
|
|
230
|
+
}
|
|
231
|
+
|
|
228
232
|
let child = obj[key];
|
|
229
233
|
|
|
230
234
|
if (!isObject(child)) {
|
|
@@ -243,7 +247,11 @@ function set(obj, path, value) {
|
|
|
243
247
|
}
|
|
244
248
|
|
|
245
249
|
if (path.length > 0 && isObject(obj)) {
|
|
246
|
-
|
|
250
|
+
const key = path[path.length - 1];
|
|
251
|
+
|
|
252
|
+
if (isSafeKey(key)) {
|
|
253
|
+
obj[key] = value;
|
|
254
|
+
}
|
|
247
255
|
}
|
|
248
256
|
|
|
249
257
|
return inputObj;
|
|
@@ -253,7 +261,11 @@ function zipObject(keys, values) {
|
|
|
253
261
|
const out = {};
|
|
254
262
|
|
|
255
263
|
for (let i = 0, l = keys.length; i < l; ++i) {
|
|
256
|
-
|
|
264
|
+
const key = keys[i];
|
|
265
|
+
|
|
266
|
+
if (isSafeKey(key)) {
|
|
267
|
+
out[key] = values[i];
|
|
268
|
+
}
|
|
257
269
|
}
|
|
258
270
|
|
|
259
271
|
return out;
|
|
@@ -357,6 +369,10 @@ function compareStrict(val1, val2) {
|
|
|
357
369
|
return val1 === val2;
|
|
358
370
|
}
|
|
359
371
|
|
|
372
|
+
function isSafeKey(key) {
|
|
373
|
+
return isNumber(key) || (isString(key) && key !== '__proto__');
|
|
374
|
+
}
|
|
375
|
+
|
|
360
376
|
module.exports = {
|
|
361
377
|
isEmpty,
|
|
362
378
|
isString,
|
package/package.json
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "objection",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc.1",
|
|
4
4
|
"description": "An SQL-friendly ORM for Node.js",
|
|
5
5
|
"main": "lib/objection.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "npm run eslint && mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --exclude \"tests/unit/relations/files/**\"",
|
|
9
|
-
"test-travis": "nyc mocha --slow 100 --timeout 60000 --reporter spec --recursive tests --exclude \"tests/unit/relations/files/**\" && npm run test-typings",
|
|
10
9
|
"test-fast": "mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --bail --exclude \"tests/unit/relations/files/**\"",
|
|
11
|
-
"test-opt": "mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --bail --trace_opt --trace_deopt --exclude \"tests/unit/relations/files/**\"",
|
|
12
|
-
"test-debug": "mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --inspect-brk --exclude \"tests/unit/relations/files/**\"",
|
|
13
|
-
"test-sqlite": "cross-env DATABASES=sqlite3 mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --exclude \"tests/unit/relations/files/**\"",
|
|
14
10
|
"test-typings": "tsc",
|
|
15
|
-
"coveralls": "cat ./testCoverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
|
16
|
-
"perf": "mocha --slow 60000 --timeout 60000 --reporter spec --recursive perf",
|
|
17
|
-
"perf-debug": "mocha --slow 60000 --timeout 60000 --reporter spec --inspect-brk perf",
|
|
18
|
-
"perf-opt": "mocha --slow 60000 --timeout 60000 --reporter spec --recursive perf --trace_opt --trace_deopt",
|
|
19
11
|
"prettier": "prettier --write \"{examples,lib,tests,typings,doc}/**/*.{js,ts}\"",
|
|
20
12
|
"eslint": "eslint --format codeframe \"examples/**/*.js\" \"lib/**/*.js\" \"tests/**/*.js\"",
|
|
21
13
|
"docs:dev": "vuepress dev doc",
|
|
@@ -68,38 +60,20 @@
|
|
|
68
60
|
"knex": ">=0.95.0"
|
|
69
61
|
},
|
|
70
62
|
"devDependencies": {
|
|
71
|
-
"@types/node": "^16.
|
|
63
|
+
"@types/node": "^16.11.6",
|
|
72
64
|
"chai": "^4.3.4",
|
|
73
65
|
"chai-subset": "^1.6.0",
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"eslint": "^
|
|
77
|
-
"eslint-plugin-prettier": "^3.4.0",
|
|
66
|
+
"eslint": "^8.1.0",
|
|
67
|
+
"eslint-formatter-codeframe": "^7.32.1",
|
|
68
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
78
69
|
"expect.js": "^0.3.1",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"knex": "0.95.7",
|
|
82
|
-
"mocha": "^9.0.2",
|
|
70
|
+
"knex": "0.95.13",
|
|
71
|
+
"mocha": "^9.1.3",
|
|
83
72
|
"mysql": "^2.18.1",
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"prettier": "2.3.2",
|
|
73
|
+
"pg": "^8.7.1",
|
|
74
|
+
"prettier": "2.4.1",
|
|
87
75
|
"sqlite3": "^5.0.2",
|
|
88
|
-
"typescript": "^4.
|
|
76
|
+
"typescript": "^4.4.4",
|
|
89
77
|
"vuepress": "1.8.2"
|
|
90
|
-
},
|
|
91
|
-
"nyc": {
|
|
92
|
-
"description": "test coverage",
|
|
93
|
-
"exclude": [
|
|
94
|
-
"lib/queryBuilder/parsers/jsonFieldExpressionParser.js",
|
|
95
|
-
"lib/queryBuilder/parsers/relationExpressionParser.js",
|
|
96
|
-
"testUtils/*",
|
|
97
|
-
"lib/utils/clone.js"
|
|
98
|
-
],
|
|
99
|
-
"reporter": [
|
|
100
|
-
"lcov",
|
|
101
|
-
"text"
|
|
102
|
-
],
|
|
103
|
-
"report-dir": "./testCoverage"
|
|
104
78
|
}
|
|
105
79
|
}
|
|
@@ -21,8 +21,6 @@ export = Objection;
|
|
|
21
21
|
|
|
22
22
|
declare namespace Objection {
|
|
23
23
|
const raw: RawFunction;
|
|
24
|
-
// Deprecated
|
|
25
|
-
const lit: ValueFunction;
|
|
26
24
|
const val: ValueFunction;
|
|
27
25
|
const ref: ReferenceFunction;
|
|
28
26
|
const fn: FunctionFunction;
|
|
@@ -138,7 +136,7 @@ declare namespace Objection {
|
|
|
138
136
|
|
|
139
137
|
type Expression<T> = T | Raw | ReferenceBuilder | ValueBuilder | AnyQueryBuilder;
|
|
140
138
|
|
|
141
|
-
type Id = string | number;
|
|
139
|
+
type Id = string | number | BigInt;
|
|
142
140
|
type CompositeId = Id[];
|
|
143
141
|
type MaybeCompositeId = Id | CompositeId;
|
|
144
142
|
|
|
@@ -306,6 +304,11 @@ declare namespace Objection {
|
|
|
306
304
|
*/
|
|
307
305
|
type SingleQueryBuilder<T extends { SingleQueryBuilderType: any }> = T['SingleQueryBuilderType'];
|
|
308
306
|
|
|
307
|
+
/**
|
|
308
|
+
* Gets the single or undefined item query builder type for a query builder.
|
|
309
|
+
*/
|
|
310
|
+
type MaybeSingleQueryBuilder<QB extends AnyQueryBuilder> = QB['MaybeSingleQueryBuilderType'];
|
|
311
|
+
|
|
309
312
|
/**
|
|
310
313
|
* Gets the multi-item query builder type for a query builder.
|
|
311
314
|
*/
|
|
@@ -566,17 +569,12 @@ declare namespace Objection {
|
|
|
566
569
|
|
|
567
570
|
interface FirstMethod {
|
|
568
571
|
<QB extends AnyQueryBuilder>(this: QB): QB extends ArrayQueryBuilder<QB>
|
|
569
|
-
?
|
|
572
|
+
? MaybeSingleQueryBuilder<QB>
|
|
570
573
|
: QB;
|
|
571
574
|
}
|
|
572
575
|
|
|
573
576
|
type ForIdValue = MaybeCompositeId | AnyQueryBuilder;
|
|
574
577
|
|
|
575
|
-
// Deprecated
|
|
576
|
-
interface EagerMethod<QB extends AnyQueryBuilder> {
|
|
577
|
-
(expr: RelationExpression<ModelType<QB>>, modifiers?: Modifiers): QB;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
578
|
interface AllowGraphMethod<QB extends AnyQueryBuilder> {
|
|
581
579
|
(expr: RelationExpression<ModelType<QB>>): QB;
|
|
582
580
|
}
|
|
@@ -589,10 +587,6 @@ declare namespace Objection {
|
|
|
589
587
|
(arg: T): QB;
|
|
590
588
|
}
|
|
591
589
|
|
|
592
|
-
interface OptionalOneArgMethod<T, QB extends AnyQueryBuilder> {
|
|
593
|
-
(arg?: T): QB;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
590
|
interface StringReturningMethod {
|
|
597
591
|
(): string;
|
|
598
592
|
}
|
|
@@ -735,22 +729,6 @@ declare namespace Objection {
|
|
|
735
729
|
(): any;
|
|
736
730
|
}
|
|
737
731
|
|
|
738
|
-
// Deprecated
|
|
739
|
-
export interface EagerAlgorithm {}
|
|
740
|
-
|
|
741
|
-
// Deprecated
|
|
742
|
-
interface EagerAlgorithmMethod<QB extends AnyQueryBuilder> {
|
|
743
|
-
(algorithm: EagerAlgorithm): QB;
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
// Deprecated
|
|
747
|
-
export interface EagerOptions {
|
|
748
|
-
minimize?: boolean;
|
|
749
|
-
separator?: string;
|
|
750
|
-
aliases?: string[];
|
|
751
|
-
joinOperation: string;
|
|
752
|
-
}
|
|
753
|
-
|
|
754
732
|
export interface GraphOptions {
|
|
755
733
|
minimize?: boolean;
|
|
756
734
|
separator?: string;
|
|
@@ -759,11 +737,6 @@ declare namespace Objection {
|
|
|
759
737
|
maxBatchSize?: number;
|
|
760
738
|
}
|
|
761
739
|
|
|
762
|
-
// Deprecated
|
|
763
|
-
interface EagerOptionsMethod<QB extends AnyQueryBuilder> {
|
|
764
|
-
(options: EagerOptions): QB;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
740
|
interface ModifyGraphMethod<QB extends AnyQueryBuilder> {
|
|
768
741
|
<M extends Model>(
|
|
769
742
|
expr: RelationExpression<ModelType<QB>>,
|
|
@@ -789,11 +762,6 @@ declare namespace Objection {
|
|
|
789
762
|
(): QB;
|
|
790
763
|
}
|
|
791
764
|
|
|
792
|
-
// Deprecated
|
|
793
|
-
interface ApplyFilterMethod<QB extends AnyQueryBuilder> {
|
|
794
|
-
(...filters: string[]): QB;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
765
|
export interface Pojo {
|
|
798
766
|
[key: string]: any;
|
|
799
767
|
}
|
|
@@ -920,23 +888,6 @@ declare namespace Objection {
|
|
|
920
888
|
withRecursive: WithMethod<this>;
|
|
921
889
|
withWrapped: WithMethod<this>;
|
|
922
890
|
|
|
923
|
-
// Deprecated
|
|
924
|
-
joinRelation: JoinRelatedMethod<this>;
|
|
925
|
-
// Deprecated
|
|
926
|
-
innerJoinRelation: JoinRelatedMethod<this>;
|
|
927
|
-
// Deprecated
|
|
928
|
-
outerJoinRelation: JoinRelatedMethod<this>;
|
|
929
|
-
// Deprecated
|
|
930
|
-
leftJoinRelation: JoinRelatedMethod<this>;
|
|
931
|
-
// Deprecated
|
|
932
|
-
leftOuterJoinRelation: JoinRelatedMethod<this>;
|
|
933
|
-
// Deprecated
|
|
934
|
-
rightJoinRelation: JoinRelatedMethod<this>;
|
|
935
|
-
// Deprecated
|
|
936
|
-
rightOuterJoinRelation: JoinRelatedMethod<this>;
|
|
937
|
-
// Deprecated
|
|
938
|
-
fullOuterJoinRelation: JoinRelatedMethod<this>;
|
|
939
|
-
|
|
940
891
|
joinRelated: JoinRelatedMethod<this>;
|
|
941
892
|
innerJoinRelated: JoinRelatedMethod<this>;
|
|
942
893
|
outerJoinRelated: JoinRelatedMethod<this>;
|
|
@@ -975,9 +926,9 @@ declare namespace Objection {
|
|
|
975
926
|
groupBy: GroupByMethod<this>;
|
|
976
927
|
groupByRaw: RawInterface<this>;
|
|
977
928
|
|
|
978
|
-
findById(id: MaybeCompositeId):
|
|
929
|
+
findById(id: MaybeCompositeId): MaybeSingleQueryBuilder<this>;
|
|
979
930
|
findByIds(ids: MaybeCompositeId[]): this;
|
|
980
|
-
findOne: WhereMethod<
|
|
931
|
+
findOne: WhereMethod<MaybeSingleQueryBuilder<this>>;
|
|
981
932
|
|
|
982
933
|
execute(): Promise<R>;
|
|
983
934
|
castTo<MC extends Model>(modelClass: ModelConstructor<MC>): QueryBuilderType<MC>;
|
|
@@ -1026,34 +977,12 @@ declare namespace Objection {
|
|
|
1026
977
|
withGraphJoined(expr: RelationExpression<M>, options?: GraphOptions): this;
|
|
1027
978
|
|
|
1028
979
|
truncate(): Promise<void>;
|
|
1029
|
-
|
|
1030
|
-
// Deprecated
|
|
1031
|
-
eager: EagerMethod<this>;
|
|
1032
|
-
// Deprecated
|
|
1033
|
-
mergeEager: EagerMethod<this>;
|
|
1034
|
-
|
|
1035
|
-
// Deprecated
|
|
1036
|
-
joinEager: EagerMethod<this>;
|
|
1037
|
-
// Deprecated
|
|
1038
|
-
mergeJoinEager: EagerMethod<this>;
|
|
1039
|
-
|
|
1040
|
-
// Deprecated
|
|
1041
|
-
naiveEager: EagerMethod<this>;
|
|
1042
|
-
// Deprecated
|
|
1043
|
-
mergeNaiveEager: EagerMethod<this>;
|
|
1044
|
-
|
|
1045
|
-
// Deprecated
|
|
1046
|
-
allowEager: AllowGraphMethod<this>;
|
|
1047
|
-
// Deprecated
|
|
1048
|
-
mergeAllowEager: AllowGraphMethod<this>;
|
|
1049
|
-
|
|
1050
980
|
allowGraph: AllowGraphMethod<this>;
|
|
1051
|
-
// Deprecated
|
|
1052
|
-
allowInsert: AllowGraphMethod<this>;
|
|
1053
|
-
// Deprecated
|
|
1054
|
-
allowUpsert: AllowGraphMethod<this>;
|
|
1055
981
|
|
|
1056
|
-
throwIfNotFound:
|
|
982
|
+
throwIfNotFound: (
|
|
983
|
+
arg?: any
|
|
984
|
+
) => R extends Model | undefined ? SingleQueryBuilder<QueryBuilder<M, M>> : this;
|
|
985
|
+
|
|
1057
986
|
returning: ReturningMethod;
|
|
1058
987
|
forUpdate: IdentityMethod<this>;
|
|
1059
988
|
forShare: IdentityMethod<this>;
|
|
@@ -1077,17 +1006,6 @@ declare namespace Objection {
|
|
|
1077
1006
|
toKnexQuery<T = ModelObject<M>>(): Knex.QueryBuilder<T, T[]>;
|
|
1078
1007
|
clone(): this;
|
|
1079
1008
|
|
|
1080
|
-
// Deprecated
|
|
1081
|
-
pluck(property: string): this;
|
|
1082
|
-
// Deprecated
|
|
1083
|
-
pick(modelClass: typeof Model, properties: string[]): this;
|
|
1084
|
-
// Deprecated
|
|
1085
|
-
pick(properties: string[]): this;
|
|
1086
|
-
// Deprecated
|
|
1087
|
-
omit(modelClass: typeof Model, properties: string[]): this;
|
|
1088
|
-
// Deprecated
|
|
1089
|
-
omit(properties: string[]): this;
|
|
1090
|
-
|
|
1091
1009
|
page(page: number, pageSize: number): PageQueryBuilder<this>;
|
|
1092
1010
|
range(): PageQueryBuilder<this>;
|
|
1093
1011
|
range(start: number, end: number): PageQueryBuilder<this>;
|
|
@@ -1104,33 +1022,19 @@ declare namespace Objection {
|
|
|
1104
1022
|
|
|
1105
1023
|
insertGraph: InsertGraphMethod<M>;
|
|
1106
1024
|
insertGraphAndFetch: InsertGraphMethod<M>;
|
|
1107
|
-
insertWithRelated: InsertGraphMethod<M>;
|
|
1108
|
-
insertWithRelatedAndFetch: InsertGraphMethod<M>;
|
|
1109
1025
|
|
|
1110
1026
|
upsertGraph: UpsertGraphMethod<M>;
|
|
1111
1027
|
upsertGraphAndFetch: UpsertGraphMethod<M>;
|
|
1112
1028
|
|
|
1113
1029
|
graphExpressionObject: GraphExpressionObjectMethod<this>;
|
|
1114
1030
|
|
|
1115
|
-
// Deprecated
|
|
1116
|
-
eagerAlgorithm: EagerAlgorithmMethod<this>;
|
|
1117
|
-
// Deprecated
|
|
1118
|
-
eagerOptions: EagerOptionsMethod<this>;
|
|
1119
|
-
// Deprecated
|
|
1120
|
-
modifyEager: ModifyGraphMethod<this>;
|
|
1121
|
-
// Deprecated
|
|
1122
|
-
filterEager: ModifyGraphMethod<this>;
|
|
1123
1031
|
modifyGraph: ModifyGraphMethod<this>;
|
|
1124
1032
|
|
|
1125
1033
|
context: ContextMethod<this>;
|
|
1126
1034
|
clearContext: ClearContextMethod<this>;
|
|
1127
|
-
// Deprecated
|
|
1128
|
-
mergeContext: ContextMethod<this>;
|
|
1129
1035
|
|
|
1130
1036
|
modify: ModifyMethod<this>;
|
|
1131
1037
|
modifiers: ModifiersMethod<this>;
|
|
1132
|
-
// Deprecated
|
|
1133
|
-
applyFilter: ApplyFilterMethod<this>;
|
|
1134
1038
|
|
|
1135
1039
|
isFind: BooleanReturningMethod;
|
|
1136
1040
|
isExecutable: BooleanReturningMethod;
|
|
@@ -1142,8 +1046,6 @@ declare namespace Objection {
|
|
|
1142
1046
|
isInternal: BooleanReturningMethod;
|
|
1143
1047
|
hasWheres: BooleanReturningMethod;
|
|
1144
1048
|
hasSelects: BooleanReturningMethod;
|
|
1145
|
-
// Deprecated
|
|
1146
|
-
hasEager: BooleanReturningMethod;
|
|
1147
1049
|
hasWithGraph: BooleanReturningMethod;
|
|
1148
1050
|
|
|
1149
1051
|
has: HasMethod;
|
|
@@ -1154,14 +1056,13 @@ declare namespace Objection {
|
|
|
1154
1056
|
clearWhere: IdentityMethod<this>;
|
|
1155
1057
|
clearWithGraph: IdentityMethod<this>;
|
|
1156
1058
|
clearAllowGraph: IdentityMethod<this>;
|
|
1157
|
-
// Deprecated
|
|
1158
|
-
clearEager: IdentityMethod<this>;
|
|
1159
1059
|
|
|
1160
1060
|
ModelType: M;
|
|
1161
1061
|
ResultType: R;
|
|
1162
1062
|
|
|
1163
1063
|
ArrayQueryBuilderType: QueryBuilder<M, M[]>;
|
|
1164
1064
|
SingleQueryBuilderType: QueryBuilder<M, M>;
|
|
1065
|
+
MaybeSingleQueryBuilderType: QueryBuilder<M, M | undefined>;
|
|
1165
1066
|
NumberQueryBuilderType: QueryBuilder<M, number>;
|
|
1166
1067
|
PageQueryBuilderType: QueryBuilder<M, Page<M>>;
|
|
1167
1068
|
|
|
@@ -1439,17 +1340,6 @@ declare namespace Objection {
|
|
|
1439
1340
|
HasOneThroughRelation: RelationType;
|
|
1440
1341
|
|
|
1441
1342
|
defaultGraphOptions?: GraphOptions;
|
|
1442
|
-
// Deprecated
|
|
1443
|
-
defaultEagerAlgorithm?: EagerAlgorithm;
|
|
1444
|
-
// Deprecated
|
|
1445
|
-
defaultEagerOptions?: EagerOptions;
|
|
1446
|
-
|
|
1447
|
-
// Deprecated
|
|
1448
|
-
WhereInEagerAlgorithm: EagerAlgorithm;
|
|
1449
|
-
// Deprecated
|
|
1450
|
-
NaiveEagerAlgorithm: EagerAlgorithm;
|
|
1451
|
-
// Deprecated
|
|
1452
|
-
JoinEagerAlgorithm: EagerAlgorithm;
|
|
1453
1343
|
|
|
1454
1344
|
query(this: Constructor<M>, trxOrKnex?: TransactionOrKnex): QueryBuilderType<M>;
|
|
1455
1345
|
|
|
@@ -1486,22 +1376,6 @@ declare namespace Objection {
|
|
|
1486
1376
|
bindKnex(trxOrKnex: TransactionOrKnex): this;
|
|
1487
1377
|
bindTransaction(trxOrKnex: TransactionOrKnex): this;
|
|
1488
1378
|
|
|
1489
|
-
// Deprecated
|
|
1490
|
-
loadRelated(
|
|
1491
|
-
modelOrObject: PartialModelObject<M>,
|
|
1492
|
-
expression: RelationExpression<M>,
|
|
1493
|
-
modifiers?: Modifiers<QueryBuilderType<M>>,
|
|
1494
|
-
trxOrKnex?: TransactionOrKnex
|
|
1495
|
-
): SingleQueryBuilder<QueryBuilderType<M>>;
|
|
1496
|
-
|
|
1497
|
-
// Deprecated
|
|
1498
|
-
loadRelated(
|
|
1499
|
-
modelOrObject: PartialModelObject<M>[],
|
|
1500
|
-
expression: RelationExpression<M>,
|
|
1501
|
-
modifiers?: Modifiers<QueryBuilderType<M>>,
|
|
1502
|
-
trxOrKnex?: TransactionOrKnex
|
|
1503
|
-
): QueryBuilderType<M>;
|
|
1504
|
-
|
|
1505
1379
|
fetchGraph(
|
|
1506
1380
|
modelOrObject: PartialModelObject<M>,
|
|
1507
1381
|
expression: RelationExpression<M>,
|
|
@@ -1572,17 +1446,6 @@ declare namespace Objection {
|
|
|
1572
1446
|
static HasOneThroughRelation: RelationType;
|
|
1573
1447
|
|
|
1574
1448
|
static defaultGraphOptions?: GraphOptions;
|
|
1575
|
-
// Deprecated
|
|
1576
|
-
static defaultEagerAlgorithm?: EagerAlgorithm;
|
|
1577
|
-
// Deprecated
|
|
1578
|
-
static defaultEagerOptions?: EagerOptions;
|
|
1579
|
-
|
|
1580
|
-
// Deprecated
|
|
1581
|
-
static WhereInEagerAlgorithm: EagerAlgorithm;
|
|
1582
|
-
// Deprecated
|
|
1583
|
-
static NaiveEagerAlgorithm: EagerAlgorithm;
|
|
1584
|
-
// Deprecated
|
|
1585
|
-
static JoinEagerAlgorithm: EagerAlgorithm;
|
|
1586
1449
|
|
|
1587
1450
|
static query<M extends Model>(
|
|
1588
1451
|
this: Constructor<M>,
|
|
@@ -1623,24 +1486,6 @@ declare namespace Objection {
|
|
|
1623
1486
|
static bindKnex<M>(this: M, trxOrKnex: TransactionOrKnex): M;
|
|
1624
1487
|
static bindTransaction<M>(this: M, trxOrKnex: TransactionOrKnex): M;
|
|
1625
1488
|
|
|
1626
|
-
// Deprecated
|
|
1627
|
-
static loadRelated<M extends Model>(
|
|
1628
|
-
this: Constructor<M>,
|
|
1629
|
-
modelOrObject: PartialModelObject<M>,
|
|
1630
|
-
expression: RelationExpression<M>,
|
|
1631
|
-
modifiers?: Modifiers<QueryBuilderType<M>>,
|
|
1632
|
-
trxOrKnex?: TransactionOrKnex
|
|
1633
|
-
): SingleQueryBuilder<QueryBuilderType<M>>;
|
|
1634
|
-
|
|
1635
|
-
// Deprecated
|
|
1636
|
-
static loadRelated<M extends Model>(
|
|
1637
|
-
this: Constructor<M>,
|
|
1638
|
-
modelOrObject: PartialModelObject<M>[],
|
|
1639
|
-
expression: RelationExpression<M>,
|
|
1640
|
-
modifiers?: Modifiers<QueryBuilderType<M>>,
|
|
1641
|
-
trxOrKnex?: TransactionOrKnex
|
|
1642
|
-
): QueryBuilderType<M>;
|
|
1643
|
-
|
|
1644
1489
|
static fetchGraph<M extends Model>(
|
|
1645
1490
|
this: Constructor<M>,
|
|
1646
1491
|
modelOrObject: PartialModelObject<M>,
|
|
@@ -1697,13 +1542,6 @@ declare namespace Objection {
|
|
|
1697
1542
|
$id(id: any): void;
|
|
1698
1543
|
$id(): any;
|
|
1699
1544
|
|
|
1700
|
-
// Deprecated
|
|
1701
|
-
$loadRelated(
|
|
1702
|
-
expression: RelationExpression<this>,
|
|
1703
|
-
modifiers?: Modifiers<QueryBuilderType<this>>,
|
|
1704
|
-
trxOrKnex?: TransactionOrKnex
|
|
1705
|
-
): SingleQueryBuilder<QueryBuilderType<this>>;
|
|
1706
|
-
|
|
1707
1545
|
$fetchGraph(
|
|
1708
1546
|
expression: RelationExpression<this>,
|
|
1709
1547
|
options?: FetchGraphOptions
|