@coderich/autograph 0.13.88 → 0.13.90

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.88",
4
+ "version": "0.13.90",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -10,8 +10,8 @@
10
10
  "!__mocks__"
11
11
  ],
12
12
  "scripts": {
13
- "test": "NODE_OPTIONS=\"--stack-trace-limit=1000\" jest --config=test/jest.config.js",
14
- "lint": "eslint --config=.eslintrc ./",
13
+ "test": "NODE_OPTIONS=\"--stack-trace-limit=1000\" jest --config=jest.config.js",
14
+ "lint": "eslint ./",
15
15
  "dev": "coderich-dev"
16
16
  },
17
17
  "dependencies": {
@@ -77,7 +77,8 @@ module.exports = class Pipeline {
77
77
  const { fkField, linkTo, isPrimaryKey, generator } = params.field;
78
78
  const lookupField = isPrimaryKey ? params.field : fkField;
79
79
  const v = params.value?.[lookupField] || params.value;
80
- const $generator = isPrimaryKey ? generator : linkTo.fields[fkField].generator;
80
+ // const $generator = isPrimaryKey ? generator : linkTo.fields[fkField].generator;
81
+ const $generator = linkTo?.fields?.[fkField]?.generator || generator; // ???
81
82
  return Util.map(v, value => $generator({ ...params, value }));
82
83
  });
83
84
 
@@ -219,12 +219,13 @@ 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
- let input = suffix === 'One' ? args[0] : args;
222
+ const op = `${crud}${suffix}`;
223
+ let input = op === 'createMany' ? args : args[0];
223
224
  if (input === undefined) input = {};
224
225
  if (id !== undefined) input.id = id;
225
226
  this.#query.args.input = input;
226
227
  return this.terminate(Object.assign(this.#query, {
227
- op: `${crud}${suffix}`,
228
+ op,
228
229
  key: `${crud}${this.#query.model}`,
229
230
  crud: ['push', 'pull', 'splice'].includes(crud) ? 'update' : crud,
230
231
  input,
@@ -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[0]);
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[0]);
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
  });