rads-db 3.0.70 → 3.0.72

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/dist/index.cjs CHANGED
@@ -234,9 +234,9 @@ function getAggFromArray(array, args) {
234
234
  else if (operator === "avg")
235
235
  result[key] = values.length ? ___default.mean(values) : void 0;
236
236
  else if (operator === "max")
237
- result[key] = values.length ? ___default.max(array.map((x) => x[field])) : void 0;
237
+ result[key] = values.length ? ___default.max(values) : void 0;
238
238
  else if (operator === "sum")
239
- result[key] = values.length ? ___default.sum(array.map((x) => x[field])) : void 0;
239
+ result[key] = values.length ? ___default.sum(values) : void 0;
240
240
  else
241
241
  throw new Error(`Unknown operator: ${operator} (${key})`);
242
242
  }
@@ -955,8 +955,8 @@ function getRadsDbMethods(key, computedContext, driverInstance) {
955
955
  cleanUndefinedAndNull(doc);
956
956
  const docArgsToSave = [{ doc, oldDoc }];
957
957
  await handlePrecomputed(computedContext, docArgsToSave, ctx);
958
- const beforePutResults = await handleEffectsBeforePut(computedContext, docArgsToSave, ctx);
959
958
  await beforePut(docArgsToSave, ctx, computedContext);
959
+ const beforePutResults = await handleEffectsBeforePut(computedContext, docArgsToSave, ctx);
960
960
  const validatedDoc = validators[key](doc);
961
961
  docArgsToSave[0].doc = validatedDoc;
962
962
  if (precomputedFields) {
package/dist/index.mjs CHANGED
@@ -227,9 +227,9 @@ function getAggFromArray(array, args) {
227
227
  else if (operator === "avg")
228
228
  result[key] = values.length ? _.mean(values) : void 0;
229
229
  else if (operator === "max")
230
- result[key] = values.length ? _.max(array.map((x) => x[field])) : void 0;
230
+ result[key] = values.length ? _.max(values) : void 0;
231
231
  else if (operator === "sum")
232
- result[key] = values.length ? _.sum(array.map((x) => x[field])) : void 0;
232
+ result[key] = values.length ? _.sum(values) : void 0;
233
233
  else
234
234
  throw new Error(`Unknown operator: ${operator} (${key})`);
235
235
  }
@@ -948,8 +948,8 @@ function getRadsDbMethods(key, computedContext, driverInstance) {
948
948
  cleanUndefinedAndNull(doc);
949
949
  const docArgsToSave = [{ doc, oldDoc }];
950
950
  await handlePrecomputed(computedContext, docArgsToSave, ctx);
951
- const beforePutResults = await handleEffectsBeforePut(computedContext, docArgsToSave, ctx);
952
951
  await beforePut(docArgsToSave, ctx, computedContext);
952
+ const beforePutResults = await handleEffectsBeforePut(computedContext, docArgsToSave, ctx);
953
953
  const validatedDoc = validators[key](doc);
954
954
  docArgsToSave[0].doc = validatedDoc;
955
955
  if (precomputedFields) {
@@ -115,7 +115,7 @@ function getAggFromArray(array, args) {
115
115
  const [field, operator] = key.split("_");
116
116
  if (operator === "count") result[key] = array.length;else {
117
117
  const values = array.map(x => x[field]).filter(x => x != null);
118
- if (operator === "min") result[key] = values.length ? _lodash.default.min(values) : void 0;else if (operator === "avg") result[key] = values.length ? _lodash.default.mean(values) : void 0;else if (operator === "max") result[key] = values.length ? _lodash.default.max(array.map(x => x[field])) : void 0;else if (operator === "sum") result[key] = values.length ? _lodash.default.sum(array.map(x => x[field])) : void 0;else throw new Error(`Unknown operator: ${operator} (${key})`);
118
+ if (operator === "min") result[key] = values.length ? _lodash.default.min(values) : void 0;else if (operator === "avg") result[key] = values.length ? _lodash.default.mean(values) : void 0;else if (operator === "max") result[key] = values.length ? _lodash.default.max(values) : void 0;else if (operator === "sum") result[key] = values.length ? _lodash.default.sum(values) : void 0;else throw new Error(`Unknown operator: ${operator} (${key})`);
119
119
  }
120
120
  }
121
121
  return result;
@@ -101,9 +101,9 @@ export function getAggFromArray(array, args) {
101
101
  else if (operator === "avg")
102
102
  result[key] = values.length ? _.mean(values) : void 0;
103
103
  else if (operator === "max")
104
- result[key] = values.length ? _.max(array.map((x) => x[field])) : void 0;
104
+ result[key] = values.length ? _.max(values) : void 0;
105
105
  else if (operator === "sum")
106
- result[key] = values.length ? _.sum(array.map((x) => x[field])) : void 0;
106
+ result[key] = values.length ? _.sum(values) : void 0;
107
107
  else
108
108
  throw new Error(`Unknown operator: ${operator} (${key})`);
109
109
  }
@@ -279,5 +279,5 @@ function getStringHashCode(str) {
279
279
  hash = (hash << 5) - hash + chr;
280
280
  hash |= 0;
281
281
  }
282
- return hash;
282
+ return Math.abs(hash);
283
283
  }
@@ -308,5 +308,5 @@ function getStringHashCode(str) {
308
308
  hash = (hash << 5) - hash + chr;
309
309
  hash |= 0;
310
310
  }
311
- return hash;
311
+ return Math.abs(hash);
312
312
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rads-db",
3
- "version": "3.0.70",
3
+ "version": "3.0.72",
4
4
  "packageManager": "pnpm@8.6.1",
5
5
  "description": "Say goodbye to boilerplate code and hello to efficient and elegant syntax.",
6
6
  "author": "",