@coderich/autograph 0.13.89 → 0.13.91
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/package.json +1 -1
- package/src/query/QueryBuilder.js +13 -11
- package/src/query/QueryResolver.js +2 -2
package/package.json
CHANGED
|
@@ -219,17 +219,19 @@ module.exports = class QueryBuilder {
|
|
|
219
219
|
args = args.flat();
|
|
220
220
|
const { id, limit } = this.#query;
|
|
221
221
|
const suffix = id || limit === 1 || (crud === 'create' && args.length < 2) ? 'One' : 'Many';
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
input
|
|
231
|
-
|
|
232
|
-
}
|
|
222
|
+
const op = `${crud}${suffix}`;
|
|
223
|
+
const key = `${crud}${this.#query.model}`;
|
|
224
|
+
const $crud = ['push', 'pull', 'splice'].includes(crud) ? 'update' : crud;
|
|
225
|
+
let input;
|
|
226
|
+
|
|
227
|
+
if (['create', 'update'].includes($crud)) {
|
|
228
|
+
input = op === 'createMany' ? args : args[0];
|
|
229
|
+
if (input === undefined) input = {};
|
|
230
|
+
if (id !== undefined) input.id = id;
|
|
231
|
+
this.#query.args.input = input;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return this.terminate(Object.assign(this.#query, { op, key, crud: $crud, input, isMutation: true }));
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
#propCheck(prop, ...checks) {
|
|
@@ -54,7 +54,7 @@ module.exports = class QueryResolver extends QueryBuilder {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
case 'pushMany': {
|
|
57
|
-
const [[key, values]] = Object.entries(input
|
|
57
|
+
const [[key, values]] = Object.entries(input);
|
|
58
58
|
return this.#find(query).then((docs) => {
|
|
59
59
|
return this.#resolver.transaction(false).run(Promise.all(docs.map(doc => this.#resolver.match(this.#model.name).id(doc.id).push(key, values))));
|
|
60
60
|
});
|
|
@@ -72,7 +72,7 @@ module.exports = class QueryResolver extends QueryBuilder {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
case 'pullMany': {
|
|
75
|
-
const [[key, values]] = Object.entries(input
|
|
75
|
+
const [[key, values]] = Object.entries(input);
|
|
76
76
|
return this.#find(query).then((docs) => {
|
|
77
77
|
return this.#resolver.transaction(false).run(Promise.all(docs.map(doc => this.#resolver.match(this.#model.name).id(doc.id).pull(key, values))));
|
|
78
78
|
});
|