@naturalcycles/db-lib 10.26.0 → 10.27.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.
- package/dist/adapter/cachedb/cache.db.d.ts +2 -2
- package/dist/adapter/cachedb/cache.db.js +6 -6
- package/dist/adapter/file/file.db.d.ts +2 -2
- package/dist/adapter/file/file.db.js +5 -6
- package/dist/commondao/common.dao.d.ts +7 -21
- package/dist/commondao/common.dao.js +36 -153
- package/dist/commondao/common.dao.model.d.ts +1 -19
- package/dist/commondb/base.common.db.d.ts +2 -2
- package/dist/commondb/common.db.d.ts +2 -2
- package/dist/inmemory/inMemory.db.d.ts +2 -2
- package/dist/inmemory/inMemory.db.js +2 -2
- package/dist/inmemory/inMemoryKeyValueDB.d.ts +4 -4
- package/dist/inmemory/inMemoryKeyValueDB.js +4 -4
- package/dist/kv/commonKeyValueDB.d.ts +4 -4
- package/dist/kv/commonKeyValueDao.d.ts +5 -5
- package/dist/kv/commonKeyValueDao.js +9 -12
- package/dist/pipeline/dbPipelineBackup.d.ts +1 -1
- package/dist/pipeline/dbPipelineBackup.js +3 -3
- package/dist/pipeline/dbPipelineCopy.d.ts +1 -1
- package/dist/pipeline/dbPipelineCopy.js +3 -4
- package/dist/pipeline/dbPipelineRestore.js +1 -1
- package/dist/query/dbQuery.d.ts +6 -12
- package/dist/query/dbQuery.js +0 -19
- package/dist/testing/commonDaoTest.js +8 -2
- package/package.json +2 -2
- package/src/adapter/cachedb/cache.db.ts +7 -8
- package/src/adapter/file/file.db.ts +6 -10
- package/src/commondao/common.dao.model.ts +1 -26
- package/src/commondao/common.dao.ts +45 -205
- package/src/commondb/base.common.db.ts +2 -2
- package/src/commondb/common.db.ts +2 -2
- package/src/inmemory/inMemory.db.ts +3 -7
- package/src/inmemory/inMemoryKeyValueDB.ts +7 -8
- package/src/kv/commonKeyValueDB.ts +4 -4
- package/src/kv/commonKeyValueDao.ts +16 -20
- package/src/pipeline/dbPipelineBackup.ts +6 -6
- package/src/pipeline/dbPipelineCopy.ts +6 -8
- package/src/pipeline/dbPipelineRestore.ts +1 -1
- package/src/query/dbQuery.ts +5 -39
- package/src/testing/commonDaoTest.ts +8 -2
package/src/query/dbQuery.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { _truncate } from '@naturalcycles/js-lib/string/string.util.js'
|
|
2
|
-
import type {
|
|
2
|
+
import type { BaseDBEntity, ObjectWithId } from '@naturalcycles/js-lib/types'
|
|
3
3
|
import { _objectAssign } from '@naturalcycles/js-lib/types'
|
|
4
|
-
import { Pipeline
|
|
4
|
+
import type { Pipeline } from '@naturalcycles/nodejs-lib/stream'
|
|
5
5
|
import type { CommonDao } from '../commondao/common.dao.js'
|
|
6
6
|
import type {
|
|
7
7
|
CommonDaoOptions,
|
|
8
8
|
CommonDaoReadOptions,
|
|
9
9
|
CommonDaoStreamDeleteOptions,
|
|
10
|
-
CommonDaoStreamForEachOptions,
|
|
11
10
|
CommonDaoStreamOptions,
|
|
12
11
|
} from '../commondao/common.dao.model.js'
|
|
13
12
|
import type { RunQueryResult } from '../db.model.js'
|
|
@@ -276,55 +275,22 @@ export class RunnableDBQuery<
|
|
|
276
275
|
return await this.dao.patchByQuery(this, patch, opt)
|
|
277
276
|
}
|
|
278
277
|
|
|
279
|
-
|
|
280
|
-
mapper: AsyncIndexedMapper<BM, void>,
|
|
281
|
-
opt?: CommonDaoStreamForEachOptions<BM>,
|
|
282
|
-
): Promise<void> {
|
|
283
|
-
await this.dao.streamQueryForEach(this, mapper, opt)
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
async streamQueryAsDBMForEach(
|
|
287
|
-
mapper: AsyncIndexedMapper<DBM, void>,
|
|
288
|
-
opt?: CommonDaoStreamForEachOptions<DBM>,
|
|
289
|
-
): Promise<void> {
|
|
290
|
-
await this.dao.streamQueryAsDBMForEach(this, mapper, opt)
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
streamQuery(opt?: CommonDaoStreamOptions<BM>): ReadableTyped<BM> {
|
|
278
|
+
streamQuery(opt?: CommonDaoStreamOptions<BM>): Pipeline<BM> {
|
|
294
279
|
return this.dao.streamQuery(this, opt)
|
|
295
280
|
}
|
|
296
281
|
|
|
297
|
-
streamQueryAsDBM(opt?: CommonDaoStreamOptions<DBM>):
|
|
282
|
+
streamQueryAsDBM(opt?: CommonDaoStreamOptions<DBM>): Pipeline<DBM> {
|
|
298
283
|
return this.dao.streamQueryAsDBM(this, opt)
|
|
299
284
|
}
|
|
300
285
|
|
|
301
|
-
pipeline(opt?: CommonDaoStreamOptions<BM>): Pipeline<BM> {
|
|
302
|
-
return Pipeline.from(this.dao.streamQuery(this, opt))
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
pipelineAsDBM(opt?: CommonDaoStreamOptions<DBM>): Pipeline<DBM> {
|
|
306
|
-
return Pipeline.from(this.dao.streamQueryAsDBM(this, opt))
|
|
307
|
-
}
|
|
308
|
-
|
|
309
286
|
async queryIds(opt?: CommonDaoReadOptions): Promise<ID[]> {
|
|
310
287
|
return await this.dao.queryIds(this, opt)
|
|
311
288
|
}
|
|
312
289
|
|
|
313
|
-
streamQueryIds(opt?: CommonDaoStreamOptions<ID>):
|
|
290
|
+
streamQueryIds(opt?: CommonDaoStreamOptions<ID>): Pipeline<ID> {
|
|
314
291
|
return this.dao.streamQueryIds(this, opt)
|
|
315
292
|
}
|
|
316
293
|
|
|
317
|
-
pipelineIds(opt?: CommonDaoStreamOptions<ID>): Pipeline<ID> {
|
|
318
|
-
return Pipeline.from(this.dao.streamQueryIds(this, opt))
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
async streamQueryIdsForEach(
|
|
322
|
-
mapper: AsyncIndexedMapper<ID, void>,
|
|
323
|
-
opt?: CommonDaoStreamForEachOptions<ID>,
|
|
324
|
-
): Promise<void> {
|
|
325
|
-
await this.dao.streamQueryIdsForEach(this, mapper, opt)
|
|
326
|
-
}
|
|
327
|
-
|
|
328
294
|
async deleteByQuery(opt?: CommonDaoStreamDeleteOptions<DBM>): Promise<number> {
|
|
329
295
|
return await this.dao.deleteByQuery(this, opt)
|
|
330
296
|
}
|
|
@@ -245,7 +245,10 @@ export async function runCommonDaoTest(
|
|
|
245
245
|
if (support.streaming) {
|
|
246
246
|
test('streamQueryForEach all', async () => {
|
|
247
247
|
let rows: TestItemBM[] = []
|
|
248
|
-
await dao
|
|
248
|
+
await dao
|
|
249
|
+
.query()
|
|
250
|
+
.streamQuery()
|
|
251
|
+
.forEachSync(bm => void rows.push(bm))
|
|
249
252
|
|
|
250
253
|
rows = _sortBy(rows, r => r.id)
|
|
251
254
|
expectMatch(expectedItems, rows, quirks)
|
|
@@ -260,7 +263,10 @@ export async function runCommonDaoTest(
|
|
|
260
263
|
|
|
261
264
|
test('streamQueryIdsForEach all', async () => {
|
|
262
265
|
let ids: string[] = []
|
|
263
|
-
await dao
|
|
266
|
+
await dao
|
|
267
|
+
.query()
|
|
268
|
+
.streamQueryIds()
|
|
269
|
+
.forEachSync(id => void ids.push(id))
|
|
264
270
|
ids = ids.sort()
|
|
265
271
|
expectMatch(
|
|
266
272
|
expectedItems.map(i => i.id),
|