objection 3.9.1 → 4.0.0-rc.2
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/lib/dbErrors/LICENSE +21 -0
- package/lib/dbErrors/errorCodes/mssql.js +19 -0
- package/lib/dbErrors/errorCodes/mysql.js +805 -0
- package/lib/dbErrors/errorCodes/postgres.js +241 -0
- package/lib/dbErrors/errors/CheckViolationError.js +10 -0
- package/lib/dbErrors/errors/ConstraintViolationError.js +3 -0
- package/lib/dbErrors/errors/DBError.js +9 -0
- package/lib/dbErrors/errors/DataError.js +3 -0
- package/lib/dbErrors/errors/ForeignKeyViolationError.js +11 -0
- package/lib/dbErrors/errors/NotNullViolationError.js +12 -0
- package/lib/dbErrors/errors/UniqueViolationError.js +12 -0
- package/lib/dbErrors/index.js +59 -0
- package/lib/dbErrors/parsers/mssql/DBError/CheckViolationError/parser.js +28 -0
- package/lib/dbErrors/parsers/mssql/DBError/DataError/parser.js +25 -0
- package/lib/dbErrors/parsers/mssql/DBError/ForeignKeyViolationError/parser.js +39 -0
- package/lib/dbErrors/parsers/mssql/DBError/NotNullViolationError/parser.js +30 -0
- package/lib/dbErrors/parsers/mssql/DBError/UniqueViolationError/parser.js +53 -0
- package/lib/dbErrors/parsers/mssql/DBError/parser.js +51 -0
- package/lib/dbErrors/parsers/mssql/DBError/util.js +16 -0
- package/lib/dbErrors/parsers/mysql/DBError/ConstraintViolationError/ForeignKeyViolationError/parser.js +43 -0
- package/lib/dbErrors/parsers/mysql/DBError/ConstraintViolationError/NotNullViolationError/parser.js +29 -0
- package/lib/dbErrors/parsers/mysql/DBError/ConstraintViolationError/UniqueViolationError/parser.js +27 -0
- package/lib/dbErrors/parsers/mysql/DBError/ConstraintViolationError/parser.js +23 -0
- package/lib/dbErrors/parsers/mysql/DBError/DataError/parser.js +24 -0
- package/lib/dbErrors/parsers/mysql/DBError/parser.js +28 -0
- package/lib/dbErrors/parsers/postgres/DBError/ConstraintViolationError/CheckViolationError/parser.js +18 -0
- package/lib/dbErrors/parsers/postgres/DBError/ConstraintViolationError/ForeignKeyViolationError/parser.js +18 -0
- package/lib/dbErrors/parsers/postgres/DBError/ConstraintViolationError/NotNullViolationError/parser.js +18 -0
- package/lib/dbErrors/parsers/postgres/DBError/ConstraintViolationError/UniqueViolationError/parser.js +40 -0
- package/lib/dbErrors/parsers/postgres/DBError/ConstraintViolationError/parser.js +25 -0
- package/lib/dbErrors/parsers/postgres/DBError/DataError/parser.js +16 -0
- package/lib/dbErrors/parsers/postgres/DBError/parser.js +27 -0
- package/lib/dbErrors/parsers/sqlite/DBError/ConstraintViolationError/CheckViolationError/parser.js +20 -0
- package/lib/dbErrors/parsers/sqlite/DBError/ConstraintViolationError/ForeignKeyViolationError/parser.js +20 -0
- package/lib/dbErrors/parsers/sqlite/DBError/ConstraintViolationError/NotNullViolationError/parser.js +27 -0
- package/lib/dbErrors/parsers/sqlite/DBError/ConstraintViolationError/UniqueViolationError/parser.js +28 -0
- package/lib/dbErrors/parsers/sqlite/DBError/ConstraintViolationError/parser.js +24 -0
- package/lib/dbErrors/parsers/sqlite/DBError/parser.js +23 -0
- package/lib/dbErrors/utils/sqlState.js +3 -0
- package/lib/initialize.js +1 -7
- package/lib/model/AjvValidator.js +51 -117
- package/lib/model/Model.js +84 -59
- package/lib/model/ModifierNotFoundError.js +1 -7
- package/lib/model/NotFoundError.js +1 -7
- package/lib/model/RelationDoesNotExistError.js +1 -7
- package/lib/model/ValidationError.js +3 -10
- package/lib/model/Validator.js +1 -7
- package/lib/model/getModel.js +7 -6
- package/lib/model/inheritModel.js +1 -7
- package/lib/model/modelBindKnex.js +4 -10
- package/lib/model/modelClone.js +5 -11
- package/lib/model/modelColPropMap.js +3 -10
- package/lib/model/modelId.js +3 -10
- package/lib/model/modelJsonAttributes.js +35 -16
- package/lib/model/modelParseRelations.js +2 -8
- package/lib/model/modelQueryProps.js +11 -23
- package/lib/model/modelSet.js +89 -41
- package/lib/model/modelTableMetadata.js +4 -11
- package/lib/model/modelToJson.js +6 -13
- package/lib/model/modelUtils.js +14 -13
- package/lib/model/modelValidate.js +3 -9
- package/lib/model/modelValues.js +5 -14
- package/lib/model/modelVisitor.js +1 -7
- package/lib/objection.js +33 -71
- package/lib/queryBuilder/FunctionBuilder.js +4 -11
- package/lib/queryBuilder/InternalOptions.js +4 -9
- package/lib/queryBuilder/JoinBuilder.js +5 -8
- package/lib/queryBuilder/QueryBuilder.js +126 -95
- package/lib/queryBuilder/QueryBuilderBase.js +41 -123
- package/lib/queryBuilder/QueryBuilderContext.js +2 -8
- package/lib/queryBuilder/QueryBuilderContextBase.js +2 -8
- package/lib/queryBuilder/QueryBuilderOperationSupport.js +7 -21
- package/lib/queryBuilder/QueryBuilderUserContext.js +1 -7
- package/lib/queryBuilder/RawBuilder.js +5 -13
- package/lib/queryBuilder/ReferenceBuilder.js +20 -48
- package/lib/queryBuilder/RelationExpression.js +18 -16
- package/lib/queryBuilder/StaticHookArguments.js +74 -16
- package/lib/queryBuilder/ValueBuilder.js +11 -13
- package/lib/queryBuilder/getJoinBuilder.js +10 -0
- package/lib/queryBuilder/graph/GraphLoader.js +314 -0
- package/lib/queryBuilder/graph/GraphNode.js +241 -0
- package/lib/queryBuilder/graph/GraphOptions.js +55 -248
- package/lib/queryBuilder/graph/GraphPlan.js +431 -0
- package/lib/queryBuilder/graph/GraphSchedule.js +513 -0
- package/lib/queryBuilder/graph/GraphUpsert.js +519 -412
- package/lib/queryBuilder/graph/GraphWriter.js +508 -0
- package/lib/queryBuilder/graph/graphKeys.js +929 -0
- package/lib/queryBuilder/join/JoinResultColumn.js +1 -7
- package/lib/queryBuilder/join/JoinResultParser.js +6 -11
- package/lib/queryBuilder/join/RelationJoiner.js +66 -84
- package/lib/queryBuilder/join/TableNode.js +2 -8
- package/lib/queryBuilder/join/TableTree.js +3 -9
- package/lib/queryBuilder/join/utils.js +5 -15
- package/lib/queryBuilder/jsonDialects/JsonDialect.js +51 -0
- package/lib/queryBuilder/jsonDialects/MySqlJsonDialect.js +81 -0
- package/lib/queryBuilder/jsonDialects/PostgresJsonDialect.js +45 -0
- package/lib/queryBuilder/jsonDialects/SqliteJsonDialect.js +67 -0
- package/lib/queryBuilder/jsonDialects/index.js +44 -0
- package/lib/queryBuilder/operations/DelegateOperation.js +2 -8
- package/lib/queryBuilder/operations/DeleteOperation.js +10 -39
- package/lib/queryBuilder/operations/FindByIdOperation.js +7 -12
- package/lib/queryBuilder/operations/FindByIdsOperation.js +4 -8
- package/lib/queryBuilder/operations/FindOperation.js +14 -34
- package/lib/queryBuilder/operations/FirstOperation.js +6 -10
- package/lib/queryBuilder/operations/FromOperation.js +3 -9
- package/lib/queryBuilder/operations/InsertAndFetchOperation.js +13 -12
- package/lib/queryBuilder/operations/InsertGraphAndFetchOperation.js +4 -10
- package/lib/queryBuilder/operations/InsertGraphOperation.js +7 -18
- package/lib/queryBuilder/operations/InsertOperation.js +118 -45
- package/lib/queryBuilder/operations/InstanceDeleteOperation.js +5 -12
- package/lib/queryBuilder/operations/InstanceFindOperation.js +4 -11
- package/lib/queryBuilder/operations/InstanceInsertOperation.js +2 -8
- package/lib/queryBuilder/operations/InstanceUpdateOperation.js +7 -14
- package/lib/queryBuilder/operations/JoinRelatedOperation.js +5 -11
- package/lib/queryBuilder/operations/KnexOperation.js +2 -8
- package/lib/queryBuilder/operations/LimitPerParentOperation.js +7 -69
- package/lib/queryBuilder/operations/MergeOperation.js +5 -11
- package/lib/queryBuilder/operations/NoneOperation.js +2 -8
- package/lib/queryBuilder/operations/ObjectionToKnexConvertingOperation.js +20 -49
- package/lib/queryBuilder/operations/OnBuildKnexOperation.js +2 -8
- package/lib/queryBuilder/operations/OnBuildOperation.js +2 -8
- package/lib/queryBuilder/operations/OnErrorOperation.js +2 -8
- package/lib/queryBuilder/operations/QueryBuilderOperation.js +1 -7
- package/lib/queryBuilder/operations/RangeOperation.js +11 -26
- package/lib/queryBuilder/operations/RelateOperation.js +2 -8
- package/lib/queryBuilder/operations/ReturningOperation.js +3 -9
- package/lib/queryBuilder/operations/RunAfterOperation.js +2 -12
- package/lib/queryBuilder/operations/RunBeforeOperation.js +2 -8
- package/lib/queryBuilder/operations/UnrelateOperation.js +2 -8
- package/lib/queryBuilder/operations/UpdateAndFetchOperation.js +14 -17
- package/lib/queryBuilder/operations/UpdateOperation.js +32 -132
- package/lib/queryBuilder/operations/UpsertGraphAndFetchOperation.js +8 -11
- package/lib/queryBuilder/operations/UpsertGraphOperation.js +6 -12
- package/lib/queryBuilder/operations/WhereCompositeOperation.js +3 -9
- package/lib/queryBuilder/operations/WhereGroupOperation.js +2 -8
- package/lib/queryBuilder/operations/eager/EagerOperation.js +3 -9
- package/lib/queryBuilder/operations/eager/JoinEagerOperation.js +72 -10
- package/lib/queryBuilder/operations/eager/NaiveEagerOperation.js +2 -8
- package/lib/queryBuilder/operations/eager/WhereInEagerOperation.js +23 -44
- package/lib/queryBuilder/operations/fieldExpressions.js +122 -0
- package/lib/queryBuilder/operations/jsonApi/WhereJsonHasOperation.js +20 -0
- package/lib/queryBuilder/operations/jsonApi/WhereJsonOperation.js +44 -0
- package/lib/queryBuilder/operations/jsonApi/WhereJsonTypeOperation.js +14 -0
- package/lib/queryBuilder/operations/select/SelectOperation.js +11 -21
- package/lib/queryBuilder/operations/select/Selection.js +19 -17
- package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeMsSqlOperation.js +4 -10
- package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeOperation.js +4 -10
- package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeSqliteOperation.js +4 -10
- package/lib/queryBuilder/operations/windowOrder.js +56 -0
- package/lib/queryBuilder/parsers/jsonFieldExpressionParser.js +3 -7
- package/lib/queryBuilder/parsers/relationExpressionParser.js +42 -43
- package/lib/queryBuilder/parsers/relationExpressionParser.pegjs +39 -36
- package/lib/queryBuilder/transformations/CompositeQueryTransformation.js +2 -8
- package/lib/queryBuilder/transformations/QueryTransformation.js +1 -7
- package/lib/queryBuilder/transformations/WrapMysqlModifySubqueryTransformation.js +3 -9
- package/lib/queryBuilder/transformations/index.js +3 -11
- package/lib/queryBuilder/whereGroups.js +9 -24
- package/lib/queryBuilder/withoutOrder.js +4 -11
- package/lib/relations/Relation.js +47 -28
- package/lib/relations/RelationDeleteOperation.js +4 -14
- package/lib/relations/RelationFindOperation.js +119 -90
- package/lib/relations/RelationInsertOperation.js +2 -8
- package/lib/relations/RelationOwner.js +5 -11
- package/lib/relations/RelationProperty.js +4 -10
- package/lib/relations/RelationUpdateOperation.js +4 -14
- package/lib/relations/RelationWriteResultOperation.js +15 -0
- package/lib/relations/belongsToMany/BelongsToManyDeleteOperation.js +23 -0
- package/lib/relations/belongsToMany/BelongsToManyFindOperation.js +35 -0
- package/lib/relations/belongsToMany/BelongsToManyInsertOperation.js +28 -0
- package/lib/relations/belongsToMany/BelongsToManyRelateOperation.js +16 -0
- package/lib/relations/belongsToMany/BelongsToManyRelation.js +276 -0
- package/lib/relations/belongsToMany/BelongsToManyUnrelateOperation.js +11 -0
- package/lib/relations/belongsToOne/BelongsToOneDeleteOperation.js +2 -8
- package/lib/relations/belongsToOne/BelongsToOneInsertOperation.js +6 -11
- package/lib/relations/belongsToOne/BelongsToOneRelateOperation.js +3 -9
- package/lib/relations/belongsToOne/BelongsToOneRelation.js +8 -19
- package/lib/relations/belongsToOne/BelongsToOneUnrelateOperation.js +53 -27
- package/lib/relations/hasMany/HasManyInsertOperation.js +5 -10
- package/lib/relations/hasMany/HasManyRelateOperation.js +5 -11
- package/lib/relations/hasMany/HasManyRelation.js +9 -11
- package/lib/relations/hasMany/HasManyUnrelateOperation.js +3 -9
- package/lib/relations/hasOne/HasOneRelation.js +2 -8
- package/lib/relations/hasOneThrough/HasOneThroughRelation.js +2 -8
- package/lib/relations/manyToMany/ManyToManyModifyMixin.js +10 -15
- package/lib/relations/manyToMany/ManyToManyMySqlModifyMixin.js +2 -8
- package/lib/relations/manyToMany/ManyToManyRelation.js +82 -50
- package/lib/relations/manyToMany/ManyToManySqliteModifyMixin.js +2 -8
- package/lib/relations/manyToMany/delete/ManyToManyDeleteOperation.js +5 -9
- package/lib/relations/manyToMany/delete/ManyToManyDeleteOperationBase.js +2 -8
- package/lib/relations/manyToMany/delete/ManyToManyDeleteSqliteOperation.js +3 -9
- package/lib/relations/manyToMany/find/ManyToManyFindOperation.js +20 -59
- package/lib/relations/manyToMany/insert/ManyToManyInsertOperation.js +6 -11
- package/lib/relations/manyToMany/relate/ManyToManyRelateOperation.js +4 -10
- package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateMySqlOperation.js +3 -9
- package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateOperation.js +5 -9
- package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateOperationBase.js +3 -9
- package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateSqliteOperation.js +3 -9
- package/lib/relations/manyToMany/update/ManyToManyUpdateMySqlOperation.js +3 -9
- package/lib/relations/manyToMany/update/ManyToManyUpdateOperation.js +5 -9
- package/lib/relations/manyToMany/update/ManyToManyUpdateOperationBase.js +64 -72
- package/lib/relations/manyToMany/update/ManyToManyUpdateSqliteOperation.js +3 -9
- package/lib/transaction.js +3 -9
- package/lib/utils/assert.js +3 -11
- package/lib/utils/buildUtils.js +2 -8
- package/lib/utils/classUtils.js +1 -7
- package/lib/utils/createModifier.js +2 -8
- package/lib/utils/identifierMapping.js +23 -27
- package/lib/utils/internalPropUtils.js +1 -7
- package/lib/utils/knexUtils.js +84 -40
- package/lib/utils/mixin.js +3 -10
- package/lib/utils/normalizeIds.js +2 -8
- package/lib/utils/objectUtils.js +41 -60
- package/lib/utils/parseFieldExpression.js +16 -16
- package/lib/utils/promiseUtils/after.js +2 -8
- package/lib/utils/promiseUtils/afterReturn.js +2 -8
- package/lib/utils/promiseUtils/index.js +7 -16
- package/lib/utils/promiseUtils/isPromise.js +2 -8
- package/lib/utils/promiseUtils/map.js +2 -8
- package/lib/utils/promiseUtils/mapAfterAllReturn.js +2 -8
- package/lib/utils/promiseUtils/try.js +2 -8
- package/lib/utils/resolveModel.js +10 -17
- package/lib/utils/tmpColumnUtils.js +2 -9
- package/lib/utils/warnings.js +2 -14
- package/package.json +25 -17
- package/typings/objection/index.d.ts +3217 -2179
- package/lib/.eslintrc.json +0 -8
- package/lib/model/graph/ModelGraph.js +0 -80
- package/lib/model/graph/ModelGraphBuilder.js +0 -241
- package/lib/model/graph/ModelGraphEdge.js +0 -52
- package/lib/model/graph/ModelGraphNode.js +0 -238
- package/lib/queryBuilder/graph/GraphAction.js +0 -69
- package/lib/queryBuilder/graph/GraphData.js +0 -53
- package/lib/queryBuilder/graph/GraphFetcher.js +0 -197
- package/lib/queryBuilder/graph/GraphNodeDbExistence.js +0 -184
- package/lib/queryBuilder/graph/GraphOperation.js +0 -27
- package/lib/queryBuilder/graph/delete/GraphDelete.js +0 -73
- package/lib/queryBuilder/graph/delete/GraphDeleteAction.js +0 -88
- package/lib/queryBuilder/graph/insert/DeferredRelationGraphInsertAction.js +0 -58
- package/lib/queryBuilder/graph/insert/GraphInsert.js +0 -296
- package/lib/queryBuilder/graph/insert/GraphInsertAction.js +0 -233
- package/lib/queryBuilder/graph/insert/JoinRowGraphInsertAction.js +0 -92
- package/lib/queryBuilder/graph/patch/GraphPatch.js +0 -20
- package/lib/queryBuilder/graph/patch/GraphPatchAction.js +0 -289
- package/lib/queryBuilder/graph/recursiveUpsert/GraphRecursiveUpsert.js +0 -31
- package/lib/queryBuilder/graph/recursiveUpsert/GraphRecursiveUpsertAction.js +0 -126
- package/lib/queryBuilder/operations/jsonApi/WhereJsonHasPostgresOperation.js +0 -30
- package/lib/queryBuilder/operations/jsonApi/WhereJsonNotObjectPostgresOperation.js +0 -37
- package/lib/queryBuilder/operations/jsonApi/WhereJsonPostgresOperation.js +0 -62
- package/lib/queryBuilder/operations/jsonApi/postgresJsonApi.js +0 -192
- package/lib/utils/wrapDbError.js +0 -64
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { DeleteOperation } from './DeleteOperation.js';
|
|
2
|
+
import { InstanceFindOperation } from './InstanceFindOperation.js';
|
|
3
|
+
import { assertHasId } from '../../utils/assert.js';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
const { InstanceFindOperation } = require('./InstanceFindOperation');
|
|
5
|
-
const { assertHasId } = require('../../utils/assert');
|
|
6
|
-
const { addWhereGroup } = require('../whereGroups');
|
|
7
|
-
|
|
8
|
-
class InstanceDeleteOperation extends DeleteOperation {
|
|
5
|
+
export class InstanceDeleteOperation extends DeleteOperation {
|
|
9
6
|
constructor(name, opt) {
|
|
10
7
|
super(name, opt);
|
|
11
8
|
this.instance = opt.instance;
|
|
@@ -21,7 +18,7 @@ class InstanceDeleteOperation extends DeleteOperation {
|
|
|
21
18
|
super.onBuild(builder);
|
|
22
19
|
|
|
23
20
|
assertHasId(this.instance);
|
|
24
|
-
|
|
21
|
+
builder.findById(this.instance.$id());
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
async onAfter2(builder, result) {
|
|
@@ -40,7 +37,3 @@ class InstanceDeleteOperation extends DeleteOperation {
|
|
|
40
37
|
});
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
|
|
44
|
-
module.exports = {
|
|
45
|
-
InstanceDeleteOperation,
|
|
46
|
-
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { FindOperation } from './FindOperation.js';
|
|
2
|
+
import { assertHasId } from '../../utils/assert.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const { assertHasId } = require('../../utils/assert');
|
|
5
|
-
const { addWhereGroup } = require('../whereGroups');
|
|
6
|
-
|
|
7
|
-
class InstanceFindOperation extends FindOperation {
|
|
4
|
+
export class InstanceFindOperation extends FindOperation {
|
|
8
5
|
constructor(name, opt) {
|
|
9
6
|
super(name, opt);
|
|
10
7
|
this.instance = opt.instance;
|
|
@@ -12,10 +9,6 @@ class InstanceFindOperation extends FindOperation {
|
|
|
12
9
|
|
|
13
10
|
onBuild(builder) {
|
|
14
11
|
assertHasId(this.instance);
|
|
15
|
-
|
|
12
|
+
builder.findById(this.instance.$id());
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
|
-
|
|
19
|
-
module.exports = {
|
|
20
|
-
InstanceFindOperation,
|
|
21
|
-
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { InsertOperation } from './InsertOperation.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class InstanceInsertOperation extends InsertOperation {
|
|
3
|
+
export class InstanceInsertOperation extends InsertOperation {
|
|
6
4
|
constructor(name, opt) {
|
|
7
5
|
super(name, opt);
|
|
8
6
|
this.instance = opt.instance;
|
|
@@ -18,7 +16,3 @@ class InstanceInsertOperation extends InsertOperation {
|
|
|
18
16
|
return super.onAdd(builder, args);
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
|
-
|
|
22
|
-
module.exports = {
|
|
23
|
-
InstanceInsertOperation,
|
|
24
|
-
};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { UpdateOperation } from './UpdateOperation.js';
|
|
2
|
+
import { InstanceFindOperation } from './InstanceFindOperation.js';
|
|
3
|
+
import { assertHasId } from '../../utils/assert.js';
|
|
4
|
+
import { isObject } from '../../utils/objectUtils.js';
|
|
5
|
+
import { removeOverriddenQueryProps } from '../../model/modelQueryProps.js';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
const { InstanceFindOperation } = require('./InstanceFindOperation');
|
|
5
|
-
const { assertHasId } = require('../../utils/assert');
|
|
6
|
-
const { isObject } = require('../../utils/objectUtils');
|
|
7
|
-
const { addWhereGroup } = require('../whereGroups');
|
|
8
|
-
const { removeOverriddenQueryProps } = require('../../model/modelQueryProps');
|
|
9
|
-
|
|
10
|
-
class InstanceUpdateOperation extends UpdateOperation {
|
|
7
|
+
export class InstanceUpdateOperation extends UpdateOperation {
|
|
11
8
|
constructor(name, opt) {
|
|
12
9
|
super(name, opt);
|
|
13
10
|
|
|
@@ -30,7 +27,7 @@ class InstanceUpdateOperation extends UpdateOperation {
|
|
|
30
27
|
super.onBuild(builder);
|
|
31
28
|
|
|
32
29
|
assertHasId(this.instance);
|
|
33
|
-
|
|
30
|
+
builder.findById(this.instance.$id());
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
async onAfter2(builder, result) {
|
|
@@ -60,7 +57,3 @@ class InstanceUpdateOperation extends UpdateOperation {
|
|
|
60
57
|
});
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
|
-
|
|
64
|
-
module.exports = {
|
|
65
|
-
InstanceUpdateOperation,
|
|
66
|
-
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { QueryBuilderOperation } from './QueryBuilderOperation.js';
|
|
2
|
+
import { RelationExpression } from '../RelationExpression.js';
|
|
3
|
+
import { RelationJoiner } from '../join/RelationJoiner.js';
|
|
4
|
+
import { isString } from '../../utils/objectUtils.js';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
const { RelationExpression } = require('../RelationExpression');
|
|
5
|
-
const { RelationJoiner } = require('../join/RelationJoiner');
|
|
6
|
-
const { isString } = require('../../utils/objectUtils');
|
|
7
|
-
|
|
8
|
-
class JoinRelatedOperation extends QueryBuilderOperation {
|
|
6
|
+
export class JoinRelatedOperation extends QueryBuilderOperation {
|
|
9
7
|
constructor(name, opt) {
|
|
10
8
|
super(name, opt);
|
|
11
9
|
this.calls = [];
|
|
@@ -97,7 +95,3 @@ function renameRelationExpressionNode(expr, oldName, newName) {
|
|
|
97
95
|
childExpr.$name = newName;
|
|
98
96
|
expr.$childNames = expr.$childNames.map((it) => (it === oldName ? newName : it));
|
|
99
97
|
}
|
|
100
|
-
|
|
101
|
-
module.exports = {
|
|
102
|
-
JoinRelatedOperation,
|
|
103
|
-
};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { ObjectionToKnexConvertingOperation } = require('./ObjectionToKnexConvertingOperation');
|
|
1
|
+
import { ObjectionToKnexConvertingOperation } from './ObjectionToKnexConvertingOperation.js';
|
|
4
2
|
|
|
5
3
|
// An operation that simply calls the equivalent knex method.
|
|
6
|
-
class KnexOperation extends ObjectionToKnexConvertingOperation {
|
|
4
|
+
export class KnexOperation extends ObjectionToKnexConvertingOperation {
|
|
7
5
|
onBuildKnex(knexBuilder, builder) {
|
|
8
6
|
return knexBuilder[this.name].apply(knexBuilder, this.getKnexArgs(builder));
|
|
9
7
|
}
|
|
10
8
|
}
|
|
11
|
-
|
|
12
|
-
module.exports = {
|
|
13
|
-
KnexOperation,
|
|
14
|
-
};
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { hasWindowFunctions, isKnexRaw } = require('../../utils/knexUtils');
|
|
8
|
-
const { Selection, isSameTable, withoutSchema } = require('./select/Selection');
|
|
9
|
-
|
|
10
|
-
// Without underscores, so that column name mappers don't change it.
|
|
11
|
-
const rowNumberColumn = 'objectiontmprownum';
|
|
1
|
+
import { QueryBuilderOperation } from './QueryBuilderOperation.js';
|
|
2
|
+
import { RangeOperation } from './RangeOperation.js';
|
|
3
|
+
import { FirstOperation } from './FirstOperation.js';
|
|
4
|
+
import { isNumber } from '../../utils/objectUtils.js';
|
|
5
|
+
import { withoutSchema } from './select/Selection.js';
|
|
6
|
+
import { getWindowOrder, rowNumberColumn } from './windowOrder.js';
|
|
12
7
|
|
|
13
8
|
// Applies the `limit()`, `offset()` and `first()` of a relation query that
|
|
14
9
|
// fetches the related models of many parents to each parent separately.
|
|
15
|
-
class LimitPerParentOperation extends QueryBuilderOperation {
|
|
10
|
+
export class LimitPerParentOperation extends QueryBuilderOperation {
|
|
16
11
|
constructor(name, opt) {
|
|
17
12
|
super(name, opt);
|
|
18
13
|
this.findOperation = opt.findOperation;
|
|
@@ -46,10 +41,6 @@ class LimitPerParentOperation extends QueryBuilderOperation {
|
|
|
46
41
|
|
|
47
42
|
if (!range) {
|
|
48
43
|
return knexBuilder;
|
|
49
|
-
} else if (!hasWindowFunctions(knex)) {
|
|
50
|
-
// `WhereInEagerOperation` fetches the related models of each parent with
|
|
51
|
-
// a separate query then, so only `first()` still needs to be applied:
|
|
52
|
-
return range.limit === null ? knexBuilder : knexBuilder.limit(range.limit);
|
|
53
44
|
} else {
|
|
54
45
|
const { limit, offset } = range;
|
|
55
46
|
// Number the rows of each parent one level up, aliased as the related
|
|
@@ -97,56 +88,3 @@ class LimitPerParentOperation extends QueryBuilderOperation {
|
|
|
97
88
|
}
|
|
98
89
|
}
|
|
99
90
|
}
|
|
100
|
-
|
|
101
|
-
// Convert the `orderBy()` and `orderByRaw()` calls of the query to the order
|
|
102
|
-
// of knex's window functions, which can only refer to the related table by its
|
|
103
|
-
// alias `table`.
|
|
104
|
-
function getWindowOrder(builder, knex, table) {
|
|
105
|
-
const order = [];
|
|
106
|
-
const tableRef = builder.tableRef();
|
|
107
|
-
|
|
108
|
-
const getAliasedColumn = (column) => {
|
|
109
|
-
const selection = isString(column) && Selection.create(column);
|
|
110
|
-
return selection?.table && isSameTable(builder, selection.table, tableRef)
|
|
111
|
-
? `${table}.${selection.column}`
|
|
112
|
-
: column;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
builder.forEachOperation(builder.constructor.OrderBySelector, (op) => {
|
|
116
|
-
const args = op.getKnexArgs(builder);
|
|
117
|
-
|
|
118
|
-
if (op.name === 'orderByRaw') {
|
|
119
|
-
const [sql, bindings] = args;
|
|
120
|
-
order.push({ column: isKnexRaw(sql) ? sql : knex.raw(sql, bindings) });
|
|
121
|
-
} else {
|
|
122
|
-
const [column, direction, nulls] = args;
|
|
123
|
-
const items = Array.isArray(column)
|
|
124
|
-
? column.map((item) => (isString(item) ? { column: item } : item))
|
|
125
|
-
: [{ column, order: direction, nulls }];
|
|
126
|
-
|
|
127
|
-
for (const item of items) {
|
|
128
|
-
const aliasedColumn = getAliasedColumn(item.column);
|
|
129
|
-
|
|
130
|
-
if (item.nulls) {
|
|
131
|
-
// Not all databases support `nulls first` and `nulls last`:
|
|
132
|
-
order.push({
|
|
133
|
-
column: knex.raw('(case when ? is null then 0 else 1 end)', [
|
|
134
|
-
isString(aliasedColumn) ? knex.ref(aliasedColumn) : aliasedColumn,
|
|
135
|
-
]),
|
|
136
|
-
order: item.nulls === 'first' ? 'asc' : 'desc',
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Unlike in `orderBy()`, knex adds the direction to the window as it is:
|
|
141
|
-
order.push({ column: aliasedColumn, order: /^desc$/i.test(item.order) ? 'desc' : 'asc' });
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
// SQL Server requires an order in the window function:
|
|
147
|
-
return order.length ? order : [{ column: knex.raw('(select null)') }];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
module.exports = {
|
|
151
|
-
LimitPerParentOperation,
|
|
152
|
-
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { isFunction, isEmpty, isObject } from '../../utils/objectUtils.js';
|
|
2
|
+
import { QueryBuilderOperation } from './QueryBuilderOperation.js';
|
|
3
|
+
import { convertFieldExpressionsToRaw } from './fieldExpressions.js';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
const { QueryBuilderOperation } = require('./QueryBuilderOperation');
|
|
5
|
-
const { convertFieldExpressionsToRaw } = require('./UpdateOperation');
|
|
6
|
-
|
|
7
|
-
class MergeOperation extends QueryBuilderOperation {
|
|
5
|
+
export class MergeOperation extends QueryBuilderOperation {
|
|
8
6
|
constructor(name, opt) {
|
|
9
7
|
super(name, opt);
|
|
10
8
|
this.model = null;
|
|
@@ -31,7 +29,7 @@ class MergeOperation extends QueryBuilderOperation {
|
|
|
31
29
|
|
|
32
30
|
if (this.model) {
|
|
33
31
|
const json = this.model.$toDatabaseJson(builder);
|
|
34
|
-
const convertedJson = convertFieldExpressionsToRaw(builder,
|
|
32
|
+
const convertedJson = convertFieldExpressionsToRaw(builder, json);
|
|
35
33
|
|
|
36
34
|
return knexBuilder.merge(convertedJson);
|
|
37
35
|
}
|
|
@@ -50,7 +48,3 @@ class MergeOperation extends QueryBuilderOperation {
|
|
|
50
48
|
return clone;
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
|
-
|
|
54
|
-
module.exports = {
|
|
55
|
-
MergeOperation,
|
|
56
|
-
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { QueryBuilderOperation } = require('./QueryBuilderOperation');
|
|
1
|
+
import { QueryBuilderOperation } from './QueryBuilderOperation.js';
|
|
4
2
|
|
|
5
3
|
const AggregateSelector =
|
|
6
4
|
/^(count|countDistinct|min|max|sum|sumDistinct|avg|avgDistinct|groupBy\w*)$/;
|
|
7
5
|
|
|
8
|
-
class NoneOperation extends QueryBuilderOperation {
|
|
6
|
+
export class NoneOperation extends QueryBuilderOperation {
|
|
9
7
|
onBefore1(builder, result) {
|
|
10
8
|
// Resolve the query without executing it, like `cancelQuery()` does.
|
|
11
9
|
if (builder.isFind()) {
|
|
@@ -31,7 +29,3 @@ class NoneOperation extends QueryBuilderOperation {
|
|
|
31
29
|
return knexBuilder.clearWhere().where(false);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
module.exports = {
|
|
36
|
-
NoneOperation,
|
|
37
|
-
};
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { transformation } = require('../transformations');
|
|
7
|
-
const getJoinBuilder = once(() => require('../JoinBuilder').JoinBuilder);
|
|
1
|
+
import { QueryBuilderOperation } from './QueryBuilderOperation.js';
|
|
2
|
+
import { isPlainObject, isObject, isFunction } from '../../utils/objectUtils.js';
|
|
3
|
+
import { isKnexQueryBuilder, isKnexJoinBuilder } from '../../utils/knexUtils.js';
|
|
4
|
+
import { transformation } from '../transformations/index.js';
|
|
5
|
+
import { getJoinBuilder } from '../getJoinBuilder.js';
|
|
8
6
|
|
|
9
7
|
// An abstract operation base class that converts all arguments from objection types
|
|
10
8
|
// to knex types. For example objection query builders are converted into knex query
|
|
11
9
|
// builders and objection RawBuilder instances are converted into knex Raw instances.
|
|
12
|
-
class ObjectionToKnexConvertingOperation extends QueryBuilderOperation {
|
|
10
|
+
export class ObjectionToKnexConvertingOperation extends QueryBuilderOperation {
|
|
13
11
|
constructor(name, opt) {
|
|
14
12
|
super(name, opt);
|
|
15
13
|
this.args = null;
|
|
@@ -21,7 +19,8 @@ class ObjectionToKnexConvertingOperation extends QueryBuilderOperation {
|
|
|
21
19
|
|
|
22
20
|
onAdd(builder, args) {
|
|
23
21
|
this.args = Array.from(args);
|
|
24
|
-
|
|
22
|
+
assertNoUndefinedArgs(this.name, this.args);
|
|
23
|
+
return true;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
clone() {
|
|
@@ -31,52 +30,34 @@ class ObjectionToKnexConvertingOperation extends QueryBuilderOperation {
|
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
function
|
|
35
|
-
const skipUndefined = builder.internalOptions().skipUndefined;
|
|
36
|
-
|
|
33
|
+
function assertNoUndefinedArgs(opName, args) {
|
|
37
34
|
for (let i = 0, l = args.length; i < l; ++i) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (isUndefined(arg)) {
|
|
41
|
-
if (skipUndefined) {
|
|
42
|
-
return false;
|
|
43
|
-
} else {
|
|
44
|
-
throw new Error(
|
|
45
|
-
`undefined passed as argument #${i} for '${opName}' operation. Call skipUndefined() method to ignore the undefined values.`,
|
|
46
|
-
);
|
|
47
|
-
}
|
|
35
|
+
if (args[i] === undefined) {
|
|
36
|
+
throw new Error(`undefined passed as argument #${i} for '${opName}' operation.`);
|
|
48
37
|
}
|
|
49
38
|
}
|
|
50
|
-
|
|
51
|
-
return true;
|
|
52
39
|
}
|
|
53
40
|
|
|
54
41
|
function convertArgs(opName, builder, args) {
|
|
55
|
-
const skipUndefined = builder.internalOptions().skipUndefined;
|
|
56
|
-
|
|
57
42
|
return args.map((arg, i) => {
|
|
58
43
|
if (hasToKnexRawMethod(arg)) {
|
|
59
44
|
return convertToKnexRaw(arg, builder);
|
|
60
45
|
} else if (isObjectionQueryBuilderBase(arg)) {
|
|
61
46
|
return convertQueryBuilderBase(arg, builder);
|
|
62
47
|
} else if (isArray(arg)) {
|
|
63
|
-
return convertArray(arg, builder, i, opName
|
|
48
|
+
return convertArray(arg, builder, i, opName);
|
|
64
49
|
} else if (isFunction(arg)) {
|
|
65
50
|
return convertFunction(arg, builder);
|
|
66
51
|
} else if (isModel(arg)) {
|
|
67
52
|
return convertModel(arg);
|
|
68
53
|
} else if (isPlainObject(arg)) {
|
|
69
|
-
return convertPlainObject(arg, builder, i, opName
|
|
54
|
+
return convertPlainObject(arg, builder, i, opName);
|
|
70
55
|
} else {
|
|
71
56
|
return arg;
|
|
72
57
|
}
|
|
73
58
|
});
|
|
74
59
|
}
|
|
75
60
|
|
|
76
|
-
function isUndefined(item) {
|
|
77
|
-
return item === undefined;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
61
|
function hasToKnexRawMethod(item) {
|
|
81
62
|
return isObject(item) && isFunction(item.toKnexRaw);
|
|
82
63
|
}
|
|
@@ -98,19 +79,15 @@ function isArray(item) {
|
|
|
98
79
|
return Array.isArray(item);
|
|
99
80
|
}
|
|
100
81
|
|
|
101
|
-
function convertArray(arr, builder, i, opName
|
|
82
|
+
function convertArray(arr, builder, i, opName) {
|
|
102
83
|
return arr.map((item) => {
|
|
103
84
|
if (item === undefined) {
|
|
104
|
-
|
|
105
|
-
throw new Error(
|
|
106
|
-
`undefined passed as an item in argument #${i} for '${opName}' operation. Call skipUndefined() method to ignore the undefined values.`,
|
|
107
|
-
);
|
|
108
|
-
}
|
|
85
|
+
throw new Error(`undefined passed as an item in argument #${i} for '${opName}' operation.`);
|
|
109
86
|
} else if (opName === 'orderBy' && isObject(item)) {
|
|
110
87
|
// knex's `orderBy()` only reads `{ column, order, nulls }` objects from arrays,
|
|
111
88
|
// so wrap refs, raws and query builders in one and convert its properties.
|
|
112
89
|
const obj = isPlainObject(item) ? item : { column: item };
|
|
113
|
-
return convertPlainObject(obj, builder, i, opName
|
|
90
|
+
return convertPlainObject(obj, builder, i, opName);
|
|
114
91
|
} else if (hasToKnexRawMethod(item)) {
|
|
115
92
|
return convertToKnexRaw(item, builder);
|
|
116
93
|
} else if (isObjectionQueryBuilderBase(item)) {
|
|
@@ -160,16 +137,14 @@ function convertModel(model) {
|
|
|
160
137
|
return model.$toDatabaseJson();
|
|
161
138
|
}
|
|
162
139
|
|
|
163
|
-
function convertPlainObject(obj, builder, i, opName
|
|
140
|
+
function convertPlainObject(obj, builder, i, opName) {
|
|
164
141
|
return Object.keys(obj).reduce((out, key) => {
|
|
165
142
|
const item = obj[key];
|
|
166
143
|
|
|
167
144
|
if (item === undefined) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
);
|
|
172
|
-
}
|
|
145
|
+
throw new Error(
|
|
146
|
+
`undefined passed as a property in argument #${i} for '${opName}' operation.`,
|
|
147
|
+
);
|
|
173
148
|
} else if (hasToKnexRawMethod(item)) {
|
|
174
149
|
out[key] = convertToKnexRaw(item, builder);
|
|
175
150
|
} else if (isObjectionQueryBuilderBase(item)) {
|
|
@@ -181,7 +156,3 @@ function convertPlainObject(obj, builder, i, opName, skipUndefined) {
|
|
|
181
156
|
return out;
|
|
182
157
|
}, {});
|
|
183
158
|
}
|
|
184
|
-
|
|
185
|
-
module.exports = {
|
|
186
|
-
ObjectionToKnexConvertingOperation,
|
|
187
|
-
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { QueryBuilderOperation } from './QueryBuilderOperation.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class OnBuildKnexOperation extends QueryBuilderOperation {
|
|
3
|
+
export class OnBuildKnexOperation extends QueryBuilderOperation {
|
|
6
4
|
constructor(name, opt) {
|
|
7
5
|
super(name, opt);
|
|
8
6
|
this.func = null;
|
|
@@ -23,7 +21,3 @@ class OnBuildKnexOperation extends QueryBuilderOperation {
|
|
|
23
21
|
return clone;
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
module.exports = {
|
|
28
|
-
OnBuildKnexOperation,
|
|
29
|
-
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { QueryBuilderOperation } from './QueryBuilderOperation.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class OnBuildOperation extends QueryBuilderOperation {
|
|
3
|
+
export class OnBuildOperation extends QueryBuilderOperation {
|
|
6
4
|
constructor(name, opt) {
|
|
7
5
|
super(name, opt);
|
|
8
6
|
this.func = null;
|
|
@@ -23,7 +21,3 @@ class OnBuildOperation extends QueryBuilderOperation {
|
|
|
23
21
|
return clone;
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
module.exports = {
|
|
28
|
-
OnBuildOperation,
|
|
29
|
-
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { QueryBuilderOperation } from './QueryBuilderOperation.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class OnErrorOperation extends QueryBuilderOperation {
|
|
3
|
+
export class OnErrorOperation extends QueryBuilderOperation {
|
|
6
4
|
constructor(name, opt) {
|
|
7
5
|
super(name, opt);
|
|
8
6
|
this.func = null;
|
|
@@ -23,7 +21,3 @@ class OnErrorOperation extends QueryBuilderOperation {
|
|
|
23
21
|
return clone;
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
module.exports = {
|
|
28
|
-
OnErrorOperation,
|
|
29
|
-
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
const hookNameToHasMethodName = {
|
|
4
2
|
onAdd: 'hasOnAdd',
|
|
5
3
|
onBefore1: 'hasOnBefore1',
|
|
@@ -29,7 +27,7 @@ const hookNameToHasMethodName = {
|
|
|
29
27
|
// certain hook is called for _all_ operations before the next hook is called. For example if
|
|
30
28
|
// a builder has 5 operations, onBefore1 hook is called for each of them (and their results are awaited)
|
|
31
29
|
// before onBefore2 hook is called for any of the operations.
|
|
32
|
-
class QueryBuilderOperation {
|
|
30
|
+
export class QueryBuilderOperation {
|
|
33
31
|
constructor(name = null, opt = {}) {
|
|
34
32
|
this.name = name;
|
|
35
33
|
this.opt = opt;
|
|
@@ -322,7 +320,3 @@ Object.defineProperties(QueryBuilderOperation, {
|
|
|
322
320
|
value: true,
|
|
323
321
|
},
|
|
324
322
|
});
|
|
325
|
-
|
|
326
|
-
module.exports = {
|
|
327
|
-
QueryBuilderOperation,
|
|
328
|
-
};
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { QueryBuilderOperation } = require('./QueryBuilderOperation');
|
|
4
|
-
|
|
5
|
-
class RangeOperation extends QueryBuilderOperation {
|
|
6
|
-
constructor(name, opt) {
|
|
7
|
-
super(name, opt);
|
|
8
|
-
this.resultSizeBuilder = null;
|
|
9
|
-
}
|
|
1
|
+
import { RunAfterOperation } from './RunAfterOperation.js';
|
|
10
2
|
|
|
3
|
+
// Wraps the result in `{ results, total }` as a `runAfter` callback.
|
|
4
|
+
export class RangeOperation extends RunAfterOperation {
|
|
11
5
|
onAdd(builder, args) {
|
|
12
6
|
if (args.length === 2) {
|
|
13
7
|
const start = args[0];
|
|
@@ -22,26 +16,17 @@ class RangeOperation extends QueryBuilderOperation {
|
|
|
22
16
|
}
|
|
23
17
|
|
|
24
18
|
onBefore1(builder, result) {
|
|
25
|
-
|
|
26
|
-
return super.onBefore1(builder, result);
|
|
27
|
-
}
|
|
19
|
+
const resultSizeBuilder = builder.clone();
|
|
28
20
|
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
this.func = async (results) => {
|
|
22
|
+
const resultSize = await resultSizeBuilder.resultSize();
|
|
31
23
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
return {
|
|
25
|
+
results,
|
|
26
|
+
total: parseInt(resultSize),
|
|
27
|
+
};
|
|
35
28
|
};
|
|
36
|
-
}
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
const clone = super.clone();
|
|
40
|
-
clone.resultSizeBuilder = this.resultSizeBuilder;
|
|
41
|
-
return clone;
|
|
30
|
+
return super.onBefore1(builder, result);
|
|
42
31
|
}
|
|
43
32
|
}
|
|
44
|
-
|
|
45
|
-
module.exports = {
|
|
46
|
-
RangeOperation,
|
|
47
|
-
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { QueryBuilderOperation } from './QueryBuilderOperation.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class RelateOperation extends QueryBuilderOperation {
|
|
3
|
+
export class RelateOperation extends QueryBuilderOperation {
|
|
6
4
|
constructor(name, opt) {
|
|
7
5
|
super(name, opt);
|
|
8
6
|
|
|
@@ -21,7 +19,3 @@ class RelateOperation extends QueryBuilderOperation {
|
|
|
21
19
|
return clone;
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
module.exports = {
|
|
26
|
-
RelateOperation,
|
|
27
|
-
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { flatten, isPlainObject } = require('../../utils/objectUtils');
|
|
4
|
-
const { ObjectionToKnexConvertingOperation } = require('./ObjectionToKnexConvertingOperation');
|
|
1
|
+
import { flatten, isPlainObject } from '../../utils/objectUtils.js';
|
|
2
|
+
import { ObjectionToKnexConvertingOperation } from './ObjectionToKnexConvertingOperation.js';
|
|
5
3
|
|
|
6
4
|
// This class's purpose is to normalize the arguments into an array and to
|
|
7
5
|
// pass an optional trailing options object (e.g. `includeTriggerModifications`)
|
|
@@ -9,7 +7,7 @@ const { ObjectionToKnexConvertingOperation } = require('./ObjectionToKnexConvert
|
|
|
9
7
|
//
|
|
10
8
|
// In knex, if a single column is given to `returning` it returns an array with the that column's value
|
|
11
9
|
// in it. If an array is given with a one item inside, the return value is an object.
|
|
12
|
-
class ReturningOperation extends ObjectionToKnexConvertingOperation {
|
|
10
|
+
export class ReturningOperation extends ObjectionToKnexConvertingOperation {
|
|
13
11
|
constructor(name, opt) {
|
|
14
12
|
super(name, opt);
|
|
15
13
|
this.options = null;
|
|
@@ -49,7 +47,3 @@ class ReturningOperation extends ObjectionToKnexConvertingOperation {
|
|
|
49
47
|
return clone;
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
module.exports = {
|
|
54
|
-
ReturningOperation,
|
|
55
|
-
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { QueryBuilderOperation } from './QueryBuilderOperation.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class RunAfterOperation extends QueryBuilderOperation {
|
|
3
|
+
export class RunAfterOperation extends QueryBuilderOperation {
|
|
6
4
|
constructor(name, opt) {
|
|
7
5
|
super(name, opt);
|
|
8
6
|
this.func = null;
|
|
@@ -13,17 +11,9 @@ class RunAfterOperation extends QueryBuilderOperation {
|
|
|
13
11
|
return true;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
onAfter3(builder, result) {
|
|
17
|
-
return this.func.call(builder, result, builder);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
14
|
clone() {
|
|
21
15
|
const clone = super.clone();
|
|
22
16
|
clone.func = this.func;
|
|
23
17
|
return clone;
|
|
24
18
|
}
|
|
25
19
|
}
|
|
26
|
-
|
|
27
|
-
module.exports = {
|
|
28
|
-
RunAfterOperation,
|
|
29
|
-
};
|