@abedmurrar/objection 4.0.0-beta.0 → 4.0.0-beta.10
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 +1 -1
- package/lib/initialize.js +4 -5
- package/lib/model/AjvValidator.js +24 -21
- package/lib/model/Model.js +116 -114
- package/lib/model/ModifierNotFoundError.js +4 -4
- package/lib/model/NotFoundError.js +4 -4
- package/lib/model/RelationDoesNotExistError.js +4 -4
- package/lib/model/ValidationError.js +8 -8
- package/lib/model/Validator.js +7 -6
- package/lib/model/getModel.js +4 -4
- package/lib/model/graph/ModelGraph.js +9 -7
- package/lib/model/graph/ModelGraphBuilder.js +24 -24
- package/lib/model/graph/ModelGraphEdge.js +4 -4
- package/lib/model/graph/ModelGraphNode.js +17 -11
- package/lib/model/inheritModel.js +3 -4
- package/lib/model/modelBindKnex.js +12 -13
- package/lib/model/modelClone.js +15 -16
- package/lib/model/modelColPropMap.js +7 -8
- package/lib/model/modelConcurrency.js +6 -7
- package/lib/model/modelId.js +4 -5
- package/lib/model/modelJsonAttributes.js +10 -11
- package/lib/model/modelParseRelations.js +5 -6
- package/lib/model/modelQueryProps.js +12 -13
- package/lib/model/modelSet.js +17 -18
- package/lib/model/modelTableMetadata.js +9 -10
- package/lib/model/modelToJson.js +13 -14
- package/lib/model/modelUtils.js +7 -7
- package/lib/model/modelValidate.js +5 -6
- package/lib/model/modelValues.js +10 -10
- package/lib/model/modelVisitor.js +3 -4
- package/lib/objection.js +4 -26
- package/lib/queryBuilder/FunctionBuilder.js +35 -31
- package/lib/queryBuilder/InternalOptions.js +4 -4
- package/lib/queryBuilder/JoinBuilder.js +46 -45
- package/lib/queryBuilder/QueryBuilder.js +161 -135
- package/lib/queryBuilder/QueryBuilderBase.js +203 -203
- package/lib/queryBuilder/QueryBuilderContext.js +6 -6
- package/lib/queryBuilder/QueryBuilderContextBase.js +12 -8
- package/lib/queryBuilder/QueryBuilderOperationSupport.js +30 -25
- package/lib/queryBuilder/QueryBuilderUserContext.js +4 -4
- package/lib/queryBuilder/RawBuilder.js +15 -13
- package/lib/queryBuilder/ReferenceBuilder.js +25 -23
- package/lib/queryBuilder/RelationExpression.js +29 -20
- package/lib/queryBuilder/StaticHookArguments.js +11 -11
- package/lib/queryBuilder/ValueBuilder.js +20 -19
- package/lib/queryBuilder/expressions.js +8 -18
- package/lib/queryBuilder/functions/mysql.js +18 -42
- package/lib/queryBuilder/graph/GraphAction.js +7 -7
- package/lib/queryBuilder/graph/GraphData.js +4 -4
- package/lib/queryBuilder/graph/GraphFetcher.js +18 -17
- package/lib/queryBuilder/graph/GraphNodeDbExistence.js +45 -12
- package/lib/queryBuilder/graph/GraphOperation.js +4 -4
- package/lib/queryBuilder/graph/GraphOptions.js +5 -5
- package/lib/queryBuilder/graph/GraphUpsert.js +36 -36
- package/lib/queryBuilder/graph/delete/GraphDelete.js +8 -8
- package/lib/queryBuilder/graph/delete/GraphDeleteAction.js +46 -11
- package/lib/queryBuilder/graph/insert/GraphInsert.js +12 -12
- package/lib/queryBuilder/graph/insert/GraphInsertAction.js +59 -21
- package/lib/queryBuilder/graph/insert/JoinRowGraphInsertAction.js +49 -11
- package/lib/queryBuilder/graph/patch/GraphPatch.js +8 -8
- package/lib/queryBuilder/graph/patch/GraphPatchAction.js +52 -19
- package/lib/queryBuilder/graph/recursiveUpsert/GraphRecursiveUpsert.js +8 -8
- package/lib/queryBuilder/graph/recursiveUpsert/GraphRecursiveUpsertAction.js +54 -18
- package/lib/queryBuilder/join/JoinResultColumn.js +6 -4
- package/lib/queryBuilder/join/JoinResultParser.js +10 -8
- package/lib/queryBuilder/join/RelationJoiner.js +40 -35
- package/lib/queryBuilder/join/TableNode.js +7 -5
- package/lib/queryBuilder/join/TableTree.js +13 -9
- package/lib/queryBuilder/join/utils.js +8 -8
- package/lib/queryBuilder/operations/DelegateOperation.js +6 -6
- package/lib/queryBuilder/operations/DeleteOperation.js +11 -11
- package/lib/queryBuilder/operations/FindByIdOperation.js +8 -8
- package/lib/queryBuilder/operations/FindByIdsOperation.js +6 -6
- package/lib/queryBuilder/operations/FindOperation.js +23 -23
- package/lib/queryBuilder/operations/FirstOperation.js +6 -6
- package/lib/queryBuilder/operations/FromOperation.js +13 -13
- package/lib/queryBuilder/operations/InsertAndFetchOperation.js +12 -12
- package/lib/queryBuilder/operations/InsertGraphAndFetchOperation.js +10 -10
- package/lib/queryBuilder/operations/InsertGraphOperation.js +11 -11
- package/lib/queryBuilder/operations/InsertOperation.js +23 -22
- package/lib/queryBuilder/operations/InstanceDeleteOperation.js +12 -12
- package/lib/queryBuilder/operations/InstanceFindOperation.js +10 -10
- package/lib/queryBuilder/operations/InstanceInsertOperation.js +6 -6
- package/lib/queryBuilder/operations/InstanceUpdateOperation.js +14 -14
- package/lib/queryBuilder/operations/JoinRelatedOperation.js +13 -13
- package/lib/queryBuilder/operations/KnexOperation.js +6 -6
- package/lib/queryBuilder/operations/MergeOperation.js +11 -11
- package/lib/queryBuilder/operations/ObjectionToKnexConvertingOperation.js +26 -22
- package/lib/queryBuilder/operations/OnBuildKnexOperation.js +6 -6
- package/lib/queryBuilder/operations/OnBuildOperation.js +6 -6
- package/lib/queryBuilder/operations/OnErrorOperation.js +6 -6
- package/lib/queryBuilder/operations/QueryBuilderOperation.js +6 -4
- package/lib/queryBuilder/operations/RangeOperation.js +7 -6
- package/lib/queryBuilder/operations/RelateOperation.js +6 -6
- package/lib/queryBuilder/operations/ReturningOperation.js +8 -8
- package/lib/queryBuilder/operations/RunAfterOperation.js +6 -6
- package/lib/queryBuilder/operations/RunBeforeOperation.js +6 -6
- package/lib/queryBuilder/operations/UnrelateOperation.js +6 -6
- package/lib/queryBuilder/operations/UpdateAndFetchOperation.js +12 -12
- package/lib/queryBuilder/operations/UpdateOperation.js +24 -24
- package/lib/queryBuilder/operations/UpsertGraphAndFetchOperation.js +10 -10
- package/lib/queryBuilder/operations/UpsertGraphOperation.js +10 -10
- package/lib/queryBuilder/operations/WhereCompositeOperation.js +8 -8
- package/lib/queryBuilder/operations/WhereInOperation.js +11 -9
- package/lib/queryBuilder/operations/eager/EagerOperation.js +11 -9
- package/lib/queryBuilder/operations/eager/JoinEagerOperation.js +10 -12
- package/lib/queryBuilder/operations/eager/NaiveEagerOperation.js +6 -6
- package/lib/queryBuilder/operations/eager/WhereInEagerOperation.js +64 -28
- package/lib/queryBuilder/operations/jsonApi/WhereJsonHasOperation.js +45 -12
- package/lib/queryBuilder/operations/jsonApi/WhereJsonNotObjectOperation.js +45 -12
- package/lib/queryBuilder/operations/jsonApi/WhereJsonOperation.js +45 -12
- package/lib/queryBuilder/operations/jsonApi/WhereJsonOverlapsOperation.js +46 -13
- package/lib/queryBuilder/operations/jsonApi/mysqlJsonApi.js +22 -27
- package/lib/queryBuilder/operations/jsonApi/postgresJsonApi.js +51 -17
- package/lib/queryBuilder/operations/select/SelectOperation.js +12 -12
- package/lib/queryBuilder/operations/select/Selection.js +23 -19
- package/lib/queryBuilder/operations/types.js +8 -0
- package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeMsSqlOperation.js +13 -12
- package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeOperation.js +11 -11
- package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeSqliteOperation.js +10 -10
- package/lib/queryBuilder/transformations/CompositeQueryTransformation.js +6 -6
- package/lib/queryBuilder/transformations/QueryTransformation.js +4 -4
- package/lib/queryBuilder/transformations/WrapMysqlModifySubqueryTransformation.js +11 -8
- package/lib/queryBuilder/transformations/index.js +8 -8
- package/lib/queryBuilder/whereScopes.js +15 -21
- package/lib/relations/Relation.js +31 -29
- package/lib/relations/RelationDeleteOperation.js +8 -8
- package/lib/relations/RelationFindOperation.js +8 -6
- package/lib/relations/RelationInsertOperation.js +6 -6
- package/lib/relations/RelationOwner.js +16 -13
- package/lib/relations/RelationProperty.js +18 -15
- package/lib/relations/RelationUpdateOperation.js +8 -8
- package/lib/relations/belongsToOne/BelongsToOneDeleteOperation.js +6 -6
- package/lib/relations/belongsToOne/BelongsToOneInsertOperation.js +8 -8
- package/lib/relations/belongsToOne/BelongsToOneRelateOperation.js +8 -8
- package/lib/relations/belongsToOne/BelongsToOneRelation.js +14 -14
- package/lib/relations/belongsToOne/BelongsToOneUnrelateOperation.js +6 -6
- package/lib/relations/hasMany/HasManyInsertOperation.js +6 -6
- package/lib/relations/hasMany/HasManyRelateOperation.js +11 -11
- package/lib/relations/hasMany/HasManyRelation.js +12 -12
- package/lib/relations/hasMany/HasManyUnrelateOperation.js +9 -9
- package/lib/relations/hasOne/HasOneRelation.js +6 -6
- package/lib/relations/hasOneThrough/HasOneThroughRelation.js +6 -6
- package/lib/relations/manyToMany/ManyToManyModifyMixin.js +9 -8
- package/lib/relations/manyToMany/ManyToManyRelation.js +52 -49
- package/lib/relations/manyToMany/ManyToManySqliteModifyMixin.js +6 -6
- package/lib/relations/manyToMany/delete/ManyToManyDeleteOperation.js +7 -7
- package/lib/relations/manyToMany/delete/ManyToManyDeleteOperationBase.js +6 -6
- package/lib/relations/manyToMany/delete/ManyToManyDeleteSqliteOperation.js +7 -7
- package/lib/relations/manyToMany/find/ManyToManyFindOperation.js +8 -8
- package/lib/relations/manyToMany/insert/ManyToManyInsertOperation.js +8 -8
- package/lib/relations/manyToMany/relate/ManyToManyRelateOperation.js +11 -10
- package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateOperation.js +7 -7
- package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateOperationBase.js +8 -8
- package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateSqliteOperation.js +7 -7
- package/lib/relations/manyToMany/update/ManyToManyUpdateOperation.js +7 -7
- package/lib/relations/manyToMany/update/ManyToManyUpdateOperationBase.js +8 -8
- package/lib/relations/manyToMany/update/ManyToManyUpdateSqliteOperation.js +7 -7
- package/lib/transaction.js +44 -12
- package/lib/utils/objectUtils.js +6 -1
- package/lib/utils/parseFieldExpression.js +4 -35
- package/lib/utils/promiseUtils/index.js +19 -9
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyToManyDeleteOperation = void 0;
|
|
4
|
+
const ManyToManyDeleteOperationBase_1 = require("./ManyToManyDeleteOperationBase");
|
|
5
|
+
const ManyToManyModifyMixin_1 = require("../ManyToManyModifyMixin");
|
|
6
|
+
class ManyToManyDeleteOperation extends (0, ManyToManyModifyMixin_1.ManyToManyModifyMixin)(ManyToManyDeleteOperationBase_1.ManyToManyDeleteOperationBase) {
|
|
5
7
|
}
|
|
6
|
-
|
|
7
|
-
ManyToManyDeleteOperation,
|
|
8
|
-
};
|
|
8
|
+
exports.ManyToManyDeleteOperation = ManyToManyDeleteOperation;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyToManyDeleteOperationBase = void 0;
|
|
4
|
+
const DeleteOperation_1 = require("../../../queryBuilder/operations/DeleteOperation");
|
|
5
|
+
class ManyToManyDeleteOperationBase extends DeleteOperation_1.DeleteOperation {
|
|
4
6
|
constructor(name, opt) {
|
|
5
7
|
super(name, opt);
|
|
6
8
|
this.relation = opt.relation;
|
|
@@ -15,6 +17,4 @@ class ManyToManyDeleteOperationBase extends DeleteOperation {
|
|
|
15
17
|
throw new Error('not implemented');
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
ManyToManyDeleteOperationBase,
|
|
20
|
-
};
|
|
20
|
+
exports.ManyToManyDeleteOperationBase = ManyToManyDeleteOperationBase;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyToManyDeleteSqliteOperation = void 0;
|
|
4
|
+
const ManyToManyDeleteOperationBase_1 = require("./ManyToManyDeleteOperationBase");
|
|
5
|
+
const ManyToManySqliteModifyMixin_1 = require("../ManyToManySqliteModifyMixin");
|
|
6
|
+
class ManyToManyDeleteSqliteOperation extends (0, ManyToManySqliteModifyMixin_1.ManyToManySqliteModifyMixin)(ManyToManyDeleteOperationBase_1.ManyToManyDeleteOperationBase) {
|
|
5
7
|
}
|
|
6
|
-
|
|
7
|
-
ManyToManyDeleteSqliteOperation,
|
|
8
|
-
};
|
|
8
|
+
exports.ManyToManyDeleteSqliteOperation = ManyToManyDeleteSqliteOperation;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyToManyFindOperation = void 0;
|
|
4
|
+
const RelationFindOperation_1 = require("../../RelationFindOperation");
|
|
5
|
+
const tmpColumnUtils_1 = require("../../../utils/tmpColumnUtils");
|
|
6
|
+
class ManyToManyFindOperation extends RelationFindOperation_1.RelationFindOperation {
|
|
5
7
|
constructor(name, opt) {
|
|
6
8
|
super(name, opt);
|
|
7
9
|
this.ownerJoinColumnAlias = new Array(this.relation.joinTableOwnerProp.size);
|
|
8
10
|
for (let i = 0, l = this.ownerJoinColumnAlias.length; i < l; ++i) {
|
|
9
|
-
this.ownerJoinColumnAlias[i] = getTempColumn(i);
|
|
11
|
+
this.ownerJoinColumnAlias[i] = (0, tmpColumnUtils_1.getTempColumn)(i);
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
onBuild(builder) {
|
|
@@ -77,6 +79,4 @@ class ManyToManyFindOperation extends RelationFindOperation {
|
|
|
77
79
|
super.selectMissingJoinColumns(builder);
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
|
-
|
|
81
|
-
ManyToManyFindOperation,
|
|
82
|
-
};
|
|
82
|
+
exports.ManyToManyFindOperation = ManyToManyFindOperation;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyToManyInsertOperation = void 0;
|
|
4
|
+
const RelationInsertOperation_1 = require("../../RelationInsertOperation");
|
|
5
|
+
const ManyToManyRelateOperation_1 = require("../relate/ManyToManyRelateOperation");
|
|
6
|
+
class ManyToManyInsertOperation extends RelationInsertOperation_1.RelationInsertOperation {
|
|
5
7
|
onAdd(builder, args) {
|
|
6
8
|
const retVal = super.onAdd(builder, args);
|
|
7
9
|
// Omit extra properties so that we don't try to insert
|
|
@@ -13,7 +15,7 @@ class ManyToManyInsertOperation extends RelationInsertOperation {
|
|
|
13
15
|
}
|
|
14
16
|
async onAfter1(builder, ret) {
|
|
15
17
|
const inserted = await super.onAfter1(builder, ret);
|
|
16
|
-
const relateOp = new ManyToManyRelateOperation('relate', {
|
|
18
|
+
const relateOp = new ManyToManyRelateOperation_1.ManyToManyRelateOperation('relate', {
|
|
17
19
|
dontCopyReturning: true,
|
|
18
20
|
dontCopyOnConflict: true,
|
|
19
21
|
relation: this.relation,
|
|
@@ -35,6 +37,4 @@ class ManyToManyInsertOperation extends RelationInsertOperation {
|
|
|
35
37
|
return inserted;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
|
-
|
|
39
|
-
ManyToManyInsertOperation,
|
|
40
|
-
};
|
|
40
|
+
exports.ManyToManyInsertOperation = ManyToManyInsertOperation;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyToManyRelateOperation = void 0;
|
|
4
|
+
const knexUtils_1 = require("../../../utils/knexUtils");
|
|
5
|
+
const normalizeIds_1 = require("../../../utils/normalizeIds");
|
|
6
|
+
const RelateOperation_1 = require("../../../queryBuilder/operations/RelateOperation");
|
|
7
|
+
class ManyToManyRelateOperation extends RelateOperation_1.RelateOperation {
|
|
6
8
|
onAdd(builder, args) {
|
|
7
9
|
this.input = args[0];
|
|
8
|
-
|
|
10
|
+
// Without `arrayOutput`, these are id objects.
|
|
11
|
+
this.ids = (0, normalizeIds_1.normalizeIds)(args[0], this.relation.relatedProp);
|
|
9
12
|
assertOwnerIsSingleItem(builder, this.owner, this.relation);
|
|
10
13
|
return true;
|
|
11
14
|
}
|
|
@@ -38,12 +41,13 @@ class ManyToManyRelateOperation extends RelateOperation {
|
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
43
|
}
|
|
44
|
+
exports.ManyToManyRelateOperation = ManyToManyRelateOperation;
|
|
41
45
|
function assertOwnerIsSingleItem(builder, owner, relation) {
|
|
42
46
|
const { isModels, isIdentifiers, isQueryBuilder } = owner;
|
|
43
47
|
const { ownerProp } = relation;
|
|
44
48
|
const singleModel = isModels && owner.modelArray.length === 1;
|
|
45
49
|
const singleId = isIdentifiers && owner.getNormalizedIdentifiers(ownerProp).length === 1;
|
|
46
|
-
if (isPostgres(builder.unsafeKnex())) {
|
|
50
|
+
if ((0, knexUtils_1.isPostgres)(builder.unsafeKnex())) {
|
|
47
51
|
if (!isModels && !isIdentifiers && !isQueryBuilder) {
|
|
48
52
|
throw new Error('Parent must be a list of identifiers or a list of models when relating a ManyToManyRelation');
|
|
49
53
|
}
|
|
@@ -59,6 +63,3 @@ function assertOwnerIsSingleItem(builder, owner, relation) {
|
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
|
-
module.exports = {
|
|
63
|
-
ManyToManyRelateOperation,
|
|
64
|
-
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyToManyUnrelateOperation = void 0;
|
|
4
|
+
const ManyToManyUnrelateOperationBase_1 = require("./ManyToManyUnrelateOperationBase");
|
|
5
|
+
const ManyToManyModifyMixin_1 = require("../ManyToManyModifyMixin");
|
|
6
|
+
class ManyToManyUnrelateOperation extends (0, ManyToManyModifyMixin_1.ManyToManyModifyMixin)(ManyToManyUnrelateOperationBase_1.ManyToManyUnrelateOperationBase) {
|
|
5
7
|
get modifyMainQuery() {
|
|
6
8
|
return false;
|
|
7
9
|
}
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
ManyToManyUnrelateOperation,
|
|
11
|
-
};
|
|
11
|
+
exports.ManyToManyUnrelateOperation = ManyToManyUnrelateOperation;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyToManyUnrelateOperationBase = void 0;
|
|
4
|
+
const whereScopes_1 = require("../../../queryBuilder/whereScopes");
|
|
5
|
+
const UnrelateOperation_1 = require("../../../queryBuilder/operations/UnrelateOperation");
|
|
6
|
+
class ManyToManyUnrelateOperationBase extends UnrelateOperation_1.UnrelateOperation {
|
|
5
7
|
queryExecutor(builder) {
|
|
6
8
|
const unrelateQuery = this.relation
|
|
7
9
|
.getJoinModelClass(builder.knex())
|
|
8
10
|
.query()
|
|
9
11
|
.childQueryOf(builder)
|
|
10
12
|
.delete();
|
|
11
|
-
withWhereScope(unrelateQuery, () => {
|
|
13
|
+
(0, whereScopes_1.withWhereScope)(unrelateQuery, () => {
|
|
12
14
|
this.applyModifyFilterForJoinTable(unrelateQuery);
|
|
13
15
|
});
|
|
14
16
|
return unrelateQuery.modify(this.relation.joinTableModify);
|
|
@@ -22,6 +24,4 @@ class ManyToManyUnrelateOperationBase extends UnrelateOperation {
|
|
|
22
24
|
throw new Error('not implemented');
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
ManyToManyUnrelateOperationBase,
|
|
27
|
-
};
|
|
27
|
+
exports.ManyToManyUnrelateOperationBase = ManyToManyUnrelateOperationBase;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyToManyUnrelateSqliteOperation = void 0;
|
|
4
|
+
const ManyToManyUnrelateOperationBase_1 = require("./ManyToManyUnrelateOperationBase");
|
|
5
|
+
const ManyToManySqliteModifyMixin_1 = require("../ManyToManySqliteModifyMixin");
|
|
6
|
+
class ManyToManyUnrelateSqliteOperation extends (0, ManyToManySqliteModifyMixin_1.ManyToManySqliteModifyMixin)(ManyToManyUnrelateOperationBase_1.ManyToManyUnrelateOperationBase) {
|
|
5
7
|
get modifyMainQuery() {
|
|
6
8
|
return false;
|
|
7
9
|
}
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
ManyToManyUnrelateSqliteOperation,
|
|
11
|
-
};
|
|
11
|
+
exports.ManyToManyUnrelateSqliteOperation = ManyToManyUnrelateSqliteOperation;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyToManyUpdateOperation = void 0;
|
|
4
|
+
const ManyToManyUpdateOperationBase_1 = require("./ManyToManyUpdateOperationBase");
|
|
5
|
+
const ManyToManyModifyMixin_1 = require("../ManyToManyModifyMixin");
|
|
6
|
+
class ManyToManyUpdateOperation extends (0, ManyToManyModifyMixin_1.ManyToManyModifyMixin)(ManyToManyUpdateOperationBase_1.ManyToManyUpdateOperationBase) {
|
|
5
7
|
}
|
|
6
|
-
|
|
7
|
-
ManyToManyUpdateOperation,
|
|
8
|
-
};
|
|
8
|
+
exports.ManyToManyUpdateOperation = ManyToManyUpdateOperation;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyToManyUpdateOperationBase = void 0;
|
|
4
|
+
const whereScopes_1 = require("../../../queryBuilder/whereScopes");
|
|
5
|
+
const UpdateOperation_1 = require("../../../queryBuilder/operations/UpdateOperation");
|
|
6
|
+
class ManyToManyUpdateOperationBase extends UpdateOperation_1.UpdateOperation {
|
|
5
7
|
constructor(name, opt) {
|
|
6
8
|
super(name, opt);
|
|
7
9
|
this.relation = opt.relation;
|
|
@@ -34,7 +36,7 @@ class ManyToManyUpdateOperationBase extends UpdateOperation {
|
|
|
34
36
|
.query()
|
|
35
37
|
.childQueryOf(builder)
|
|
36
38
|
.patch(this.joinTablePatch);
|
|
37
|
-
withWhereScope(joinTableUpdateQuery, () => {
|
|
39
|
+
(0, whereScopes_1.withWhereScope)(joinTableUpdateQuery, () => {
|
|
38
40
|
this.applyModifyFilterForJoinTable(joinTableUpdateQuery);
|
|
39
41
|
});
|
|
40
42
|
await joinTableUpdateQuery.modify(this.relation.joinTableModify);
|
|
@@ -60,6 +62,4 @@ class ManyToManyUpdateOperationBase extends UpdateOperation {
|
|
|
60
62
|
return clone;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
|
-
|
|
64
|
-
ManyToManyUpdateOperationBase,
|
|
65
|
-
};
|
|
65
|
+
exports.ManyToManyUpdateOperationBase = ManyToManyUpdateOperationBase;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyToManyUpdateSqliteOperation = void 0;
|
|
4
|
+
const ManyToManyUpdateOperationBase_1 = require("./ManyToManyUpdateOperationBase");
|
|
5
|
+
const ManyToManySqliteModifyMixin_1 = require("../ManyToManySqliteModifyMixin");
|
|
6
|
+
class ManyToManyUpdateSqliteOperation extends (0, ManyToManySqliteModifyMixin_1.ManyToManySqliteModifyMixin)(ManyToManyUpdateOperationBase_1.ManyToManyUpdateOperationBase) {
|
|
5
7
|
}
|
|
6
|
-
|
|
7
|
-
ManyToManyUpdateSqliteOperation,
|
|
8
|
-
};
|
|
8
|
+
exports.ManyToManyUpdateSqliteOperation = ManyToManyUpdateSqliteOperation;
|
package/lib/transaction.js
CHANGED
|
@@ -1,13 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.transaction = transaction;
|
|
37
|
+
const promiseUtils = __importStar(require("./utils/promiseUtils"));
|
|
38
|
+
const objectUtils_1 = require("./utils/objectUtils");
|
|
39
|
+
function transaction(...transactionArgs) {
|
|
5
40
|
// There must be at least one model class and the callback.
|
|
6
|
-
if (
|
|
41
|
+
if (transactionArgs.length < 2) {
|
|
7
42
|
return Promise.reject(new Error('objection.transaction: provide at least one Model class to bind to the transaction or a knex instance'));
|
|
8
43
|
}
|
|
9
|
-
let args = Array.from(
|
|
10
|
-
if (!isModelClass(args[0]) && isFunction(args[0].transaction)) {
|
|
44
|
+
let args = Array.from(transactionArgs);
|
|
45
|
+
if (!isModelClass(args[0]) && (0, objectUtils_1.isFunction)(args[0].transaction)) {
|
|
11
46
|
const knex = args[0];
|
|
12
47
|
args = args.slice(1);
|
|
13
48
|
return knex.transaction.apply(knex, args);
|
|
@@ -45,7 +80,7 @@ transaction.start = function (modelClassOrKnex) {
|
|
|
45
80
|
if (isModelClass(modelClassOrKnex)) {
|
|
46
81
|
knex = modelClassOrKnex.knex();
|
|
47
82
|
}
|
|
48
|
-
if (!knex || !isFunction(knex.transaction)) {
|
|
83
|
+
if (!knex || !(0, objectUtils_1.isFunction)(knex.transaction)) {
|
|
49
84
|
return Promise.reject(new Error('objection.transaction.start: first argument must be a model class or a knex instance'));
|
|
50
85
|
}
|
|
51
86
|
return new Promise((resolve, reject) => {
|
|
@@ -59,8 +94,5 @@ transaction.start = function (modelClassOrKnex) {
|
|
|
59
94
|
});
|
|
60
95
|
};
|
|
61
96
|
function isModelClass(maybeModel) {
|
|
62
|
-
return isFunction(maybeModel) && maybeModel.isObjectionModelClass;
|
|
97
|
+
return (0, objectUtils_1.isFunction)(maybeModel) && maybeModel.isObjectionModelClass;
|
|
63
98
|
}
|
|
64
|
-
module.exports = {
|
|
65
|
-
transaction,
|
|
66
|
-
};
|
package/lib/utils/objectUtils.js
CHANGED
|
@@ -25,7 +25,12 @@ exports.last = last;
|
|
|
25
25
|
exports.get = get;
|
|
26
26
|
exports.set = set;
|
|
27
27
|
const cloneDeep_1 = require("./cloneDeep");
|
|
28
|
-
|
|
28
|
+
// Re-exporting an imported binding makes tsc define the export as a getter,
|
|
29
|
+
// which puts this module's whole exports object in V8's slow dictionary mode
|
|
30
|
+
// and makes every `objectUtils.x()` call several times slower. A local
|
|
31
|
+
// constant is exported as a plain property instead.
|
|
32
|
+
const cloneDeep = cloneDeep_1.cloneDeep;
|
|
33
|
+
exports.cloneDeep = cloneDeep;
|
|
29
34
|
const SMALL_ARRAY_SIZE = 10;
|
|
30
35
|
function isEmpty(item) {
|
|
31
36
|
if (Array.isArray(item) || Buffer.isBuffer(item)) {
|
|
@@ -1,40 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.parseFieldExpression = parseFieldExpression;
|
|
37
|
-
|
|
4
|
+
// A named import: `import * as` of a JavaScript module wraps it in an object
|
|
5
|
+
// of getters (tsc's __importStar), which is slow to call through.
|
|
6
|
+
const jsonFieldExpressionParser_1 = require("../queryBuilder/parsers/jsonFieldExpressionParser");
|
|
38
7
|
const cache = new Map();
|
|
39
8
|
function parseFieldExpression(expr) {
|
|
40
9
|
let parsedExpr = cache.get(expr);
|
|
@@ -42,7 +11,7 @@ function parseFieldExpression(expr) {
|
|
|
42
11
|
return parsedExpr;
|
|
43
12
|
}
|
|
44
13
|
else {
|
|
45
|
-
const parserOutput =
|
|
14
|
+
const parserOutput = (0, jsonFieldExpressionParser_1.parse)(expr);
|
|
46
15
|
parsedExpr = preprocessParsedExpression(parserOutput);
|
|
47
16
|
// We don't take a copy of the parsedExpr each time we
|
|
48
17
|
// use if from cache. Instead to make sure it's never
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.try = exports.
|
|
4
|
-
const isPromise_1 = require("./isPromise");
|
|
5
|
-
Object.defineProperty(exports, "isPromise", { enumerable: true, get: function () { return isPromise_1.isPromise; } });
|
|
3
|
+
exports.try = exports.mapAfterAllReturn = exports.map = exports.isPromise = exports.afterReturn = exports.after = void 0;
|
|
6
4
|
const after_1 = require("./after");
|
|
7
|
-
Object.defineProperty(exports, "after", { enumerable: true, get: function () { return after_1.after; } });
|
|
8
5
|
const afterReturn_1 = require("./afterReturn");
|
|
9
|
-
|
|
10
|
-
const mapAfterAllReturn_1 = require("./mapAfterAllReturn");
|
|
11
|
-
Object.defineProperty(exports, "mapAfterAllReturn", { enumerable: true, get: function () { return mapAfterAllReturn_1.mapAfterAllReturn; } });
|
|
6
|
+
const isPromise_1 = require("./isPromise");
|
|
12
7
|
const map_1 = require("./map");
|
|
13
|
-
|
|
8
|
+
const mapAfterAllReturn_1 = require("./mapAfterAllReturn");
|
|
14
9
|
const try_1 = require("./try");
|
|
15
|
-
|
|
10
|
+
// Re-exporting imported bindings makes tsc define the exports as getters,
|
|
11
|
+
// which puts this module's exports object in V8's slow dictionary mode and
|
|
12
|
+
// makes every call through it several times slower. Local constants are
|
|
13
|
+
// exported as plain properties instead.
|
|
14
|
+
const isPromise = isPromise_1.isPromise;
|
|
15
|
+
exports.isPromise = isPromise;
|
|
16
|
+
const after = after_1.after;
|
|
17
|
+
exports.after = after;
|
|
18
|
+
const afterReturn = afterReturn_1.afterReturn;
|
|
19
|
+
exports.afterReturn = afterReturn;
|
|
20
|
+
const mapAfterAllReturn = mapAfterAllReturn_1.mapAfterAllReturn;
|
|
21
|
+
exports.mapAfterAllReturn = mapAfterAllReturn;
|
|
22
|
+
const map = map_1.promiseMap;
|
|
23
|
+
exports.map = map;
|
|
24
|
+
const promiseTryExport = try_1.promiseTry;
|
|
25
|
+
exports.try = promiseTryExport;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abedmurrar/objection",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.10",
|
|
4
4
|
"description": "An SQL-friendly ORM for Node.js. A fork of objection.js with strict TypeScript types and MySQL support.",
|
|
5
5
|
"main": "lib/objection.js",
|
|
6
6
|
"type": "commonjs",
|