@abedmurrar/objection 4.0.0-beta.0 → 4.0.0-beta.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/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/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/package.json +1 -1
|
@@ -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/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.2",
|
|
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",
|