@coderich/autograph 0.13.48 → 0.13.49

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coderich/autograph",
3
3
  "main": "index.js",
4
- "version": "0.13.48",
4
+ "version": "0.13.49",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -117,7 +117,9 @@ module.exports = class Pipeline {
117
117
  const ids = Util.filterBy(Util.ensureArray(value), (a, b) => `${a}` === `${b}`);
118
118
  if (!ids.length) return undefined;
119
119
  return resolver.match(type).flags(query.flags).where({ [fkField]: ids }).count().then((count) => {
120
- if (count !== ids.length) throw Boom.notFound(`${type} Not Found`);
120
+ if (count !== ids.length) {
121
+ throw Boom.notFound(`${type} Not Found`);
122
+ }
121
123
  });
122
124
  }, { itemize: false });
123
125
 
@@ -65,8 +65,10 @@ module.exports = class QueryResolver extends QueryBuilder {
65
65
  return this.#get(query).then((doc) => {
66
66
  const [key] = Object.keys(input);
67
67
  const values = get(this.#model.transformers.input.transform(input), key, []);
68
- const $input = { [key]: (get(doc, key) || []).filter(el => values.every(v => `${v}` !== `${el}`)) };
69
- return this.#resolver.match(this.#model.name).id(doc.id).save($input);
68
+ const $doc = Util.pathmap(key, doc, (arr) => {
69
+ return arr.filter(el => values.every(v => `${v}` !== `${el}`));
70
+ });
71
+ return this.#resolver.match(this.#model.name).id(doc.id).save($doc);
70
72
  });
71
73
  }
72
74
  case 'pullMany': {
@@ -110,11 +112,11 @@ module.exports = class QueryResolver extends QueryBuilder {
110
112
  }
111
113
 
112
114
  #resolveReferentialIntegrity(doc) {
113
- const { id } = doc;
114
115
  const txn = this.#resolver.transaction(false);
115
116
 
116
117
  return txn.run(Util.promiseChain(this.#model.referentialIntegrity.map(({ model, field, path }) => () => {
117
- const { onDelete, isArray } = field;
118
+ const { onDelete, isArray, fkField } = field;
119
+ const id = doc[fkField];
118
120
  const $path = path.join('.');
119
121
  const where = field.isVirtual ? { [field.model.pkField]: get(doc, field.linkBy) } : { [$path]: id };
120
122