@naturalcycles/db-lib 10.4.0 → 10.5.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 +1 -1
- package/dist/adapter/file/file.db.d.ts +1 -1
- package/dist/adapter/file/file.db.js +3 -2
- package/dist/adapter/file/localFile.persistence.plugin.js +2 -1
- package/dist/adapter/inmemory/inMemory.db.d.ts +1 -1
- package/dist/adapter/inmemory/inMemory.db.js +3 -1
- package/dist/adapter/inmemory/inMemoryKeyValueDB.d.ts +1 -1
- package/dist/base.common.db.d.ts +1 -1
- package/dist/common.db.d.ts +1 -1
- package/dist/commondao/common.dao.d.ts +7 -6
- package/dist/commondao/common.dao.js +4 -1
- package/dist/commondao/common.dao.model.d.ts +3 -1
- package/dist/kv/commonKeyValueDB.d.ts +1 -1
- package/dist/kv/commonKeyValueDao.d.ts +1 -1
- package/dist/pipeline/dbPipelineBackup.d.ts +2 -2
- package/dist/pipeline/dbPipelineBackup.js +3 -1
- package/dist/pipeline/dbPipelineCopy.d.ts +2 -2
- package/dist/pipeline/dbPipelineCopy.js +2 -1
- package/dist/pipeline/dbPipelineRestore.d.ts +2 -2
- package/dist/pipeline/dbPipelineRestore.js +3 -1
- package/dist/query/dbQuery.d.ts +5 -5
- package/dist/testing/commonDaoTest.js +1 -1
- package/dist/testing/keyValueDBTest.js +1 -1
- package/dist/testing/keyValueDaoTest.js +1 -1
- package/dist/testing/test.model.d.ts +1 -1
- package/dist/testing/test.model.js +1 -1
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +1 -1
- package/package.json +3 -3
- package/src/adapter/cachedb/cache.db.ts +1 -1
- package/src/adapter/file/file.db.ts +4 -3
- package/src/adapter/file/localFile.persistence.plugin.ts +2 -1
- package/src/adapter/inmemory/inMemory.db.ts +3 -2
- package/src/adapter/inmemory/inMemoryKeyValueDB.ts +1 -1
- package/src/base.common.db.ts +1 -1
- package/src/common.db.ts +1 -1
- package/src/commondao/common.dao.model.ts +3 -5
- package/src/commondao/common.dao.ts +13 -14
- package/src/kv/commonKeyValueDB.ts +1 -1
- package/src/kv/commonKeyValueDao.ts +1 -1
- package/src/pipeline/dbPipelineBackup.ts +7 -7
- package/src/pipeline/dbPipelineCopy.ts +6 -6
- package/src/pipeline/dbPipelineRestore.ts +7 -7
- package/src/query/dbQuery.ts +5 -5
- package/src/testing/commonDaoTest.ts +1 -1
- package/src/testing/keyValueDBTest.ts +1 -1
- package/src/testing/keyValueDaoTest.ts +1 -1
- package/src/testing/test.model.ts +1 -1
- package/src/validation/index.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JsonSchemaObject, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib';
|
|
2
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
2
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream';
|
|
3
3
|
import { BaseCommonDB } from '../../base.common.db.js';
|
|
4
4
|
import type { CommonDB, CommonDBSupport } from '../../common.db.js';
|
|
5
5
|
import type { RunQueryResult } from '../../db.model.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib';
|
|
2
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
2
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream';
|
|
3
3
|
import { BaseCommonDB } from '../../base.common.db.js';
|
|
4
4
|
import type { CommonDB, CommonDBSupport } from '../../common.db.js';
|
|
5
5
|
import type { CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, DBSaveBatchOperation, RunQueryResult } from '../../db.model.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { _assert, _by, _deepEquals, _filterUndefinedValues, _since, _sortBy, _sortObjectDeep, _stringMapValues, generateJsonSchemaFromData, localTime, } from '@naturalcycles/js-lib';
|
|
2
|
-
import { dimGrey
|
|
2
|
+
import { dimGrey } from '@naturalcycles/nodejs-lib';
|
|
3
|
+
import { readableCreate } from '@naturalcycles/nodejs-lib/stream';
|
|
3
4
|
import { BaseCommonDB } from '../../base.common.db.js';
|
|
4
5
|
import { commonDBFullSupport } from '../../common.db.js';
|
|
5
6
|
import { queryInMemory } from '../inmemory/queryInMemory.js';
|
|
@@ -147,7 +148,7 @@ export class FileDB extends BaseCommonDB {
|
|
|
147
148
|
sortRows(rows) {
|
|
148
149
|
rows = rows.map(r => _filterUndefinedValues(r));
|
|
149
150
|
if (this.cfg.sortOnSave) {
|
|
150
|
-
_sortBy(rows, r => r[this.cfg.sortOnSave.name], true);
|
|
151
|
+
_sortBy(rows, r => r[this.cfg.sortOnSave.name], { mutate: true });
|
|
151
152
|
if (this.cfg.sortOnSave.descending)
|
|
152
153
|
rows.reverse(); // mutates
|
|
153
154
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
2
|
import { pMap } from '@naturalcycles/js-lib';
|
|
3
|
-
import {
|
|
3
|
+
import { fs2 } from '@naturalcycles/nodejs-lib/fs';
|
|
4
|
+
import { _pipeline } from '@naturalcycles/nodejs-lib/stream';
|
|
4
5
|
/**
|
|
5
6
|
* Persists in local filesystem as ndjson.
|
|
6
7
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyObjectWithId, CommonLogger, JsonSchemaObject, JsonSchemaRootObject, ObjectWithId, StringMap } from '@naturalcycles/js-lib';
|
|
2
|
-
import type
|
|
2
|
+
import { type ReadableTyped } from '@naturalcycles/nodejs-lib/stream';
|
|
3
3
|
import type { CommonDB, CommonDBSupport } from '../../common.db.js';
|
|
4
4
|
import { CommonDBType } from '../../common.db.js';
|
|
5
5
|
import type { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions, CommonDBTransactionOptions, DBOperation, DBTransaction, DBTransactionFn, RunQueryResult } from '../../db.model.js';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
2
|
import { _assert, _by, _deepCopy, _isEmptyObject, _since, _sortObjectDeep, _stringMapEntries, _stringMapValues, generateJsonSchemaFromData, localTime, pMap, } from '@naturalcycles/js-lib';
|
|
3
|
-
import {
|
|
3
|
+
import { dimGrey, yellow } from '@naturalcycles/nodejs-lib';
|
|
4
|
+
import { fs2 } from '@naturalcycles/nodejs-lib/fs';
|
|
5
|
+
import { _pipeline, bufferReviver } from '@naturalcycles/nodejs-lib/stream';
|
|
4
6
|
import { commonDBFullSupport, CommonDBType } from '../../common.db.js';
|
|
5
7
|
import { queryInMemory } from './queryInMemory.js';
|
|
6
8
|
export class InMemoryDB {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StringMap } from '@naturalcycles/js-lib';
|
|
2
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
2
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream';
|
|
3
3
|
import type { CommonDBCreateOptions } from '../../db.model.js';
|
|
4
4
|
import type { CommonKeyValueDB, IncrementTuple, KeyValueDBTuple } from '../../kv/commonKeyValueDB.js';
|
|
5
5
|
export interface InMemoryKeyValueDBCfg {
|
package/dist/base.common.db.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JsonSchemaObject, JsonSchemaRootObject, ObjectWithId, StringMap } from '@naturalcycles/js-lib';
|
|
2
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
2
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream';
|
|
3
3
|
import type { CommonDB, CommonDBSupport } from './common.db.js';
|
|
4
4
|
import { CommonDBType } from './common.db.js';
|
|
5
5
|
import type { CommonDBOptions, CommonDBSaveOptions, CommonDBTransactionOptions, DBTransaction, DBTransactionFn, RunQueryResult } from './db.model.js';
|
package/dist/common.db.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JsonSchemaObject, JsonSchemaRootObject, ObjectWithId, StringMap } from '@naturalcycles/js-lib';
|
|
2
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
2
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream';
|
|
3
3
|
import type { CommonDBCreateOptions, CommonDBOptions, CommonDBReadOptions, CommonDBSaveOptions, CommonDBStreamOptions, CommonDBTransactionOptions, DBTransaction, DBTransactionFn, RunQueryResult } from './db.model.js';
|
|
4
4
|
import type { DBQuery } from './query/dbQuery.js';
|
|
5
5
|
export declare enum CommonDBType {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Transform } from 'node:stream';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AsyncIndexedMapper, BaseDBEntity, CommonLogger, JsonSchemaObject, JsonSchemaRootObject, StringMap, UnixTimestampMillis, Unsaved } from '@naturalcycles/js-lib';
|
|
3
3
|
import { ZodType } from '@naturalcycles/js-lib/zod';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import { AjvSchema } from '@naturalcycles/nodejs-lib/ajv';
|
|
5
|
+
import { type ObjectSchema } from '@naturalcycles/nodejs-lib/joi';
|
|
6
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream';
|
|
6
7
|
import type { CommonDBTransactionOptions, DBTransaction, RunQueryResult } from '../db.model.js';
|
|
7
8
|
import type { DBQuery } from '../query/dbQuery.js';
|
|
8
9
|
import { RunnableDBQuery } from '../query/dbQuery.js';
|
|
@@ -54,8 +55,8 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
|
|
|
54
55
|
runQueryAsDBM(q: DBQuery<DBM>, opt?: CommonDaoReadOptions): Promise<DBM[]>;
|
|
55
56
|
runQueryExtendedAsDBM(q: DBQuery<DBM>, opt?: CommonDaoReadOptions): Promise<RunQueryResult<DBM>>;
|
|
56
57
|
runQueryCount(q: DBQuery<DBM>, opt?: CommonDaoReadOptions): Promise<number>;
|
|
57
|
-
streamQueryForEach(q: DBQuery<DBM>, mapper:
|
|
58
|
-
streamQueryAsDBMForEach(q: DBQuery<DBM>, mapper:
|
|
58
|
+
streamQueryForEach(q: DBQuery<DBM>, mapper: AsyncIndexedMapper<BM, void>, opt?: CommonDaoStreamForEachOptions<BM>): Promise<void>;
|
|
59
|
+
streamQueryAsDBMForEach(q: DBQuery<DBM>, mapper: AsyncIndexedMapper<DBM, void>, opt?: CommonDaoStreamForEachOptions<DBM>): Promise<void>;
|
|
59
60
|
/**
|
|
60
61
|
* Stream as Readable, to be able to .pipe() it further with support of backpressure.
|
|
61
62
|
*/
|
|
@@ -72,7 +73,7 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
|
|
|
72
73
|
streamQuery(q: DBQuery<DBM>, opt?: CommonDaoStreamOptions<BM>): ReadableTyped<BM>;
|
|
73
74
|
queryIds(q: DBQuery<DBM>, opt?: CommonDaoReadOptions): Promise<ID[]>;
|
|
74
75
|
streamQueryIds(q: DBQuery<DBM>, opt?: CommonDaoStreamOptions<ID>): ReadableTyped<ID>;
|
|
75
|
-
streamQueryIdsForEach(q: DBQuery<DBM>, mapper:
|
|
76
|
+
streamQueryIdsForEach(q: DBQuery<DBM>, mapper: AsyncIndexedMapper<ID, void>, opt?: CommonDaoStreamForEachOptions<ID>): Promise<void>;
|
|
76
77
|
/**
|
|
77
78
|
* Mutates!
|
|
78
79
|
* "Returns", just to have a type of "Saved"
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { _assert, _deepCopy, _deepJsonEquals, _filterUndefinedValues, _isTruthy, _objectAssignExact, _passthroughPredicate, _since, _truncate, _typeCast, _uniqBy, AppError, ErrorMode, localTime, pMap, SKIP, } from '@naturalcycles/js-lib';
|
|
2
2
|
import { ZodType, zSafeValidate } from '@naturalcycles/js-lib/zod';
|
|
3
|
-
import {
|
|
3
|
+
import { stringId } from '@naturalcycles/nodejs-lib';
|
|
4
|
+
import { AjvSchema } from '@naturalcycles/nodejs-lib/ajv';
|
|
5
|
+
import { getValidationResult, } from '@naturalcycles/nodejs-lib/joi';
|
|
6
|
+
import { _pipeline, transformChunk, transformLogProgress, transformMap, transformNoOp, writableVoid, } from '@naturalcycles/nodejs-lib/stream';
|
|
4
7
|
import { DBLibError } from '../cnst.js';
|
|
5
8
|
import { RunnableDBQuery } from '../query/dbQuery.js';
|
|
6
9
|
import { CommonDaoLogLevel } from './common.dao.model.js';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { BaseDBEntity, CommonLogger, ErrorMode, NumberOfMilliseconds, Promisable, UnixTimestamp } from '@naturalcycles/js-lib';
|
|
2
2
|
import type { ZodType, ZodValidationError } from '@naturalcycles/js-lib/zod';
|
|
3
|
-
import type { AjvSchema, AjvValidationError
|
|
3
|
+
import type { AjvSchema, AjvValidationError } from '@naturalcycles/nodejs-lib/ajv';
|
|
4
|
+
import type { JoiValidationError, ObjectSchema } from '@naturalcycles/nodejs-lib/joi';
|
|
5
|
+
import type { TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib/stream';
|
|
4
6
|
import type { CommonDB } from '../common.db.js';
|
|
5
7
|
import type { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model.js';
|
|
6
8
|
export interface CommonDaoHooks<BM extends BaseDBEntity, DBM extends BaseDBEntity, ID = BM['id']> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Integer, UnixTimestamp } from '@naturalcycles/js-lib';
|
|
2
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
2
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream';
|
|
3
3
|
import type { CommonDBCreateOptions } from '../db.model.js';
|
|
4
4
|
/**
|
|
5
5
|
* Common interface for Key-Value database implementations.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CommonLogger, KeyValueTuple } from '@naturalcycles/js-lib';
|
|
2
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
2
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream';
|
|
3
3
|
import type { CommonDaoLogLevel } from '../commondao/common.dao.model.js';
|
|
4
4
|
import type { CommonDBCreateOptions } from '../db.model.js';
|
|
5
5
|
import type { CommonKeyValueDB, CommonKeyValueDBSaveBatchOptions, IncrementTuple, KeyValueDBTuple } from './commonKeyValueDB.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AsyncMapper, StringMap, UnixTimestamp } from '@naturalcycles/js-lib';
|
|
2
2
|
import { ErrorMode } from '@naturalcycles/js-lib';
|
|
3
|
-
import type { TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib';
|
|
4
|
-
import { NDJsonStats } from '@naturalcycles/nodejs-lib';
|
|
3
|
+
import type { TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib/stream';
|
|
4
|
+
import { NDJsonStats } from '@naturalcycles/nodejs-lib/stream';
|
|
5
5
|
import type { CommonDB } from '../common.db.js';
|
|
6
6
|
import { DBQuery } from '../query/dbQuery.js';
|
|
7
7
|
export interface DBPipelineBackupOptions extends TransformLogProgressOptions {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { _passthroughMapper, AppError, ErrorMode, localTime, pMap } from '@naturalcycles/js-lib';
|
|
2
|
-
import {
|
|
2
|
+
import { boldWhite, dimWhite, grey, yellow } from '@naturalcycles/nodejs-lib';
|
|
3
|
+
import { fs2 } from '@naturalcycles/nodejs-lib/fs';
|
|
4
|
+
import { _pipeline, NDJsonStats, transformLogProgress, transformMap, transformTap, } from '@naturalcycles/nodejs-lib/stream';
|
|
3
5
|
import { DBQuery } from '../query/dbQuery.js';
|
|
4
6
|
/**
|
|
5
7
|
* Pipeline from input stream(s) to a NDJSON file (optionally gzipped).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AsyncMapper, UnixTimestamp } from '@naturalcycles/js-lib';
|
|
2
2
|
import { ErrorMode } from '@naturalcycles/js-lib';
|
|
3
|
-
import type { TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib';
|
|
4
|
-
import { NDJsonStats } from '@naturalcycles/nodejs-lib';
|
|
3
|
+
import type { TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib/stream';
|
|
4
|
+
import { NDJsonStats } from '@naturalcycles/nodejs-lib/stream';
|
|
5
5
|
import type { CommonDB } from '../common.db.js';
|
|
6
6
|
import type { CommonDBSaveOptions } from '../db.model.js';
|
|
7
7
|
export interface DBPipelineCopyOptions extends TransformLogProgressOptions {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { _passthroughMapper, ErrorMode, localTime, pMap } from '@naturalcycles/js-lib';
|
|
2
|
-
import {
|
|
2
|
+
import { boldWhite, dimWhite, grey, yellow } from '@naturalcycles/nodejs-lib';
|
|
3
|
+
import { _pipeline, NDJsonStats, transformChunk, transformLogProgress, transformMap, transformTap, writableForEach, } from '@naturalcycles/nodejs-lib/stream';
|
|
3
4
|
import { DBQuery } from '../query/dbQuery.js';
|
|
4
5
|
/**
|
|
5
6
|
* Pipeline from input stream(s) to CommonDB .saveBatch().
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AsyncMapper, UnixTimestamp } from '@naturalcycles/js-lib';
|
|
2
2
|
import { ErrorMode } from '@naturalcycles/js-lib';
|
|
3
|
-
import type { TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib';
|
|
4
|
-
import { NDJsonStats } from '@naturalcycles/nodejs-lib';
|
|
3
|
+
import type { TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib/stream';
|
|
4
|
+
import { NDJsonStats } from '@naturalcycles/nodejs-lib/stream';
|
|
5
5
|
import type { CommonDB } from '../common.db.js';
|
|
6
6
|
import type { CommonDBSaveOptions } from '../db.model.js';
|
|
7
7
|
export interface DBPipelineRestoreOptions extends TransformLogProgressOptions {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { _hb, _mapValues, _passthroughMapper, ErrorMode, localTime, pMap, } from '@naturalcycles/js-lib';
|
|
2
|
-
import {
|
|
2
|
+
import { boldWhite, dimWhite, grey, yellow } from '@naturalcycles/nodejs-lib';
|
|
3
|
+
import { fs2 } from '@naturalcycles/nodejs-lib/fs';
|
|
4
|
+
import { _pipeline, NDJsonStats, transformChunk, transformFilterSync, transformLogProgress, transformMap, transformTap, writableForEach, } from '@naturalcycles/nodejs-lib/stream';
|
|
3
5
|
/**
|
|
4
6
|
* Pipeline from NDJSON files in a folder (optionally gzipped) to CommonDB.
|
|
5
7
|
* Allows to define a mapper and a predicate to map/filter objects between input and output.
|
package/dist/query/dbQuery.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
1
|
+
import type { AsyncIndexedMapper, BaseDBEntity, ObjectWithId } from '@naturalcycles/js-lib';
|
|
2
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream';
|
|
3
3
|
import type { CommonDao } from '../commondao/common.dao.js';
|
|
4
4
|
import type { CommonDaoOptions, CommonDaoReadOptions, CommonDaoStreamDeleteOptions, CommonDaoStreamForEachOptions, CommonDaoStreamOptions } from '../commondao/common.dao.model.js';
|
|
5
5
|
import type { RunQueryResult } from '../db.model.js';
|
|
@@ -100,12 +100,12 @@ export declare class RunnableDBQuery<BM extends BaseDBEntity, DBM extends BaseDB
|
|
|
100
100
|
runQueryExtendedAsDBM(opt?: CommonDaoReadOptions): Promise<RunQueryResult<DBM>>;
|
|
101
101
|
runQueryCount(opt?: CommonDaoReadOptions): Promise<number>;
|
|
102
102
|
patchByQuery(patch: Partial<DBM>, opt?: CommonDaoOptions): Promise<number>;
|
|
103
|
-
streamQueryForEach(mapper:
|
|
104
|
-
streamQueryAsDBMForEach(mapper:
|
|
103
|
+
streamQueryForEach(mapper: AsyncIndexedMapper<BM, void>, opt?: CommonDaoStreamForEachOptions<BM>): Promise<void>;
|
|
104
|
+
streamQueryAsDBMForEach(mapper: AsyncIndexedMapper<DBM, void>, opt?: CommonDaoStreamForEachOptions<DBM>): Promise<void>;
|
|
105
105
|
streamQuery(opt?: CommonDaoStreamOptions<BM>): ReadableTyped<BM>;
|
|
106
106
|
streamQueryAsDBM(opt?: CommonDaoStreamOptions<DBM>): ReadableTyped<DBM>;
|
|
107
107
|
queryIds(opt?: CommonDaoReadOptions): Promise<ID[]>;
|
|
108
108
|
streamQueryIds(opt?: CommonDaoStreamOptions<ID>): ReadableTyped<ID>;
|
|
109
|
-
streamQueryIdsForEach(mapper:
|
|
109
|
+
streamQueryIdsForEach(mapper: AsyncIndexedMapper<ID, void>, opt?: CommonDaoStreamForEachOptions<ID>): Promise<void>;
|
|
110
110
|
deleteByQuery(opt?: CommonDaoStreamDeleteOptions<DBM>): Promise<number>;
|
|
111
111
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
2
|
import { _deepCopy, _filterObject, _omit, _pick, _sortBy, localTime } from '@naturalcycles/js-lib';
|
|
3
|
-
import { _pipeline } from '@naturalcycles/nodejs-lib';
|
|
3
|
+
import { _pipeline } from '@naturalcycles/nodejs-lib/stream';
|
|
4
4
|
import { CommonDao } from '../commondao/common.dao.js';
|
|
5
5
|
import { CommonDaoLogLevel } from '../commondao/common.dao.model.js';
|
|
6
6
|
import { DBQuery } from '../query/dbQuery.js';
|
|
@@ -39,7 +39,7 @@ export async function runCommonKeyValueDBTest(db) {
|
|
|
39
39
|
test('saveBatch, then getByIds', async () => {
|
|
40
40
|
await db.saveBatch(TEST_TABLE, testEntries);
|
|
41
41
|
const entries = await db.getByIds(TEST_TABLE, testIds);
|
|
42
|
-
_sortBy(entries, e => e[0], true);
|
|
42
|
+
_sortBy(entries, e => e[0], { mutate: true });
|
|
43
43
|
expect(entries).toEqual(testEntries);
|
|
44
44
|
});
|
|
45
45
|
if (support.count) {
|
|
@@ -41,7 +41,7 @@ export async function runCommonKeyValueDaoTest(db) {
|
|
|
41
41
|
await dao.saveBatch(testEntries);
|
|
42
42
|
const entries = await dao.getByIds(testIds);
|
|
43
43
|
// console.log(typeof entries[0]![1], entries[0]![1])
|
|
44
|
-
_sortBy(entries, e => e[0], true);
|
|
44
|
+
_sortBy(entries, e => e[0], { mutate: true });
|
|
45
45
|
expect(entries).toEqual(testEntries); // Jest doesn't allow to compare Buffers directly
|
|
46
46
|
// expect(entries.map(e => e[0])).toEqual(testEntries.map(e => e[0]))
|
|
47
47
|
// expect(entries.map(e => e[1].toString())).toEqual(testEntries.map(e => e[1].toString()))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseDBEntity, JsonSchemaObject } from '@naturalcycles/js-lib';
|
|
2
|
-
import { type ObjectSchema } from '@naturalcycles/nodejs-lib';
|
|
2
|
+
import { type ObjectSchema } from '@naturalcycles/nodejs-lib/joi';
|
|
3
3
|
export declare const TEST_TABLE = "TEST_TABLE";
|
|
4
4
|
export interface TestItemBM extends BaseDBEntity {
|
|
5
5
|
k1: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _range, jsonSchema } from '@naturalcycles/js-lib';
|
|
2
|
-
import { baseDBEntitySchema, binarySchema, booleanSchema, numberSchema, objectSchema, stringSchema, } from '@naturalcycles/nodejs-lib';
|
|
2
|
+
import { baseDBEntitySchema, binarySchema, booleanSchema, numberSchema, objectSchema, stringSchema, } from '@naturalcycles/nodejs-lib/joi';
|
|
3
3
|
const MOCK_TS_2018_06_21 = 1529539200;
|
|
4
4
|
export const TEST_TABLE = 'TEST_TABLE';
|
|
5
5
|
export const testItemBMSchema = objectSchema({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ObjectSchema, type StringSchema } from '@naturalcycles/nodejs-lib';
|
|
1
|
+
import { type ObjectSchema, type StringSchema } from '@naturalcycles/nodejs-lib/joi';
|
|
2
2
|
import type { CommonDBOptions, CommonDBSaveOptions } from '../db.model.js';
|
|
3
3
|
import type { DBQuery, DBQueryFilter, DBQueryFilterOperator, DBQueryOrder } from '../query/dbQuery.js';
|
|
4
4
|
export declare const commonDBOptionsSchema: ObjectSchema<CommonDBOptions>;
|
package/dist/validation/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { anySchema, arraySchema, booleanSchema, integerSchema, Joi, objectSchema, stringSchema, } from '@naturalcycles/nodejs-lib';
|
|
1
|
+
import { anySchema, arraySchema, booleanSchema, integerSchema, Joi, objectSchema, stringSchema, } from '@naturalcycles/nodejs-lib/joi';
|
|
2
2
|
import { dbQueryFilterOperatorValues } from '../query/dbQuery.js';
|
|
3
3
|
export const commonDBOptionsSchema = objectSchema({
|
|
4
4
|
['onlyCache']: booleanSchema.optional(),
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/db-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.5.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@naturalcycles/js-lib": "^15",
|
|
7
|
-
"@naturalcycles/nodejs-lib": "^
|
|
7
|
+
"@naturalcycles/nodejs-lib": "^15"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@naturalcycles/dev-lib": "
|
|
10
|
+
"@naturalcycles/dev-lib": "19.5.0"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
StringMap,
|
|
7
7
|
} from '@naturalcycles/js-lib'
|
|
8
8
|
import { _isTruthy } from '@naturalcycles/js-lib'
|
|
9
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
9
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
10
10
|
import { BaseCommonDB } from '../../base.common.db.js'
|
|
11
11
|
import type { CommonDB, CommonDBSupport } from '../../common.db.js'
|
|
12
12
|
import { commonDBFullSupport } from '../../common.db.js'
|
|
@@ -11,8 +11,9 @@ import {
|
|
|
11
11
|
generateJsonSchemaFromData,
|
|
12
12
|
localTime,
|
|
13
13
|
} from '@naturalcycles/js-lib'
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
14
|
+
import { dimGrey } from '@naturalcycles/nodejs-lib'
|
|
15
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
16
|
+
import { readableCreate } from '@naturalcycles/nodejs-lib/stream'
|
|
16
17
|
import { BaseCommonDB } from '../../base.common.db.js'
|
|
17
18
|
import type { CommonDB, CommonDBSupport } from '../../common.db.js'
|
|
18
19
|
import { commonDBFullSupport } from '../../common.db.js'
|
|
@@ -227,7 +228,7 @@ export class FileDB extends BaseCommonDB implements CommonDB {
|
|
|
227
228
|
rows = rows.map(r => _filterUndefinedValues(r))
|
|
228
229
|
|
|
229
230
|
if (this.cfg.sortOnSave) {
|
|
230
|
-
_sortBy(rows, r => r[this.cfg.sortOnSave!.name as keyof ROW], true)
|
|
231
|
+
_sortBy(rows, r => r[this.cfg.sortOnSave!.name as keyof ROW] as string, { mutate: true })
|
|
231
232
|
if (this.cfg.sortOnSave.descending) rows.reverse() // mutates
|
|
232
233
|
}
|
|
233
234
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Readable } from 'node:stream'
|
|
2
2
|
import type { ObjectWithId } from '@naturalcycles/js-lib'
|
|
3
3
|
import { pMap } from '@naturalcycles/js-lib'
|
|
4
|
-
import {
|
|
4
|
+
import { fs2 } from '@naturalcycles/nodejs-lib/fs'
|
|
5
|
+
import { _pipeline } from '@naturalcycles/nodejs-lib/stream'
|
|
5
6
|
import type { DBSaveBatchOperation } from '../../db.model.js'
|
|
6
7
|
import type { FileDBPersistencePlugin } from './file.db.model.js'
|
|
7
8
|
|
|
@@ -20,8 +20,9 @@ import {
|
|
|
20
20
|
localTime,
|
|
21
21
|
pMap,
|
|
22
22
|
} from '@naturalcycles/js-lib'
|
|
23
|
-
import
|
|
24
|
-
import {
|
|
23
|
+
import { dimGrey, yellow } from '@naturalcycles/nodejs-lib'
|
|
24
|
+
import { fs2 } from '@naturalcycles/nodejs-lib/fs'
|
|
25
|
+
import { _pipeline, bufferReviver, type ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
25
26
|
import type { CommonDB, CommonDBSupport } from '../../common.db.js'
|
|
26
27
|
import { commonDBFullSupport, CommonDBType } from '../../common.db.js'
|
|
27
28
|
import type {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'node:stream'
|
|
2
2
|
import type { StringMap } from '@naturalcycles/js-lib'
|
|
3
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
3
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
4
4
|
import type { CommonDBCreateOptions } from '../../db.model.js'
|
|
5
5
|
import type {
|
|
6
6
|
CommonKeyValueDB,
|
package/src/base.common.db.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
ObjectWithId,
|
|
5
5
|
StringMap,
|
|
6
6
|
} from '@naturalcycles/js-lib'
|
|
7
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
7
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
8
8
|
import type { CommonDB, CommonDBSupport } from './common.db.js'
|
|
9
9
|
import { CommonDBType } from './common.db.js'
|
|
10
10
|
import type {
|
package/src/common.db.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
ObjectWithId,
|
|
5
5
|
StringMap,
|
|
6
6
|
} from '@naturalcycles/js-lib'
|
|
7
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
7
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
8
8
|
import type {
|
|
9
9
|
CommonDBCreateOptions,
|
|
10
10
|
CommonDBOptions,
|
|
@@ -7,14 +7,12 @@ import type {
|
|
|
7
7
|
UnixTimestamp,
|
|
8
8
|
} from '@naturalcycles/js-lib'
|
|
9
9
|
import type { ZodType, ZodValidationError } from '@naturalcycles/js-lib/zod'
|
|
10
|
+
import type { AjvSchema, AjvValidationError } from '@naturalcycles/nodejs-lib/ajv'
|
|
11
|
+
import type { JoiValidationError, ObjectSchema } from '@naturalcycles/nodejs-lib/joi'
|
|
10
12
|
import type {
|
|
11
|
-
AjvSchema,
|
|
12
|
-
AjvValidationError,
|
|
13
|
-
JoiValidationError,
|
|
14
|
-
ObjectSchema,
|
|
15
13
|
TransformLogProgressOptions,
|
|
16
14
|
TransformMapOptions,
|
|
17
|
-
} from '@naturalcycles/nodejs-lib'
|
|
15
|
+
} from '@naturalcycles/nodejs-lib/stream'
|
|
18
16
|
import type { CommonDB } from '../common.db.js'
|
|
19
17
|
import type { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model.js'
|
|
20
18
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Transform } from 'node:stream'
|
|
2
2
|
import type {
|
|
3
|
-
|
|
3
|
+
AsyncIndexedMapper,
|
|
4
4
|
BaseDBEntity,
|
|
5
5
|
CommonLogger,
|
|
6
6
|
JsonSchemaObject,
|
|
@@ -30,23 +30,22 @@ import {
|
|
|
30
30
|
} from '@naturalcycles/js-lib'
|
|
31
31
|
import type { ZodValidationError } from '@naturalcycles/js-lib/zod'
|
|
32
32
|
import { ZodType, zSafeValidate } from '@naturalcycles/js-lib/zod'
|
|
33
|
-
import
|
|
34
|
-
|
|
35
|
-
JoiValidationError,
|
|
36
|
-
ObjectSchema,
|
|
37
|
-
ReadableTyped,
|
|
38
|
-
} from '@naturalcycles/nodejs-lib'
|
|
33
|
+
import { stringId } from '@naturalcycles/nodejs-lib'
|
|
34
|
+
import { AjvSchema, type AjvValidationError } from '@naturalcycles/nodejs-lib/ajv'
|
|
39
35
|
import {
|
|
40
|
-
_pipeline,
|
|
41
|
-
AjvSchema,
|
|
42
36
|
getValidationResult,
|
|
43
|
-
|
|
37
|
+
type JoiValidationError,
|
|
38
|
+
type ObjectSchema,
|
|
39
|
+
} from '@naturalcycles/nodejs-lib/joi'
|
|
40
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
41
|
+
import {
|
|
42
|
+
_pipeline,
|
|
44
43
|
transformChunk,
|
|
45
44
|
transformLogProgress,
|
|
46
45
|
transformMap,
|
|
47
46
|
transformNoOp,
|
|
48
47
|
writableVoid,
|
|
49
|
-
} from '@naturalcycles/nodejs-lib'
|
|
48
|
+
} from '@naturalcycles/nodejs-lib/stream'
|
|
50
49
|
import { DBLibError } from '../cnst.js'
|
|
51
50
|
import type { CommonDBTransactionOptions, DBTransaction, RunQueryResult } from '../db.model.js'
|
|
52
51
|
import type { DBQuery } from '../query/dbQuery.js'
|
|
@@ -359,7 +358,7 @@ export class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity = BM, I
|
|
|
359
358
|
|
|
360
359
|
async streamQueryForEach(
|
|
361
360
|
q: DBQuery<DBM>,
|
|
362
|
-
mapper:
|
|
361
|
+
mapper: AsyncIndexedMapper<BM, void>,
|
|
363
362
|
opt: CommonDaoStreamForEachOptions<BM> = {},
|
|
364
363
|
): Promise<void> {
|
|
365
364
|
this.validateQueryIndexes(q) // throws if query uses `excludeFromIndexes` property
|
|
@@ -409,7 +408,7 @@ export class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity = BM, I
|
|
|
409
408
|
|
|
410
409
|
async streamQueryAsDBMForEach(
|
|
411
410
|
q: DBQuery<DBM>,
|
|
412
|
-
mapper:
|
|
411
|
+
mapper: AsyncIndexedMapper<DBM, void>,
|
|
413
412
|
opt: CommonDaoStreamForEachOptions<DBM> = {},
|
|
414
413
|
): Promise<void> {
|
|
415
414
|
this.validateQueryIndexes(q) // throws if query uses `excludeFromIndexes` property
|
|
@@ -582,7 +581,7 @@ export class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity = BM, I
|
|
|
582
581
|
|
|
583
582
|
async streamQueryIdsForEach(
|
|
584
583
|
q: DBQuery<DBM>,
|
|
585
|
-
mapper:
|
|
584
|
+
mapper: AsyncIndexedMapper<ID, void>,
|
|
586
585
|
opt: CommonDaoStreamForEachOptions<ID> = {},
|
|
587
586
|
): Promise<void> {
|
|
588
587
|
this.validateQueryIndexes(q) // throws if query uses `excludeFromIndexes` property
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Integer, UnixTimestamp } from '@naturalcycles/js-lib'
|
|
2
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
2
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
3
3
|
import type { CommonDBCreateOptions } from '../db.model.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CommonLogger, KeyValueTuple } from '@naturalcycles/js-lib'
|
|
2
2
|
import { AppError, pMap } from '@naturalcycles/js-lib'
|
|
3
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
4
3
|
import { deflateString, inflateToString } from '@naturalcycles/nodejs-lib'
|
|
4
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
5
5
|
import type { CommonDaoLogLevel } from '../commondao/common.dao.model.js'
|
|
6
6
|
import type { CommonDBCreateOptions } from '../db.model.js'
|
|
7
7
|
import type {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { AsyncMapper, StringMap, UnixTimestamp } from '@naturalcycles/js-lib'
|
|
2
2
|
import { _passthroughMapper, AppError, ErrorMode, localTime, pMap } from '@naturalcycles/js-lib'
|
|
3
|
-
import
|
|
3
|
+
import { boldWhite, dimWhite, grey, yellow } from '@naturalcycles/nodejs-lib'
|
|
4
|
+
import { fs2 } from '@naturalcycles/nodejs-lib/fs'
|
|
5
|
+
import type {
|
|
6
|
+
TransformLogProgressOptions,
|
|
7
|
+
TransformMapOptions,
|
|
8
|
+
} from '@naturalcycles/nodejs-lib/stream'
|
|
4
9
|
import {
|
|
5
10
|
_pipeline,
|
|
6
|
-
boldWhite,
|
|
7
|
-
dimWhite,
|
|
8
|
-
fs2,
|
|
9
|
-
grey,
|
|
10
11
|
NDJsonStats,
|
|
11
12
|
transformLogProgress,
|
|
12
13
|
transformMap,
|
|
13
14
|
transformTap,
|
|
14
|
-
|
|
15
|
-
} from '@naturalcycles/nodejs-lib'
|
|
15
|
+
} from '@naturalcycles/nodejs-lib/stream'
|
|
16
16
|
import type { CommonDB } from '../common.db.js'
|
|
17
17
|
import { DBQuery } from '../query/dbQuery.js'
|
|
18
18
|
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { AsyncMapper, BaseDBEntity, UnixTimestamp } from '@naturalcycles/js-lib'
|
|
2
2
|
import { _passthroughMapper, ErrorMode, localTime, pMap } from '@naturalcycles/js-lib'
|
|
3
|
-
import
|
|
3
|
+
import { boldWhite, dimWhite, grey, yellow } from '@naturalcycles/nodejs-lib'
|
|
4
|
+
import type {
|
|
5
|
+
TransformLogProgressOptions,
|
|
6
|
+
TransformMapOptions,
|
|
7
|
+
} from '@naturalcycles/nodejs-lib/stream'
|
|
4
8
|
import {
|
|
5
9
|
_pipeline,
|
|
6
|
-
boldWhite,
|
|
7
|
-
dimWhite,
|
|
8
|
-
grey,
|
|
9
10
|
NDJsonStats,
|
|
10
11
|
transformChunk,
|
|
11
12
|
transformLogProgress,
|
|
12
13
|
transformMap,
|
|
13
14
|
transformTap,
|
|
14
15
|
writableForEach,
|
|
15
|
-
|
|
16
|
-
} from '@naturalcycles/nodejs-lib'
|
|
16
|
+
} from '@naturalcycles/nodejs-lib/stream'
|
|
17
17
|
import type { CommonDB } from '../common.db.js'
|
|
18
18
|
import type { CommonDBSaveOptions } from '../db.model.js'
|
|
19
19
|
import { DBQuery } from '../query/dbQuery.js'
|
|
@@ -12,13 +12,14 @@ import {
|
|
|
12
12
|
localTime,
|
|
13
13
|
pMap,
|
|
14
14
|
} from '@naturalcycles/js-lib'
|
|
15
|
-
import
|
|
15
|
+
import { boldWhite, dimWhite, grey, yellow } from '@naturalcycles/nodejs-lib'
|
|
16
|
+
import { fs2 } from '@naturalcycles/nodejs-lib/fs'
|
|
17
|
+
import type {
|
|
18
|
+
TransformLogProgressOptions,
|
|
19
|
+
TransformMapOptions,
|
|
20
|
+
} from '@naturalcycles/nodejs-lib/stream'
|
|
16
21
|
import {
|
|
17
22
|
_pipeline,
|
|
18
|
-
boldWhite,
|
|
19
|
-
dimWhite,
|
|
20
|
-
fs2,
|
|
21
|
-
grey,
|
|
22
23
|
NDJsonStats,
|
|
23
24
|
transformChunk,
|
|
24
25
|
transformFilterSync,
|
|
@@ -26,8 +27,7 @@ import {
|
|
|
26
27
|
transformMap,
|
|
27
28
|
transformTap,
|
|
28
29
|
writableForEach,
|
|
29
|
-
|
|
30
|
-
} from '@naturalcycles/nodejs-lib'
|
|
30
|
+
} from '@naturalcycles/nodejs-lib/stream'
|
|
31
31
|
import type { CommonDB } from '../common.db.js'
|
|
32
32
|
import type { CommonDBSaveOptions } from '../db.model.js'
|
|
33
33
|
|
package/src/query/dbQuery.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AsyncIndexedMapper, BaseDBEntity, ObjectWithId } from '@naturalcycles/js-lib'
|
|
2
2
|
import { _objectAssign, _truncate } from '@naturalcycles/js-lib'
|
|
3
|
-
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
3
|
+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
4
4
|
import type { CommonDao } from '../commondao/common.dao.js'
|
|
5
5
|
import type {
|
|
6
6
|
CommonDaoOptions,
|
|
@@ -276,14 +276,14 @@ export class RunnableDBQuery<
|
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
async streamQueryForEach(
|
|
279
|
-
mapper:
|
|
279
|
+
mapper: AsyncIndexedMapper<BM, void>,
|
|
280
280
|
opt?: CommonDaoStreamForEachOptions<BM>,
|
|
281
281
|
): Promise<void> {
|
|
282
282
|
await this.dao.streamQueryForEach(this, mapper, opt)
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
async streamQueryAsDBMForEach(
|
|
286
|
-
mapper:
|
|
286
|
+
mapper: AsyncIndexedMapper<DBM, void>,
|
|
287
287
|
opt?: CommonDaoStreamForEachOptions<DBM>,
|
|
288
288
|
): Promise<void> {
|
|
289
289
|
await this.dao.streamQueryAsDBMForEach(this, mapper, opt)
|
|
@@ -306,7 +306,7 @@ export class RunnableDBQuery<
|
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
async streamQueryIdsForEach(
|
|
309
|
-
mapper:
|
|
309
|
+
mapper: AsyncIndexedMapper<ID, void>,
|
|
310
310
|
opt?: CommonDaoStreamForEachOptions<ID>,
|
|
311
311
|
): Promise<void> {
|
|
312
312
|
await this.dao.streamQueryIdsForEach(this, mapper, opt)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'node:stream'
|
|
2
2
|
import { _deepCopy, _filterObject, _omit, _pick, _sortBy, localTime } from '@naturalcycles/js-lib'
|
|
3
|
-
import { _pipeline } from '@naturalcycles/nodejs-lib'
|
|
3
|
+
import { _pipeline } from '@naturalcycles/nodejs-lib/stream'
|
|
4
4
|
import type { CommonDB } from '../common.db.js'
|
|
5
5
|
import { CommonDao } from '../commondao/common.dao.js'
|
|
6
6
|
import { CommonDaoLogLevel } from '../commondao/common.dao.model.js'
|
|
@@ -54,7 +54,7 @@ export async function runCommonKeyValueDBTest(db: CommonKeyValueDB): Promise<voi
|
|
|
54
54
|
await db.saveBatch(TEST_TABLE, testEntries)
|
|
55
55
|
|
|
56
56
|
const entries = await db.getByIds(TEST_TABLE, testIds)
|
|
57
|
-
_sortBy(entries, e => e[0], true)
|
|
57
|
+
_sortBy(entries, e => e[0], { mutate: true })
|
|
58
58
|
expect(entries).toEqual(testEntries)
|
|
59
59
|
})
|
|
60
60
|
|
|
@@ -54,7 +54,7 @@ export async function runCommonKeyValueDaoTest(db: CommonKeyValueDB): Promise<vo
|
|
|
54
54
|
const entries = await dao.getByIds(testIds)
|
|
55
55
|
// console.log(typeof entries[0]![1], entries[0]![1])
|
|
56
56
|
|
|
57
|
-
_sortBy(entries, e => e[0], true)
|
|
57
|
+
_sortBy(entries, e => e[0], { mutate: true })
|
|
58
58
|
expect(entries).toEqual(testEntries) // Jest doesn't allow to compare Buffers directly
|
|
59
59
|
// expect(entries.map(e => e[0])).toEqual(testEntries.map(e => e[0]))
|
|
60
60
|
// expect(entries.map(e => e[1].toString())).toEqual(testEntries.map(e => e[1].toString()))
|
package/src/validation/index.ts
CHANGED