objection 3.0.0-rc.2 → 3.0.0-rc.3
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/QueryBuilderOperationSupport.js +2 -0
- package/lib/queryBuilder/RelationExpression.js +1 -1
- package/lib/queryBuilder/graph/recursiveUpsert/GraphRecursiveUpsert.js +1 -1
- package/lib/relations/RelationOwner.js +2 -4
- package/package.json +1 -1
- package/lib/model/modelFilter.js +0 -103
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const { isString, isFunction, isRegExp, last } = require('../utils/objectUtils');
|
|
4
4
|
const { QueryBuilderContextBase } = require('./QueryBuilderContextBase');
|
|
5
5
|
const { QueryBuilderUserContext } = require('./QueryBuilderUserContext');
|
|
6
|
+
const { deprecate } = require('../utils/deprecate');
|
|
6
7
|
|
|
7
8
|
const AllSelector = () => true;
|
|
8
9
|
const SelectSelector =
|
|
@@ -494,6 +495,7 @@ class QueryBuilderOperationSupport {
|
|
|
494
495
|
}
|
|
495
496
|
|
|
496
497
|
skipUndefined() {
|
|
498
|
+
deprecate('skipUndefined() is deprecated and will be removed in objection 4.0');
|
|
497
499
|
this.internalOptions().skipUndefined = true;
|
|
498
500
|
return this;
|
|
499
501
|
}
|
|
@@ -291,7 +291,7 @@ function modelToNode(model, node) {
|
|
|
291
291
|
for (let r = 0, lr = relationNames.length; r < lr; ++r) {
|
|
292
292
|
const relName = relationNames[r];
|
|
293
293
|
|
|
294
|
-
if (model
|
|
294
|
+
if (model[relName] !== undefined) {
|
|
295
295
|
let childNode = node[relName];
|
|
296
296
|
|
|
297
297
|
if (!childNode) {
|
|
@@ -18,7 +18,7 @@ class GraphRecursiveUpsert extends GraphOperation {
|
|
|
18
18
|
|
|
19
19
|
function hasRelations(obj) {
|
|
20
20
|
for (const relationName of obj.constructor.getRelationNames()) {
|
|
21
|
-
if (obj
|
|
21
|
+
if (obj[relationName] !== undefined) {
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -71,12 +71,10 @@ class RelationOwner {
|
|
|
71
71
|
if (values) {
|
|
72
72
|
builder.whereInComposite(relatedRefs, values);
|
|
73
73
|
} else {
|
|
74
|
-
builder.where(false);
|
|
75
|
-
builder.resolve([]);
|
|
74
|
+
builder.where(false).resolve([]);
|
|
76
75
|
}
|
|
77
76
|
} else {
|
|
78
|
-
builder.where(false);
|
|
79
|
-
builder.resolve([]);
|
|
77
|
+
builder.where(false).resolve([]);
|
|
80
78
|
}
|
|
81
79
|
|
|
82
80
|
return builder;
|
package/package.json
CHANGED
package/lib/model/modelFilter.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { isObject } = require('../utils/objectUtils');
|
|
4
|
-
const { isInternalProp } = require('../utils/internalPropUtils');
|
|
5
|
-
|
|
6
|
-
function omit(model, args) {
|
|
7
|
-
if (args.length === 1 && isObject(args[0])) {
|
|
8
|
-
const keys = args[0];
|
|
9
|
-
|
|
10
|
-
if (Array.isArray(keys)) {
|
|
11
|
-
omitArray(model, keys);
|
|
12
|
-
} else {
|
|
13
|
-
omitObject(model, keys);
|
|
14
|
-
}
|
|
15
|
-
} else {
|
|
16
|
-
omitArray(model, args);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return model;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function pick(model, args) {
|
|
23
|
-
if (args.length === 1 && isObject(args[0])) {
|
|
24
|
-
const keys = args[0];
|
|
25
|
-
|
|
26
|
-
if (Array.isArray(keys)) {
|
|
27
|
-
pickArray(model, keys);
|
|
28
|
-
} else {
|
|
29
|
-
pickObject(model, keys);
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
pickArray(model, args);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return model;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function omitObject(model, keyObj) {
|
|
39
|
-
const modelClass = model.constructor;
|
|
40
|
-
const keys = Object.keys(keyObj);
|
|
41
|
-
|
|
42
|
-
for (let i = 0, l = keys.length; i < l; ++i) {
|
|
43
|
-
const key = keys[i];
|
|
44
|
-
const value = keyObj[key];
|
|
45
|
-
|
|
46
|
-
if (value && !isInternalProp(key) && model.hasOwnProperty(key)) {
|
|
47
|
-
modelClass.omitImpl(model, key);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function omitArray(model, keys) {
|
|
53
|
-
const modelClass = model.constructor;
|
|
54
|
-
|
|
55
|
-
for (let i = 0, l = keys.length; i < l; ++i) {
|
|
56
|
-
const key = keys[i];
|
|
57
|
-
|
|
58
|
-
if (!isInternalProp(key) && model.hasOwnProperty(key)) {
|
|
59
|
-
modelClass.omitImpl(model, key);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function pickObject(model, keyObj) {
|
|
65
|
-
const modelClass = model.constructor;
|
|
66
|
-
const keys = Object.keys(model);
|
|
67
|
-
|
|
68
|
-
for (let i = 0, l = keys.length; i < l; ++i) {
|
|
69
|
-
const key = keys[i];
|
|
70
|
-
|
|
71
|
-
if (!isInternalProp(key) && !keyObj[key]) {
|
|
72
|
-
modelClass.omitImpl(model, key);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function pickArray(model, pick) {
|
|
78
|
-
const modelClass = model.constructor;
|
|
79
|
-
const keys = Object.keys(model);
|
|
80
|
-
|
|
81
|
-
for (let i = 0, l = keys.length; i < l; ++i) {
|
|
82
|
-
const key = keys[i];
|
|
83
|
-
|
|
84
|
-
if (!isInternalProp(key) && !contains(pick, key)) {
|
|
85
|
-
modelClass.omitImpl(model, key);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function contains(arr, value) {
|
|
91
|
-
for (let i = 0, l = arr.length; i < l; ++i) {
|
|
92
|
-
if (arr[i] === value) {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
module.exports = {
|
|
101
|
-
omit,
|
|
102
|
-
pick,
|
|
103
|
-
};
|