@coderich/autograph 0.13.104 → 0.13.106

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.104",
4
+ "version": "0.13.106",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -18,14 +18,14 @@ class Emitter extends EventEmitter {
18
18
  return prev[isBasic ? 0 : 1].push(wrapper) && prev;
19
19
  }, [[], []]);
20
20
 
21
- // Basic functions are not designed to be bound to the query execution so we need an isolated resolver from any transactions
22
- const resolver = data?.resolver?.clone();
23
- const basicData = { ...data, resolver };
21
+ // // Basic functions are not designed to be bound to the query execution so we need an isolated resolver from any transactions
22
+ // const resolver = data?.resolver?.clone();
23
+ // const basicData = { ...data, resolver };
24
24
 
25
25
  return new Promise((resolve, reject) => {
26
26
  // Basic functions run first; if they return a value they abort the flow of execution
27
27
  basicFuncs.sort(Emitter.sort).forEach((fn) => {
28
- const value = fn(basicData);
28
+ const value = fn(data);
29
29
  if (value !== undefined && !(value instanceof Promise)) throw new AbortEarlyError(value);
30
30
  });
31
31
 
@@ -36,7 +36,7 @@ module.exports = class QueryResolver extends QueryBuilder {
36
36
  return this.#resolver.resolve(query);
37
37
  }
38
38
  case 'createMany': {
39
- return this.#resolver.transaction(false).run(Promise.all(input.map(el => this.#resolver.match(this.#model.name).save(el))));
39
+ return Promise.all(input.map(el => this.#resolver.match(this.#model.name).save(el)));
40
40
  }
41
41
  case 'updateOne': {
42
42
  return this.#get(query).then((doc) => {
@@ -46,7 +46,7 @@ module.exports = class QueryResolver extends QueryBuilder {
46
46
  }
47
47
  case 'updateMany': {
48
48
  return this.#find(query).then((docs) => {
49
- return this.#resolver.transaction(false).run(Promise.all(docs.map(doc => this.#resolver.match(this.#model.name).id(doc.id).save(input))));
49
+ return Promise.all(docs.map(doc => this.#resolver.match(this.#model.name).id(doc.id).save(input)));
50
50
  });
51
51
  }
52
52
  case 'pushOne': {
@@ -62,7 +62,7 @@ module.exports = class QueryResolver extends QueryBuilder {
62
62
  case 'pushMany': {
63
63
  const [[key, values]] = Object.entries(input);
64
64
  return this.#find(query).then((docs) => {
65
- return this.#resolver.transaction(false).run(Promise.all(docs.map(doc => this.#resolver.match(this.#model.name).id(doc.id).push(key, values))));
65
+ return Promise.all(docs.map(doc => this.#resolver.match(this.#model.name).id(doc.id).push(key, values)));
66
66
  });
67
67
  }
68
68
  case 'pullOne': {
@@ -81,7 +81,7 @@ module.exports = class QueryResolver extends QueryBuilder {
81
81
  case 'pullMany': {
82
82
  const [[key, values]] = Object.entries(input);
83
83
  return this.#find(query).then((docs) => {
84
- return this.#resolver.transaction(false).run(Promise.all(docs.map(doc => this.#resolver.match(this.#model.name).id(doc.id).pull(key, values))));
84
+ return Promise.all(docs.map(doc => this.#resolver.match(this.#model.name).id(doc.id).pull(key, values)));
85
85
  });
86
86
  }
87
87
  case 'spliceOne': {
@@ -103,7 +103,7 @@ module.exports = class QueryResolver extends QueryBuilder {
103
103
  }
104
104
  case 'deleteMany': {
105
105
  return this.#find(query).then((docs) => {
106
- return this.#resolver.transaction(false).run(Promise.all(docs.map(doc => this.#resolver.match(this.#model.name).id(doc.id).delete())));
106
+ return Promise.all(docs.map(doc => this.#resolver.match(this.#model.name).id(doc.id).delete()));
107
107
  });
108
108
  }
109
109
  default: {
@@ -121,9 +121,9 @@ module.exports = class QueryResolver extends QueryBuilder {
121
121
  }
122
122
 
123
123
  #resolveReferentialIntegrity(doc) {
124
- const txn = this.#resolver.transaction(false);
124
+ const txn = this.#resolver;
125
125
 
126
- return txn.run(Util.promiseChain(this.#model.referentialIntegrity.map(({ model, field, path }) => () => {
126
+ return Util.promiseChain(this.#model.referentialIntegrity.map(({ model, field, path }) => () => {
127
127
  const { onDelete, isArray, fkField } = field;
128
128
  const id = doc[fkField];
129
129
  const $path = path.join('.');
@@ -136,6 +136,6 @@ module.exports = class QueryResolver extends QueryBuilder {
136
136
  case 'defer': return Promise.resolve(); // Used for embedded models (could be improved)
137
137
  default: throw new Error(`Unknown onDelete operator: '${onDelete}'`);
138
138
  }
139
- })));
139
+ }));
140
140
  }
141
141
  };