@sprucelabs/data-stores 26.0.0 → 26.1.0

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.
@@ -25,6 +25,7 @@ export default abstract class AbstractStore<FullSchema extends Schema, CreateSch
25
25
  protected willScramble?(values: Partial<DatabaseRecord> & {
26
26
  _isScrambled: true;
27
27
  }): Promise<Partial<DatabaseRecord>>;
28
+ protected willQuery?(query: QueryBuilder<QueryRecord>): Promise<QueryBuilder<Partial<DatabaseRecord>>>;
28
29
  protected constructor(db: Database, collectionName?: string);
29
30
  protected setCollectionName(name: string): void;
30
31
  getDb(): Database;
@@ -197,8 +197,10 @@ export default class AbstractStore extends AbstractMutexer {
197
197
  });
198
198
  }
199
199
  find(query, queryOptions, options) {
200
+ var _a, _b;
200
201
  return __awaiter(this, void 0, void 0, function* () {
201
- const results = yield this.db.find(this.collectionName, query, Object.assign(Object.assign({}, queryOptions), { includeFields: options === null || options === void 0 ? void 0 : options.includeFields }));
202
+ const mappedQuery = (_b = (yield ((_a = this.willQuery) === null || _a === void 0 ? void 0 : _a.call(this, query)))) !== null && _b !== void 0 ? _b : query;
203
+ const results = yield this.db.find(this.collectionName, mappedQuery, Object.assign(Object.assign({}, queryOptions), { includeFields: options === null || options === void 0 ? void 0 : options.includeFields }));
202
204
  if (results) {
203
205
  const all = results.map((result) => this.prepareAndNormalizeRecord(result, Object.assign(Object.assign({}, options), { shouldStripUndefinedAndNullValues: true })));
204
206
  const records = yield Promise.all(all);
@@ -25,6 +25,7 @@ export default abstract class AbstractStore<FullSchema extends Schema, CreateSch
25
25
  protected willScramble?(values: Partial<DatabaseRecord> & {
26
26
  _isScrambled: true;
27
27
  }): Promise<Partial<DatabaseRecord>>;
28
+ protected willQuery?(query: QueryBuilder<QueryRecord>): Promise<QueryBuilder<Partial<DatabaseRecord>>>;
28
29
  protected constructor(db: Database, collectionName?: string);
29
30
  protected setCollectionName(name: string): void;
30
31
  getDb(): Database;
@@ -200,7 +200,9 @@ class AbstractStore extends AbstractMutexer_1.default {
200
200
  return count;
201
201
  }
202
202
  async find(query, queryOptions, options) {
203
- const results = await this.db.find(this.collectionName, query, Object.assign(Object.assign({}, queryOptions), { includeFields: options === null || options === void 0 ? void 0 : options.includeFields }));
203
+ var _a, _b;
204
+ const mappedQuery = (_b = (await ((_a = this.willQuery) === null || _a === void 0 ? void 0 : _a.call(this, query)))) !== null && _b !== void 0 ? _b : query;
205
+ const results = await this.db.find(this.collectionName, mappedQuery, Object.assign(Object.assign({}, queryOptions), { includeFields: options === null || options === void 0 ? void 0 : options.includeFields }));
204
206
  if (results) {
205
207
  const all = results.map((result) => this.prepareAndNormalizeRecord(result, Object.assign(Object.assign({}, options), { shouldStripUndefinedAndNullValues: true })));
206
208
  const records = await Promise.all(all);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "26.0.0",
6
+ "version": "26.1.0",
7
7
  "files": [
8
8
  "build/**/*",
9
9
  "!build/__tests__",
@@ -78,7 +78,7 @@
78
78
  "nedb": "^1.8.0"
79
79
  },
80
80
  "devDependencies": {
81
- "@sprucelabs/esm-postbuild": "^5.0.102",
81
+ "@sprucelabs/esm-postbuild": "^5.0.103",
82
82
  "@sprucelabs/jest-json-reporter": "^7.0.128",
83
83
  "@sprucelabs/jest-sheets-reporter": "^3.0.26",
84
84
  "@sprucelabs/resolve-path-aliases": "^1.1.266",
@@ -87,11 +87,11 @@
87
87
  "@sprucelabs/test-utils": "^4.0.81",
88
88
  "@types/lodash": "^4.14.202",
89
89
  "@types/nedb": "^1.8.16",
90
- "@types/node": "^20.10.0",
90
+ "@types/node": "^20.10.3",
91
91
  "chokidar-cli": "^3.0.0",
92
92
  "concurrently": "^8.2.2",
93
93
  "dotenv": "^16.3.1",
94
- "eslint": "^8.54.0",
94
+ "eslint": "^8.55.0",
95
95
  "eslint-config-spruce": "^10.13.6",
96
96
  "jest": "^29.7.0",
97
97
  "jest-circus": "^29.7.0",