@naturalcycles/db-lib 10.60.0 → 10.62.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.
Files changed (45) hide show
  1. package/dist/adapter/cachedb/cache.db.d.ts +2 -2
  2. package/dist/adapter/file/file.db.d.ts +6 -6
  3. package/dist/adapter/file/file.db.js +2 -2
  4. package/dist/adapter/file/file.db.model.d.ts +1 -1
  5. package/dist/adapter/file/inMemory.persistence.plugin.d.ts +1 -1
  6. package/dist/adapter/file/localFile.persistence.plugin.d.ts +2 -2
  7. package/dist/adapter/file/noop.persistence.plugin.d.ts +1 -1
  8. package/dist/commondao/common.dao.d.ts +24 -18
  9. package/dist/commondao/common.dao.js +43 -28
  10. package/dist/commondao/commonDaoTransaction.d.ts +3 -3
  11. package/dist/commondb/base.common.db.d.ts +3 -3
  12. package/dist/commondb/common.db.d.ts +3 -3
  13. package/dist/db.model.d.ts +2 -2
  14. package/dist/inmemory/inMemory.db.d.ts +6 -6
  15. package/dist/inmemory/inMemoryKeyValueDB.d.ts +4 -4
  16. package/dist/inmemory/queryInMemory.js +1 -1
  17. package/dist/kv/commonKeyValueDB.d.ts +4 -4
  18. package/dist/kv/commonKeyValueDao.d.ts +5 -5
  19. package/dist/kv/commonKeyValueDaoMemoCache.d.ts +1 -0
  20. package/dist/kv/commonKeyValueDaoMemoCache.js +3 -0
  21. package/dist/query/dbQuery.d.ts +4 -4
  22. package/dist/query/dbQuery.js +2 -2
  23. package/dist/timeseries/commonTimeSeriesDao.d.ts +3 -3
  24. package/dist/transaction/dbTransaction.util.d.ts +3 -3
  25. package/package.json +1 -1
  26. package/src/adapter/cachedb/cache.db.ts +2 -2
  27. package/src/adapter/file/file.db.model.ts +1 -1
  28. package/src/adapter/file/file.db.ts +9 -7
  29. package/src/adapter/file/inMemory.persistence.plugin.ts +1 -1
  30. package/src/adapter/file/localFile.persistence.plugin.ts +2 -2
  31. package/src/adapter/file/noop.persistence.plugin.ts +1 -1
  32. package/src/commondao/common.dao.ts +73 -48
  33. package/src/commondao/commonDaoTransaction.ts +3 -3
  34. package/src/commondb/base.common.db.ts +10 -3
  35. package/src/commondb/common.db.ts +7 -3
  36. package/src/db.model.ts +2 -2
  37. package/src/inmemory/inMemory.db.ts +10 -6
  38. package/src/inmemory/inMemoryKeyValueDB.ts +7 -4
  39. package/src/inmemory/queryInMemory.ts +5 -5
  40. package/src/kv/commonKeyValueDB.ts +4 -4
  41. package/src/kv/commonKeyValueDao.ts +5 -5
  42. package/src/kv/commonKeyValueDaoMemoCache.ts +4 -0
  43. package/src/query/dbQuery.ts +6 -6
  44. package/src/timeseries/commonTimeSeriesDao.ts +3 -3
  45. package/src/transaction/dbTransaction.util.ts +3 -3
@@ -23,8 +23,8 @@ export declare class CacheDB extends BaseCommonDB implements CommonDB {
23
23
  getTables(): Promise<string[]>;
24
24
  getTableSchema<ROW extends ObjectWithId>(table: string): Promise<JsonSchema<ROW>>;
25
25
  createTable<ROW extends ObjectWithId>(table: string, schema: JsonSchema<ROW>, opt?: CacheDBCreateOptions): Promise<void>;
26
- getByIds<ROW extends ObjectWithId>(table: string, ids: string[], opt?: CacheDBSaveOptions<ROW>): Promise<ROW[]>;
27
- saveBatch<ROW extends ObjectWithId>(table: string, rows: ROW[], opt?: CacheDBSaveOptions<ROW>): Promise<void>;
26
+ getByIds<ROW extends ObjectWithId>(table: string, ids: readonly string[], opt?: CacheDBSaveOptions<ROW>): Promise<ROW[]>;
27
+ saveBatch<ROW extends ObjectWithId>(table: string, rows: readonly ROW[], opt?: CacheDBSaveOptions<ROW>): Promise<void>;
28
28
  runQuery<ROW extends ObjectWithId>(q: DBQuery<ROW>, opt?: CacheDBSaveOptions<ROW>): Promise<RunQueryResult<ROW>>;
29
29
  runQueryCount<ROW extends ObjectWithId>(q: DBQuery<ROW>, opt?: CacheDBOptions): Promise<number>;
30
30
  streamQuery<ROW extends ObjectWithId>(q: DBQuery<ROW>, opt?: CacheDBStreamOptions): Pipeline<ROW>;
@@ -22,18 +22,18 @@ export declare class FileDB extends BaseCommonDB implements CommonDB {
22
22
  cfg: FileDBCfg;
23
23
  ping(): Promise<void>;
24
24
  getTables(): Promise<string[]>;
25
- getByIds<ROW extends ObjectWithId>(table: string, ids: string[], _opt?: CommonDBOptions): Promise<ROW[]>;
26
- saveBatch<ROW extends ObjectWithId>(table: string, rows: ROW[], _opt?: CommonDBSaveOptions<ROW>): Promise<void>;
25
+ getByIds<ROW extends ObjectWithId>(table: string, ids: readonly string[], _opt?: CommonDBOptions): Promise<ROW[]>;
26
+ saveBatch<ROW extends ObjectWithId>(table: string, rows: readonly ROW[], _opt?: CommonDBSaveOptions<ROW>): Promise<void>;
27
27
  runQuery<ROW extends ObjectWithId>(q: DBQuery<ROW>, _opt?: CommonDBOptions): Promise<RunQueryResult<ROW>>;
28
28
  runQueryCount<ROW extends ObjectWithId>(q: DBQuery<ROW>, _opt?: CommonDBOptions): Promise<number>;
29
29
  streamQuery<ROW extends ObjectWithId>(q: DBQuery<ROW>, opt?: CommonDBStreamOptions): Pipeline<ROW>;
30
30
  deleteByQuery<ROW extends ObjectWithId>(q: DBQuery<ROW>, _opt?: CommonDBOptions): Promise<number>;
31
- deleteByIds(table: string, ids: string[], _opt?: CommonDBOptions): Promise<number>;
31
+ deleteByIds(table: string, ids: readonly string[], _opt?: CommonDBOptions): Promise<number>;
32
32
  getTableSchema<ROW extends ObjectWithId>(table: string): Promise<JsonSchema<ROW>>;
33
33
  loadFile<ROW extends ObjectWithId>(table: string): Promise<ROW[]>;
34
- saveFile<ROW extends ObjectWithId>(table: string, _rows: ROW[]): Promise<void>;
35
- saveFiles<ROW extends ObjectWithId>(ops: DBSaveBatchOperation<ROW>[]): Promise<void>;
36
- sortRows<ROW extends ObjectWithId>(rows: ROW[]): ROW[];
34
+ saveFile<ROW extends ObjectWithId>(table: string, _rows: readonly ROW[]): Promise<void>;
35
+ saveFiles<ROW extends ObjectWithId>(ops: readonly DBSaveBatchOperation<ROW>[]): Promise<void>;
36
+ sortRows<ROW extends ObjectWithId>(inputRows: readonly ROW[]): ROW[];
37
37
  private logStarted;
38
38
  private logFinished;
39
39
  }
@@ -151,8 +151,8 @@ export class FileDB extends BaseCommonDB {
151
151
  // override async createTransaction(): Promise<FileDBTransaction> {
152
152
  // return new FileDBTransaction(this)
153
153
  // }
154
- sortRows(rows) {
155
- rows = rows.map(r => _filterUndefinedValues(r));
154
+ sortRows(inputRows) {
155
+ const rows = inputRows.map(r => _filterUndefinedValues(r));
156
156
  if (this.cfg.sortOnSave) {
157
157
  _sortBy(rows, r => r[this.cfg.sortOnSave.name], { mutate: true });
158
158
  if (this.cfg.sortOnSave.descending)
@@ -6,7 +6,7 @@ export interface FileDBPersistencePlugin {
6
6
  ping: () => Promise<void>;
7
7
  getTables: () => Promise<string[]>;
8
8
  loadFile: <ROW extends ObjectWithId>(table: string) => Promise<ROW[]>;
9
- saveFiles: (ops: DBSaveBatchOperation<any>[]) => Promise<void>;
9
+ saveFiles: (ops: readonly DBSaveBatchOperation<any>[]) => Promise<void>;
10
10
  }
11
11
  export interface FileDBCfg {
12
12
  plugin: FileDBPersistencePlugin;
@@ -10,5 +10,5 @@ export declare class InMemoryPersistencePlugin implements FileDBPersistencePlugi
10
10
  clear(): void;
11
11
  getTables(): Promise<string[]>;
12
12
  loadFile<ROW extends ObjectWithId>(table: string): Promise<ROW[]>;
13
- saveFiles(ops: DBSaveBatchOperation<any>[]): Promise<void>;
13
+ saveFiles(ops: readonly DBSaveBatchOperation<any>[]): Promise<void>;
14
14
  }
@@ -20,6 +20,6 @@ export declare class LocalFilePersistencePlugin implements FileDBPersistencePlug
20
20
  ping(): Promise<void>;
21
21
  getTables(): Promise<string[]>;
22
22
  loadFile<ROW extends ObjectWithId>(table: string): Promise<ROW[]>;
23
- saveFiles(ops: DBSaveBatchOperation<any>[]): Promise<void>;
24
- saveFile<ROW extends ObjectWithId>(table: string, rows: ROW[]): Promise<void>;
23
+ saveFiles(ops: readonly DBSaveBatchOperation<any>[]): Promise<void>;
24
+ saveFile<ROW extends ObjectWithId>(table: string, rows: readonly ROW[]): Promise<void>;
25
25
  }
@@ -5,5 +5,5 @@ export declare class NoopPersistencePlugin implements FileDBPersistencePlugin {
5
5
  ping(): Promise<void>;
6
6
  getTables(): Promise<string[]>;
7
7
  loadFile<ROW extends ObjectWithId>(_table: string): Promise<ROW[]>;
8
- saveFiles(_ops: DBSaveBatchOperation<any>[]): Promise<void>;
8
+ saveFiles(_ops: readonly DBSaveBatchOperation<any>[]): Promise<void>;
9
9
  }
@@ -25,8 +25,8 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
25
25
  getByIdOrEmpty(id: ID, part?: Partial<BM>, opt?: CommonDaoReadOptions): Promise<BM>;
26
26
  getById(id?: ID | null, opt?: CommonDaoReadOptions): Promise<BM | null>;
27
27
  getByIdAsDBM(id?: ID | null, opt?: CommonDaoReadOptions): Promise<DBM | null>;
28
- getByIds(ids: ID[], opt?: CommonDaoReadOptions): Promise<BM[]>;
29
- getByIdsAsDBM(ids: ID[], opt?: CommonDaoReadOptions): Promise<DBM[]>;
28
+ getByIds(ids: readonly ID[], opt?: CommonDaoReadOptions): Promise<BM[]>;
29
+ getByIdsAsDBM(ids: readonly ID[], opt?: CommonDaoReadOptions): Promise<DBM[]>;
30
30
  private loadByIds;
31
31
  getBy(by: keyof DBM, value: any, limit?: number, opt?: CommonDaoReadOptions): Promise<BM[]>;
32
32
  getOneBy(by: keyof DBM, value: any, opt?: CommonDaoReadOptions): Promise<BM | null>;
@@ -42,7 +42,7 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
42
42
  * Does deduplication by id.
43
43
  * Order is not guaranteed, as queries run in parallel.
44
44
  */
45
- runUnionQueries(queries: DBQuery<DBM>[], opt?: CommonDaoReadOptions): Promise<BM[]>;
45
+ runUnionQueries(queries: readonly DBQuery<DBM>[], opt?: CommonDaoReadOptions): Promise<BM[]>;
46
46
  runQueryExtended(q: DBQuery<DBM>, opt?: CommonDaoReadOptions): Promise<RunQueryResult<BM>>;
47
47
  runQueryAsDBM(q: DBQuery<DBM>, opt?: CommonDaoReadOptions): Promise<DBM[]>;
48
48
  runQueryExtendedAsDBM(q: DBQuery<DBM>, opt?: CommonDaoReadOptions): Promise<RunQueryResult<DBM>>;
@@ -85,8 +85,8 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
85
85
  */
86
86
  save(bm: Unsaved<BM>, opt?: CommonDaoSaveOptions<BM, DBM>): Promise<BM>;
87
87
  saveAsDBM(dbm: Unsaved<DBM>, opt?: CommonDaoSaveOptions<BM, DBM>): Promise<DBM>;
88
- saveBatch(bms: Unsaved<BM>[], opt?: CommonDaoSaveBatchOptions<DBM>): Promise<BM[]>;
89
- saveBatchAsDBM(dbms: Unsaved<DBM>[], opt?: CommonDaoSaveBatchOptions<DBM>): Promise<DBM[]>;
88
+ saveBatch(bms: readonly Unsaved<BM>[], opt?: CommonDaoSaveBatchOptions<DBM>): Promise<BM[]>;
89
+ saveBatchAsDBM(dbms: readonly Unsaved<DBM>[], opt?: CommonDaoSaveBatchOptions<DBM>): Promise<DBM[]>;
90
90
  private prepareSaveOptions;
91
91
  /**
92
92
  * "Streaming" is implemented by buffering incoming rows into **batches**
@@ -102,14 +102,14 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
102
102
  * @returns number of deleted items
103
103
  */
104
104
  deleteById(id?: ID | null, opt?: CommonDaoOptions): Promise<number>;
105
- deleteByIds(ids: ID[], opt?: CommonDaoOptions): Promise<number>;
105
+ deleteByIds(ids: readonly ID[], opt?: CommonDaoOptions): Promise<number>;
106
106
  /**
107
107
  * Pass `chunkSize: number` (e.g 500) option to use Streaming: it will Stream the query, chunk by 500, and execute
108
108
  * `deleteByIds` for each chunk concurrently (infinite concurrency).
109
109
  * This is expected to be more memory-efficient way of deleting large number of rows.
110
110
  */
111
111
  deleteByQuery(q: DBQuery<DBM>, opt?: CommonDaoStreamDeleteOptions<DBM>): Promise<number>;
112
- patchByIds(ids: ID[], patch: Partial<DBM>, opt?: CommonDaoOptions): Promise<number>;
112
+ patchByIds(ids: readonly ID[], patch: Partial<DBM>, opt?: CommonDaoOptions): Promise<number>;
113
113
  patchByQuery(q: DBQuery<DBM>, patch: Partial<DBM>, opt?: CommonDaoOptions): Promise<number>;
114
114
  /**
115
115
  * Caveat: it doesn't update created/updated props.
@@ -125,14 +125,14 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
125
125
  incrementBatch(prop: keyof DBM, incrementMap: StringMap<number>, opt?: CommonDaoOptions): Promise<StringMap<number>>;
126
126
  dbmToBM(_dbm: undefined, opt?: CommonDaoOptions): null;
127
127
  dbmToBM(_dbm?: DBM, opt?: CommonDaoOptions): BM;
128
- dbmsToBM(dbms: DBM[], opt?: CommonDaoOptions): BM[];
128
+ dbmsToBM(dbms: readonly DBM[], opt?: CommonDaoOptions): BM[];
129
129
  /**
130
130
  * Mutates object with properties: id, created, updated.
131
131
  * Returns DBM (new reference).
132
132
  */
133
133
  bmToDBM(bm: undefined, opt?: CommonDaoOptions): null;
134
134
  bmToDBM(bm?: BM, opt?: CommonDaoOptions): DBM;
135
- bmsToDBM(bms: BM[], opt?: CommonDaoOptions): DBM[];
135
+ bmsToDBM(bms: readonly BM[], opt?: CommonDaoOptions): DBM[];
136
136
  /**
137
137
  * Converts a DBM to storage format, applying compression if configured.
138
138
  *
@@ -147,7 +147,7 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
147
147
  /**
148
148
  * Converts multiple DBMs to storage rows.
149
149
  */
150
- dbmsToStorageRows(dbms: DBM[]): Promise<ObjectWithId[]>;
150
+ dbmsToStorageRows(dbms: readonly DBM[]): Promise<readonly ObjectWithId[]>;
151
151
  /**
152
152
  * Converts a storage row back to a DBM, applying decompression if needed.
153
153
  *
@@ -161,7 +161,7 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
161
161
  /**
162
162
  * Converts multiple storage rows to DBMs.
163
163
  */
164
- storageRowsToDBM(rows: ObjectWithId[]): DBM[];
164
+ storageRowsToDBM(rows: readonly ObjectWithId[]): DBM[];
165
165
  /**
166
166
  * Mutates `dbm`.
167
167
  */
@@ -173,7 +173,7 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
173
173
  private assertNotCompressed;
174
174
  anyToDBM(dbm: undefined, opt?: CommonDaoOptions): null;
175
175
  anyToDBM(dbm?: any, opt?: CommonDaoOptions): DBM;
176
- anyToDBMs(rows: DBM[], opt?: CommonDaoOptions): DBM[];
176
+ anyToDBMs(rows: readonly DBM[], opt?: CommonDaoOptions): DBM[];
177
177
  /**
178
178
  * Returns *converted value* (NOT the same reference).
179
179
  * Does NOT mutate the object.
@@ -187,8 +187,8 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
187
187
  */
188
188
  ping(): Promise<void>;
189
189
  withId(id: ID): DaoWithId<CommonDao<BM, DBM, ID>>;
190
- withIds(ids: ID[]): DaoWithIds<CommonDao<BM, DBM, ID>>;
191
- withRowsToSave(rows: Unsaved<BM>[]): DaoWithRows<CommonDao<BM, DBM, ID>>;
190
+ withIds(ids: readonly ID[]): DaoWithIds<CommonDao<BM, DBM, ID>>;
191
+ withRowsToSave(rows: readonly Unsaved<BM>[]): DaoWithRows<CommonDao<BM, DBM, ID>>;
192
192
  withRowToSave(row: Unsaved<BM>, opt?: DaoWithRowOptions<BM>): DaoWithRow<CommonDao<BM, DBM, ID>>;
193
193
  /**
194
194
  * Load rows (by their ids) from Multiple tables at once.
@@ -205,8 +205,8 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
205
205
  /**
206
206
  * @experimental
207
207
  */
208
- static multiDelete(inputs: (DaoWithId<AnyDao> | DaoWithIds<AnyDao>)[], opt?: CommonDaoOptions): Promise<NonNegativeInteger>;
209
- static multiSave(inputs: (DaoWithRows<AnyDao> | DaoWithRow<AnyDao>)[], opt?: CommonDaoSaveBatchOptions<any>): Promise<void>;
208
+ static multiDelete(inputs: readonly (DaoWithId<AnyDao> | DaoWithIds<AnyDao>)[], opt?: CommonDaoOptions): Promise<NonNegativeInteger>;
209
+ static multiSave(inputs: readonly (DaoWithRows<AnyDao> | DaoWithRow<AnyDao>)[], opt?: CommonDaoSaveBatchOptions<any>): Promise<void>;
210
210
  createTransaction(opt?: CommonDBTransactionOptions): Promise<CommonDaoTransaction>;
211
211
  runInTransaction<T = void>(fn: CommonDaoTransactionFn<T>, opt?: CommonDBTransactionOptions): Promise<T>;
212
212
  private ensureRequired;
@@ -218,6 +218,12 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
218
218
  * Throws if readOnly is true
219
219
  */
220
220
  private requireObjectMutability;
221
+ /**
222
+ * Validates the query (throws if it uses `excludeFromIndexes` or compressed properties),
223
+ * and applies `opt.table` override (if any).
224
+ * The table override is applied on a clone, to not mutate the input query.
225
+ */
226
+ private prepareQuery;
221
227
  private validateQuery;
222
228
  private validateQueryCompression;
223
229
  /**
@@ -233,7 +239,7 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
233
239
  export type CommonDaoTransactionFn<T = void> = (tx: CommonDaoTransaction) => Promise<T>;
234
240
  export interface DaoWithIds<DAO extends AnyDao> {
235
241
  dao: DAO;
236
- ids: string[];
242
+ ids: readonly string[];
237
243
  }
238
244
  export interface DaoWithId<DAO extends AnyDao> {
239
245
  dao: DAO;
@@ -241,7 +247,7 @@ export interface DaoWithId<DAO extends AnyDao> {
241
247
  }
242
248
  export interface DaoWithRows<DAO extends AnyDao, BM = InferBM<DAO>> {
243
249
  dao: DAO;
244
- rows: Unsaved<BM>[];
250
+ rows: readonly Unsaved<BM>[];
245
251
  }
246
252
  export interface DaoWithRow<DAO extends AnyDao, BM = InferBM<DAO>> {
247
253
  dao: DAO;
@@ -146,8 +146,7 @@ export class CommonDao {
146
146
  return _uniqBy(results, r => r.id);
147
147
  }
148
148
  async runQueryExtended(q, opt = {}) {
149
- this.validateQuery(q); // throws if query uses `excludeFromIndexes` property
150
- q.table = opt.table || q.table;
149
+ q = this.prepareQuery(q, opt); // throws if query uses `excludeFromIndexes` property
151
150
  const { rows: rawRows, ...queryResult } = await this.cfg.db.runQuery(q, opt);
152
151
  const isPartialQuery = !!q._selectedFieldNames;
153
152
  const rows = isPartialQuery ? rawRows : this.storageRowsToDBM(rawRows);
@@ -162,8 +161,7 @@ export class CommonDao {
162
161
  return rows;
163
162
  }
164
163
  async runQueryExtendedAsDBM(q, opt = {}) {
165
- this.validateQuery(q); // throws if query uses `excludeFromIndexes` property
166
- q.table = opt.table || q.table;
164
+ q = this.prepareQuery(q, opt); // throws if query uses `excludeFromIndexes` property
167
165
  const { rows: rawRows, ...queryResult } = await this.cfg.db.runQuery(q, opt);
168
166
  const isPartialQuery = !!q._selectedFieldNames;
169
167
  const rows = isPartialQuery ? rawRows : this.storageRowsToDBM(rawRows);
@@ -171,13 +169,11 @@ export class CommonDao {
171
169
  return { rows: dbms, ...queryResult };
172
170
  }
173
171
  async runQueryCount(q, opt = {}) {
174
- this.validateQuery(q); // throws if query uses `excludeFromIndexes` property
175
- q.table = opt.table || q.table;
172
+ q = this.prepareQuery(q, opt); // throws if query uses `excludeFromIndexes` property
176
173
  return await this.cfg.db.runQueryCount(q, opt);
177
174
  }
178
175
  streamQueryAsDBM(q, opt = {}) {
179
- this.validateQuery(q); // throws if query uses `excludeFromIndexes` property
180
- q.table = opt.table || q.table;
176
+ q = this.prepareQuery(q, opt); // throws if query uses `excludeFromIndexes` property
181
177
  let pipeline = this.cfg.db.streamQuery(q, opt);
182
178
  if (this.cfg.compress?.keys.length) {
183
179
  pipeline = pipeline.mapSync(row => this.storageRowToDBM(row));
@@ -185,13 +181,15 @@ export class CommonDao {
185
181
  const isPartialQuery = !!q._selectedFieldNames;
186
182
  if (isPartialQuery)
187
183
  return pipeline;
188
- opt.skipValidation ??= true;
189
- opt.errorMode ||= ErrorMode.SUPPRESS;
184
+ opt = {
185
+ ...opt,
186
+ skipValidation: opt.skipValidation ?? true,
187
+ errorMode: opt.errorMode || ErrorMode.SUPPRESS,
188
+ };
190
189
  return pipeline.mapSync(dbm => this.anyToDBM(dbm, opt), { errorMode: opt.errorMode });
191
190
  }
192
191
  streamQuery(q, opt = {}) {
193
- this.validateQuery(q); // throws if query uses `excludeFromIndexes` property
194
- q.table = opt.table || q.table;
192
+ q = this.prepareQuery(q, opt); // throws if query uses `excludeFromIndexes` property
195
193
  let pipeline = this.cfg.db.streamQuery(q, opt);
196
194
  if (this.cfg.compress?.keys.length) {
197
195
  pipeline = pipeline.mapSync(row => this.storageRowToDBM(row));
@@ -199,21 +197,24 @@ export class CommonDao {
199
197
  const isPartialQuery = !!q._selectedFieldNames;
200
198
  if (isPartialQuery)
201
199
  return pipeline;
202
- opt.skipValidation ??= true;
203
- opt.errorMode ||= ErrorMode.SUPPRESS;
200
+ opt = {
201
+ ...opt,
202
+ skipValidation: opt.skipValidation ?? true,
203
+ errorMode: opt.errorMode || ErrorMode.SUPPRESS,
204
+ };
204
205
  return pipeline.mapSync(dbm => this.dbmToBM(dbm, opt), { errorMode: opt.errorMode });
205
206
  }
206
207
  async queryIds(q, opt = {}) {
207
- this.validateQuery(q); // throws if query uses `excludeFromIndexes` property
208
- q.table = opt.table || q.table;
209
- const { rows } = await this.cfg.db.runQuery(q.select(['id']), opt);
208
+ q = this.prepareQuery(q, opt); // throws if query uses `excludeFromIndexes` property
209
+ const { rows } = await this.cfg.db.runQuery(q.clone().select(['id']), opt);
210
210
  return rows.map(r => r.id);
211
211
  }
212
212
  streamQueryIds(q, opt = {}) {
213
- this.validateQuery(q); // throws if query uses `excludeFromIndexes` property
214
- q.table = opt.table || q.table;
215
- opt.errorMode ||= ErrorMode.SUPPRESS;
216
- return this.cfg.db.streamQuery(q.select(['id']), opt).mapSync((r) => r.id);
213
+ q = this.prepareQuery(q, opt); // throws if query uses `excludeFromIndexes` property
214
+ opt = { ...opt, errorMode: opt.errorMode || ErrorMode.SUPPRESS };
215
+ return this.cfg.db
216
+ .streamQuery(q.clone().select(['id']), opt)
217
+ .mapSync((r) => r.id);
217
218
  }
218
219
  /**
219
220
  * Mutates!
@@ -443,8 +444,11 @@ export class CommonDao {
443
444
  async streamSave(p, opt = {}) {
444
445
  this.requireWriteAccess();
445
446
  const table = opt.table || this.cfg.table;
446
- opt.skipValidation ??= true;
447
- opt.errorMode ||= ErrorMode.SUPPRESS;
447
+ opt = {
448
+ ...opt,
449
+ skipValidation: opt.skipValidation ?? true,
450
+ errorMode: opt.errorMode || ErrorMode.SUPPRESS,
451
+ };
448
452
  const saveOptions = this.prepareSaveOptions(opt);
449
453
  const { beforeSave } = this.cfg.hooks;
450
454
  const { chunkSize = 500, chunkConcurrency = 32, errorMode } = opt;
@@ -492,15 +496,14 @@ export class CommonDao {
492
496
  * This is expected to be more memory-efficient way of deleting large number of rows.
493
497
  */
494
498
  async deleteByQuery(q, opt = {}) {
495
- this.validateQuery(q); // throws if query uses `excludeFromIndexes` property
499
+ q = this.prepareQuery(q, opt); // throws if query uses `excludeFromIndexes` property
496
500
  this.requireWriteAccess();
497
501
  this.requireObjectMutability(opt);
498
- q.table = opt.table || q.table;
499
502
  let deleted = 0;
500
503
  if (opt.chunkSize) {
501
504
  const { chunkSize, chunkConcurrency = 8 } = opt;
502
505
  await this.cfg.db
503
- .streamQuery(q.select(['id']), opt)
506
+ .streamQuery(q.clone().select(['id']), opt)
504
507
  .mapSync(r => r.id)
505
508
  .chunk(chunkSize)
506
509
  .map(async (ids) => {
@@ -532,11 +535,10 @@ export class CommonDao {
532
535
  return await this.patchByQuery(this.query().filterIn('id', ids), patch, opt);
533
536
  }
534
537
  async patchByQuery(q, patch, opt = {}) {
535
- this.validateQuery(q); // throws if query uses `excludeFromIndexes` property
538
+ q = this.prepareQuery(q, opt); // throws if query uses `excludeFromIndexes` property
536
539
  this.assertNotCompressed(Object.keys(patch), 'patchByQuery');
537
540
  this.requireWriteAccess();
538
541
  this.requireObjectMutability(opt);
539
- q.table = opt.table || q.table;
540
542
  return await this.cfg.db.patchByQuery(q, patch, opt);
541
543
  }
542
544
  /**
@@ -961,6 +963,19 @@ export class CommonDao {
961
963
  table: this.cfg.table,
962
964
  });
963
965
  }
966
+ /**
967
+ * Validates the query (throws if it uses `excludeFromIndexes` or compressed properties),
968
+ * and applies `opt.table` override (if any).
969
+ * The table override is applied on a clone, to not mutate the input query.
970
+ */
971
+ prepareQuery(q, opt) {
972
+ this.validateQuery(q);
973
+ if (!opt.table || opt.table === q.table)
974
+ return q;
975
+ const q2 = q.clone();
976
+ q2.table = opt.table;
977
+ return q2;
978
+ }
964
979
  validateQuery(q) {
965
980
  this.validateQueryIndexes(q);
966
981
  this.validateQueryCompression(q);
@@ -22,9 +22,9 @@ export declare class CommonDaoTransaction {
22
22
  */
23
23
  rollback(): Promise<void>;
24
24
  getById<BM extends BaseDBEntity, DBM extends BaseDBEntity, ID extends string = BM['id']>(dao: CommonDao<BM, DBM, ID>, id?: ID | null, opt?: CommonDaoReadOptions): Promise<BM | null>;
25
- getByIds<BM extends BaseDBEntity, DBM extends BaseDBEntity, ID extends string = BM['id']>(dao: CommonDao<BM, DBM, ID>, ids: ID[], opt?: CommonDaoReadOptions): Promise<BM[]>;
25
+ getByIds<BM extends BaseDBEntity, DBM extends BaseDBEntity, ID extends string = BM['id']>(dao: CommonDao<BM, DBM, ID>, ids: readonly ID[], opt?: CommonDaoReadOptions): Promise<BM[]>;
26
26
  save<BM extends BaseDBEntity, DBM extends BaseDBEntity>(dao: CommonDao<BM, DBM>, bm: Unsaved<BM>, opt?: CommonDaoSaveOptions<BM, DBM>): Promise<BM>;
27
- saveBatch<BM extends BaseDBEntity, DBM extends BaseDBEntity>(dao: CommonDao<BM, DBM>, bms: Unsaved<BM>[], opt?: CommonDaoSaveBatchOptions<DBM>): Promise<BM[]>;
27
+ saveBatch<BM extends BaseDBEntity, DBM extends BaseDBEntity>(dao: CommonDao<BM, DBM>, bms: readonly Unsaved<BM>[], opt?: CommonDaoSaveBatchOptions<DBM>): Promise<BM[]>;
28
28
  /**
29
29
  * DaoTransaction.patch does not load from DB.
30
30
  * It assumes the bm was previously loaded in the same Transaction, hence could not be
@@ -34,5 +34,5 @@ export declare class CommonDaoTransaction {
34
34
  */
35
35
  patch<BM extends BaseDBEntity, DBM extends BaseDBEntity, ID extends string = BM['id']>(dao: CommonDao<BM, DBM, ID>, bm: BM, patch: Partial<BM>, opt?: CommonDaoSaveOptions<BM, DBM>): Promise<BM>;
36
36
  deleteById<DAO extends AnyDao>(dao: DAO, id?: InferID<DAO> | null, opt?: CommonDaoOptions): Promise<number>;
37
- deleteByIds<DAO extends AnyDao>(dao: DAO, ids: InferID<DAO>[], opt?: CommonDaoOptions): Promise<number>;
37
+ deleteByIds<DAO extends AnyDao>(dao: DAO, ids: readonly InferID<DAO>[], opt?: CommonDaoOptions): Promise<number>;
38
38
  }
@@ -16,15 +16,15 @@ export declare class BaseCommonDB implements CommonDB {
16
16
  getTables(): Promise<string[]>;
17
17
  getTableSchema<ROW extends ObjectWithId>(_table: string): Promise<JsonSchema<ROW>>;
18
18
  createTable<ROW extends ObjectWithId>(_table: string, _schema: JsonSchema<ROW>): Promise<void>;
19
- getByIds<ROW extends ObjectWithId>(_table: string, _ids: string[]): Promise<ROW[]>;
19
+ getByIds<ROW extends ObjectWithId>(_table: string, _ids: readonly string[]): Promise<ROW[]>;
20
20
  deleteByQuery<ROW extends ObjectWithId>(_q: DBQuery<ROW>): Promise<number>;
21
21
  patchByQuery<ROW extends ObjectWithId>(_q: DBQuery<ROW>, _patch: Partial<ROW>, _opt?: CommonDBOptions): Promise<number>;
22
22
  patchById<ROW extends ObjectWithId>(_table: string, _id: string, _patch: Partial<ROW>, _opt?: CommonDBOptions): Promise<void>;
23
23
  runQuery<ROW extends ObjectWithId>(_q: DBQuery<ROW>): Promise<RunQueryResult<ROW>>;
24
24
  runQueryCount<ROW extends ObjectWithId>(_q: DBQuery<ROW>): Promise<number>;
25
- saveBatch<ROW extends ObjectWithId>(_table: string, _rows: ROW[], _opt?: CommonDBSaveOptions<ROW>): Promise<void>;
25
+ saveBatch<ROW extends ObjectWithId>(_table: string, _rows: readonly ROW[], _opt?: CommonDBSaveOptions<ROW>): Promise<void>;
26
26
  streamQuery<ROW extends ObjectWithId>(_q: DBQuery<ROW>): Pipeline<ROW>;
27
- deleteByIds(_table: string, _ids: string[], _opt?: CommonDBOptions): Promise<number>;
27
+ deleteByIds(_table: string, _ids: readonly string[], _opt?: CommonDBOptions): Promise<number>;
28
28
  runInTransaction(fn: DBTransactionFn, _opt?: CommonDBTransactionOptions): Promise<void>;
29
29
  createTransaction(_opt?: CommonDBTransactionOptions): Promise<DBTransaction>;
30
30
  incrementBatch(_table: string, _prop: string, _incrementMap: StringMap<number>, _opt?: CommonDBOptions): Promise<StringMap<number>>;
@@ -39,7 +39,7 @@ export interface CommonDB {
39
39
  * Order of items returned is not guaranteed to match order of ids.
40
40
  * (Such limitation exists because Datastore doesn't support it).
41
41
  */
42
- getByIds: <ROW extends ObjectWithId>(table: string, ids: string[], opt?: CommonDBReadOptions) => Promise<ROW[]>;
42
+ getByIds: <ROW extends ObjectWithId>(table: string, ids: readonly string[], opt?: CommonDBReadOptions) => Promise<ROW[]>;
43
43
  /**
44
44
  * Get rows from multiple tables at once.
45
45
  * Mimics the API of some NoSQL databases like Firestore.
@@ -66,7 +66,7 @@ export interface CommonDB {
66
66
  /**
67
67
  * rows can have missing ids only if DB supports auto-generating them (like mysql auto_increment).
68
68
  */
69
- saveBatch: <ROW extends ObjectWithId>(table: string, rows: ROW[], opt?: CommonDBSaveOptions<ROW>) => Promise<void>;
69
+ saveBatch: <ROW extends ObjectWithId>(table: string, rows: readonly ROW[], opt?: CommonDBSaveOptions<ROW>) => Promise<void>;
70
70
  /**
71
71
  * Save rows for multiple tables at once.
72
72
  * Mimics the API of some NoSQL databases like Firestore.
@@ -95,7 +95,7 @@ export interface CommonDB {
95
95
  * Returns number of deleted items.
96
96
  * Not supported by all implementations (e.g Datastore will always return same number as number of ids).
97
97
  */
98
- deleteByIds: (table: string, ids: string[], opt?: CommonDBOptions) => Promise<NonNegativeInteger>;
98
+ deleteByIds: (table: string, ids: readonly string[], opt?: CommonDBOptions) => Promise<NonNegativeInteger>;
99
99
  /**
100
100
  * Deletes rows from multiple tables at once.
101
101
  * Mimics the API of some NoSQL databases like Firestore.
@@ -91,13 +91,13 @@ export type DBOperation = DBSaveBatchOperation<any> | DBDeleteByIdsOperation;
91
91
  export interface DBSaveBatchOperation<ROW extends ObjectWithId> {
92
92
  type: 'saveBatch';
93
93
  table: string;
94
- rows: ROW[];
94
+ rows: readonly ROW[];
95
95
  opt?: CommonDBSaveOptions<ROW>;
96
96
  }
97
97
  export interface DBDeleteByIdsOperation {
98
98
  type: 'deleteByIds';
99
99
  table: string;
100
- ids: string[];
100
+ ids: readonly string[];
101
101
  opt?: CommonDBOptions;
102
102
  }
103
103
  export declare enum DBRelation {
@@ -50,13 +50,13 @@ export declare class InMemoryDB implements CommonDB {
50
50
  getTables(): Promise<string[]>;
51
51
  getTableSchema<ROW extends ObjectWithId>(_table: string): Promise<JsonSchema<ROW>>;
52
52
  createTable<ROW extends ObjectWithId>(_table: string, _schema: JsonSchema<ROW>, opt?: CommonDBCreateOptions): Promise<void>;
53
- getByIds<ROW extends ObjectWithId>(_table: string, ids: string[], _opt?: CommonDBOptions): Promise<ROW[]>;
53
+ getByIds<ROW extends ObjectWithId>(_table: string, ids: readonly string[], _opt?: CommonDBOptions): Promise<ROW[]>;
54
54
  multiGet<ROW extends ObjectWithId>(map: StringMap<string[]>, _opt?: CommonDBOptions): Promise<StringMap<ROW[]>>;
55
- saveBatch<ROW extends ObjectWithId>(_table: string, rows: ROW[], opt?: CommonDBSaveOptions<ROW>): Promise<void>;
55
+ saveBatch<ROW extends ObjectWithId>(_table: string, rows: readonly ROW[], opt?: CommonDBSaveOptions<ROW>): Promise<void>;
56
56
  multiSave<ROW extends ObjectWithId>(map: StringMap<ROW[]>, opt?: CommonDBSaveOptions<ROW>): Promise<void>;
57
57
  patchById<ROW extends ObjectWithId>(_table: string, id: string, patch: Partial<ROW>, _opt?: CommonDBOptions): Promise<void>;
58
58
  deleteByQuery<ROW extends ObjectWithId>(q: DBQuery<ROW>, _opt?: CommonDBOptions): Promise<number>;
59
- deleteByIds(_table: string, ids: string[], _opt?: CommonDBOptions): Promise<number>;
59
+ deleteByIds(_table: string, ids: readonly string[], _opt?: CommonDBOptions): Promise<number>;
60
60
  multiDelete(map: StringMap<string[]>, _opt?: CommonDBOptions): Promise<number>;
61
61
  patchByQuery<ROW extends ObjectWithId>(q: DBQuery<ROW>, patch: Partial<ROW>): Promise<number>;
62
62
  runQuery<ROW extends ObjectWithId>(q: DBQuery<ROW>, _opt?: CommonDBOptions): Promise<RunQueryResult<ROW>>;
@@ -72,9 +72,9 @@ export declare class InMemoryDBTransaction implements DBTransaction {
72
72
  constructor(db: InMemoryDB, opt: Required<CommonDBTransactionOptions>);
73
73
  ops: DBOperation[];
74
74
  writeOperationHappened: boolean;
75
- getByIds<ROW extends ObjectWithId>(table: string, ids: string[], opt?: CommonDBOptions): Promise<ROW[]>;
76
- saveBatch<ROW extends ObjectWithId>(table: string, rows: ROW[], opt?: CommonDBSaveOptions<ROW>): Promise<void>;
77
- deleteByIds(table: string, ids: string[], opt?: CommonDBOptions): Promise<number>;
75
+ getByIds<ROW extends ObjectWithId>(table: string, ids: readonly string[], opt?: CommonDBOptions): Promise<ROW[]>;
76
+ saveBatch<ROW extends ObjectWithId>(table: string, rows: readonly ROW[], opt?: CommonDBSaveOptions<ROW>): Promise<void>;
77
+ deleteByIds(table: string, ids: readonly string[], opt?: CommonDBOptions): Promise<number>;
78
78
  commit(): Promise<void>;
79
79
  rollback(): Promise<void>;
80
80
  }
@@ -15,12 +15,12 @@ export declare class InMemoryKeyValueDB implements CommonKeyValueDB {
15
15
  ping(): Promise<void>;
16
16
  clear(): void;
17
17
  createTable(_table: string, _opt?: CommonDBCreateOptions): Promise<void>;
18
- deleteByIds(table: string, ids: string[]): Promise<void>;
19
- getByIds(table: string, ids: string[]): Promise<KeyValueDBTuple[]>;
20
- saveBatch(table: string, entries: KeyValueDBTuple[]): Promise<void>;
18
+ deleteByIds(table: string, ids: readonly string[]): Promise<void>;
19
+ getByIds(table: string, ids: readonly string[]): Promise<KeyValueDBTuple[]>;
20
+ saveBatch(table: string, entries: readonly KeyValueDBTuple[]): Promise<void>;
21
21
  streamIds(table: string, limit?: number): Pipeline<string>;
22
22
  streamValues(table: string, limit?: number): Pipeline<Buffer>;
23
23
  streamEntries(table: string, limit?: number): Pipeline<KeyValueDBTuple>;
24
24
  count(table: string): Promise<number>;
25
- incrementBatch(table: string, entries: IncrementTuple[]): Promise<IncrementTuple[]>;
25
+ incrementBatch(table: string, entries: readonly IncrementTuple[]): Promise<IncrementTuple[]>;
26
26
  }
@@ -31,7 +31,7 @@ export function queryInMemory(q, rows = []) {
31
31
  const [order] = q._orders;
32
32
  if (order) {
33
33
  const { name, descending } = order;
34
- rows = rows.sort(comparators.by(r => r[name], { dir: descending ? 'desc' : 'asc' }));
34
+ rows = rows.toSorted(comparators.by(r => r[name], { dir: descending ? 'desc' : 'asc' }));
35
35
  }
36
36
  // .offset()
37
37
  if (q._offsetValue) {
@@ -25,9 +25,9 @@ export interface CommonKeyValueDB {
25
25
  *
26
26
  * Currently it is NOT required to maintain the same order as input `ids`.
27
27
  */
28
- getByIds: (table: string, ids: string[]) => Promise<KeyValueDBTuple[]>;
29
- deleteByIds: (table: string, ids: string[]) => Promise<void>;
30
- saveBatch: (table: string, entries: KeyValueDBTuple[], opt?: CommonKeyValueDBSaveBatchOptions) => Promise<void>;
28
+ getByIds: (table: string, ids: readonly string[]) => Promise<KeyValueDBTuple[]>;
29
+ deleteByIds: (table: string, ids: readonly string[]) => Promise<void>;
30
+ saveBatch: (table: string, entries: readonly KeyValueDBTuple[], opt?: CommonKeyValueDBSaveBatchOptions) => Promise<void>;
31
31
  streamIds: (table: string, limit?: number) => Pipeline<string>;
32
32
  streamValues: (table: string, limit?: number) => Pipeline<Buffer>;
33
33
  streamEntries: (table: string, limit?: number) => Pipeline<KeyValueDBTuple>;
@@ -47,7 +47,7 @@ export interface CommonKeyValueDB {
47
47
  *
48
48
  * @experimental
49
49
  */
50
- incrementBatch: (table: string, entries: IncrementTuple[]) => Promise<IncrementTuple[]>;
50
+ incrementBatch: (table: string, entries: readonly IncrementTuple[]) => Promise<IncrementTuple[]>;
51
51
  }
52
52
  export type KeyValueDBTuple = [key: string, value: Buffer];
53
53
  export type IncrementTuple = [key: string, value: Integer];
@@ -56,11 +56,11 @@ export declare class CommonKeyValueDao<K extends string = string, V = Buffer> {
56
56
  getByIdAsBuffer(id?: K): Promise<Buffer | null>;
57
57
  requireById(id: K): Promise<V>;
58
58
  requireByIdAsBuffer(id: K): Promise<Buffer>;
59
- getByIds(ids: K[]): Promise<KeyValueTuple<string, V>[]>;
60
- getByIdsAsBuffer(ids: K[]): Promise<KeyValueDBTuple[]>;
59
+ getByIds(ids: readonly K[]): Promise<KeyValueTuple<string, V>[]>;
60
+ getByIdsAsBuffer(ids: readonly K[]): Promise<KeyValueDBTuple[]>;
61
61
  save(id: K, value: V, opt?: CommonKeyValueDaoSaveOptions): Promise<void>;
62
- saveBatch(entries: KeyValueTuple<K, V>[], opt?: CommonKeyValueDaoSaveOptions): Promise<void>;
63
- deleteByIds(ids: K[]): Promise<void>;
62
+ saveBatch(entries: readonly KeyValueTuple<K, V>[], opt?: CommonKeyValueDaoSaveOptions): Promise<void>;
63
+ deleteByIds(ids: readonly K[]): Promise<void>;
64
64
  deleteById(id: K): Promise<void>;
65
65
  streamIds(limit?: number): Pipeline<K>;
66
66
  streamValues(limit?: number): Pipeline<V>;
@@ -75,5 +75,5 @@ export declare class CommonKeyValueDao<K extends string = string, V = Buffer> {
75
75
  * Returns the new value of the field.
76
76
  */
77
77
  increment(id: K, by?: number): Promise<number>;
78
- incrementBatch(entries: IncrementTuple[]): Promise<IncrementTuple[]>;
78
+ incrementBatch(entries: readonly IncrementTuple[]): Promise<IncrementTuple[]>;
79
79
  }
@@ -22,5 +22,6 @@ export declare class CommonKeyValueDaoMemoCache<VALUE> implements AsyncMemoCache
22
22
  constructor(cfg: CommonKeyValueDaoMemoCacheCfg<VALUE>);
23
23
  get(k: string): Promise<VALUE | typeof MISS>;
24
24
  set(k: string, v: VALUE): Promise<void>;
25
+ delete(k: string): Promise<void>;
25
26
  clear(): Promise<void>;
26
27
  }
@@ -22,6 +22,9 @@ export class CommonKeyValueDaoMemoCache {
22
22
  : undefined;
23
23
  await this.cfg.dao.save(k, v, opt);
24
24
  }
25
+ async delete(k) {
26
+ await this.cfg.dao.deleteById(k);
27
+ }
25
28
  async clear() {
26
29
  throw new Error('CommonKeyValueDaoMemoCache.clear is not supported, because cache is expected to be persistent');
27
30
  }
@@ -23,7 +23,7 @@ import type { RunQueryResult } from '../db.model.js';
23
23
  * You may also look at queryInMemory() for its implementation (it implements all those).
24
24
  */
25
25
  export type DBQueryFilterOperator = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'in' | 'not-in' | 'array-contains' | 'array-contains-any';
26
- export declare const dbQueryFilterOperatorValues: DBQueryFilterOperator[];
26
+ export declare const dbQueryFilterOperatorValues: readonly DBQueryFilterOperator[];
27
27
  export interface DBQueryFilter<ROW extends ObjectWithId> {
28
28
  name: keyof ROW;
29
29
  op: DBQueryFilterOperator;
@@ -68,15 +68,15 @@ export declare class DBQuery<ROW extends ObjectWithId> {
68
68
  _distinct: boolean;
69
69
  filter(name: keyof ROW, op: DBQueryFilterOperator, val: any): this;
70
70
  filterEq(name: keyof ROW, val: any): this;
71
- filterIn(name: keyof ROW, val: any[]): this;
71
+ filterIn(name: keyof ROW, val: readonly any[]): this;
72
72
  /**
73
73
  * Passing 0 means "no limit".
74
74
  */
75
75
  limit(limit: number): this;
76
76
  offset(offset: number): this;
77
77
  order(name: keyof ROW, descending?: boolean): this;
78
- select(fieldNames: (keyof ROW)[]): this;
79
- groupBy(fieldNames: (keyof ROW)[]): this;
78
+ select(fieldNames: readonly (keyof ROW)[]): this;
79
+ groupBy(fieldNames: readonly (keyof ROW)[]): this;
80
80
  distinct(distinct?: boolean): this;
81
81
  startCursor(startCursor?: string): this;
82
82
  endCursor(endCursor?: string): this;