@naturalcycles/db-lib 9.14.2 → 9.14.3
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/index.d.ts +1 -1
- package/dist/adapter/file/inMemory.persistence.plugin.d.ts +1 -1
- package/dist/adapter/inmemory/inMemory.db.d.ts +1 -1
- package/dist/commondao/common.dao.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/kv/commonKeyValueDaoMemoCache.js +1 -1
- package/dist/model.util.js +2 -2
- package/dist/pipeline/dbPipelineBackup.d.ts +1 -1
- package/dist/testing/daoTest.js +1 -1
- package/dist/testing/index.d.ts +3 -3
- package/dist/testing/index.js +2 -2
- package/package.json +1 -1
- package/src/adapter/cachedb/index.ts +1 -1
- package/src/adapter/file/file.db.ts +4 -4
- package/src/adapter/file/inMemory.persistence.plugin.ts +1 -1
- package/src/adapter/inmemory/inMemory.db.ts +11 -11
- package/src/commondao/common.dao.ts +2 -2
- package/src/index.ts +1 -1
- package/src/kv/commonKeyValueDaoMemoCache.ts +2 -2
- package/src/model.util.ts +3 -3
- package/src/pipeline/dbPipelineBackup.ts +8 -8
- package/src/pipeline/dbPipelineCopy.ts +7 -7
- package/src/pipeline/dbPipelineRestore.ts +10 -10
- package/src/query/dbQuery.ts +2 -2
- package/src/testing/daoTest.ts +5 -5
- package/src/testing/index.ts +9 -9
- package/src/testing/keyValueDaoTest.ts +1 -1
- package/src/testing/test.model.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CacheDB } from './cache.db';
|
|
2
2
|
import { CacheDBCfg, CacheDBCreateOptions, CacheDBOptions, CacheDBStreamOptions } from './cache.db.model';
|
|
3
|
-
export type { CacheDBCfg,
|
|
3
|
+
export type { CacheDBCfg, CacheDBCreateOptions, CacheDBOptions, CacheDBStreamOptions };
|
|
4
4
|
export { CacheDB };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CommonLogger, JsonSchemaObject, JsonSchemaRootObject, ObjectWithId, StringMap } from '@naturalcycles/js-lib';
|
|
2
2
|
import { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
3
3
|
import { CommonDB, CommonDBTransactionOptions, CommonDBType, DBOperation, DBPatch, DBTransactionFn } from '../..';
|
|
4
4
|
import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions, DBTransaction, RunQueryResult } from '../../db.model';
|
|
@@ -447,7 +447,7 @@ class CommonDao {
|
|
|
447
447
|
* "Returns", just to have a type of "Saved"
|
|
448
448
|
*/
|
|
449
449
|
assignIdCreatedUpdated(obj, opt = {}) {
|
|
450
|
-
const now =
|
|
450
|
+
const now = js_lib_1.localTime.nowUnix();
|
|
451
451
|
if (this.cfg.useCreatedProperty) {
|
|
452
452
|
obj.created ||= obj.updated || now;
|
|
453
453
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './commondao/common.dao';
|
|
|
7
7
|
export * from './commondao/common.dao.model';
|
|
8
8
|
export * from './db.model';
|
|
9
9
|
export * from './kv/commonKeyValueDao';
|
|
10
|
+
export * from './kv/commonKeyValueDaoMemoCache';
|
|
10
11
|
export * from './kv/commonKeyValueDB';
|
|
11
12
|
export * from './model.util';
|
|
12
13
|
export * from './pipeline/dbPipelineBackup';
|
|
@@ -14,4 +15,3 @@ export * from './pipeline/dbPipelineCopy';
|
|
|
14
15
|
export * from './pipeline/dbPipelineRestore';
|
|
15
16
|
export * from './query/dbQuery';
|
|
16
17
|
export * from './transaction/dbTransaction.util';
|
|
17
|
-
export * from './kv/commonKeyValueDaoMemoCache';
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ tslib_1.__exportStar(require("./commondao/common.dao"), exports);
|
|
|
10
10
|
tslib_1.__exportStar(require("./commondao/common.dao.model"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./db.model"), exports);
|
|
12
12
|
tslib_1.__exportStar(require("./kv/commonKeyValueDao"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./kv/commonKeyValueDaoMemoCache"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./kv/commonKeyValueDB"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./model.util"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./pipeline/dbPipelineBackup"), exports);
|
|
@@ -17,4 +18,3 @@ tslib_1.__exportStar(require("./pipeline/dbPipelineCopy"), exports);
|
|
|
17
18
|
tslib_1.__exportStar(require("./pipeline/dbPipelineRestore"), exports);
|
|
18
19
|
tslib_1.__exportStar(require("./query/dbQuery"), exports);
|
|
19
20
|
tslib_1.__exportStar(require("./transaction/dbTransaction.util"), exports);
|
|
20
|
-
tslib_1.__exportStar(require("./kv/commonKeyValueDaoMemoCache"), exports);
|
|
@@ -18,7 +18,7 @@ class CommonKeyValueDaoMemoCache {
|
|
|
18
18
|
return (await this.cfg.dao.getById(k)) || js_lib_1.MISS;
|
|
19
19
|
}
|
|
20
20
|
async set(k, v) {
|
|
21
|
-
const opt = this.cfg.ttl ? { expireAt:
|
|
21
|
+
const opt = this.cfg.ttl ? { expireAt: js_lib_1.localTime.nowUnix() + this.cfg.ttl } : undefined;
|
|
22
22
|
await this.cfg.dao.save(k, v, opt);
|
|
23
23
|
}
|
|
24
24
|
async clear() {
|
package/dist/model.util.js
CHANGED
|
@@ -7,14 +7,14 @@ exports.serializeJsonField = serializeJsonField;
|
|
|
7
7
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
8
8
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
9
9
|
function createdUpdatedFields(existingObject) {
|
|
10
|
-
const now =
|
|
10
|
+
const now = js_lib_1.localTime.nowUnix();
|
|
11
11
|
return {
|
|
12
12
|
created: existingObject?.created || now,
|
|
13
13
|
updated: now,
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
function createdUpdatedIdFields(existingObject) {
|
|
17
|
-
const now =
|
|
17
|
+
const now = js_lib_1.localTime.nowUnix();
|
|
18
18
|
return {
|
|
19
19
|
created: existingObject?.created || now,
|
|
20
20
|
id: existingObject?.id || (0, nodejs_lib_1.stringId)(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AsyncMapper, ErrorMode,
|
|
1
|
+
import { AsyncMapper, ErrorMode, StringMap, UnixTimestampNumber } from '@naturalcycles/js-lib';
|
|
2
2
|
import { NDJsonStats, TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib';
|
|
3
3
|
import { CommonDB } from '../common.db';
|
|
4
4
|
import { DBQuery } from '../index';
|
package/dist/testing/daoTest.js
CHANGED
|
@@ -186,7 +186,7 @@ function runCommonDaoTest(db, quirks = {}) {
|
|
|
186
186
|
// cleanup
|
|
187
187
|
await dao.query().deleteByQuery();
|
|
188
188
|
// Test that id, created, updated are created
|
|
189
|
-
const now =
|
|
189
|
+
const now = js_lib_1.localTime.nowUnix();
|
|
190
190
|
await dao.runInTransaction(async (tx) => {
|
|
191
191
|
const row = (0, js_lib_1._omit)(item1, ['id', 'created', 'updated']);
|
|
192
192
|
await tx.save(dao, row);
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runCommonDaoTest } from './daoTest';
|
|
2
2
|
import { CommonDBImplementationQuirks, runCommonDBTest } from './dbTest';
|
|
3
3
|
import { runCommonKeyValueDBTest } from './keyValueDBTest';
|
|
4
|
-
import { createTestItemBM, createTestItemDBM, createTestItemsBM, createTestItemsDBM, TestItemBM, testItemBMJsonSchema, testItemBMSchema, TestItemDBM, TestItemTM, testItemTMSchema
|
|
5
|
-
export type {
|
|
6
|
-
export {
|
|
4
|
+
import { createTestItemBM, createTestItemDBM, createTestItemsBM, createTestItemsDBM, TEST_TABLE, TestItemBM, testItemBMJsonSchema, testItemBMSchema, TestItemDBM, TestItemTM, testItemTMSchema } from './test.model';
|
|
5
|
+
export type { CommonDBImplementationQuirks, TestItemBM, TestItemDBM, TestItemTM };
|
|
6
|
+
export { createTestItemBM, createTestItemDBM, createTestItemsBM, createTestItemsDBM, runCommonDaoTest, runCommonDBTest, runCommonKeyValueDBTest, TEST_TABLE, testItemBMJsonSchema, testItemBMSchema, testItemTMSchema, };
|
package/dist/testing/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.testItemTMSchema = exports.testItemBMSchema = exports.testItemBMJsonSchema = exports.TEST_TABLE = exports.runCommonKeyValueDBTest = exports.runCommonDBTest = exports.runCommonDaoTest = exports.createTestItemsDBM = exports.createTestItemsBM = exports.createTestItemDBM = exports.createTestItemBM = void 0;
|
|
4
4
|
const daoTest_1 = require("./daoTest");
|
|
5
5
|
Object.defineProperty(exports, "runCommonDaoTest", { enumerable: true, get: function () { return daoTest_1.runCommonDaoTest; } });
|
|
6
6
|
const dbTest_1 = require("./dbTest");
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "createTestItemBM", { enumerable: true, get: func
|
|
|
12
12
|
Object.defineProperty(exports, "createTestItemDBM", { enumerable: true, get: function () { return test_model_1.createTestItemDBM; } });
|
|
13
13
|
Object.defineProperty(exports, "createTestItemsBM", { enumerable: true, get: function () { return test_model_1.createTestItemsBM; } });
|
|
14
14
|
Object.defineProperty(exports, "createTestItemsDBM", { enumerable: true, get: function () { return test_model_1.createTestItemsDBM; } });
|
|
15
|
+
Object.defineProperty(exports, "TEST_TABLE", { enumerable: true, get: function () { return test_model_1.TEST_TABLE; } });
|
|
15
16
|
Object.defineProperty(exports, "testItemBMJsonSchema", { enumerable: true, get: function () { return test_model_1.testItemBMJsonSchema; } });
|
|
16
17
|
Object.defineProperty(exports, "testItemBMSchema", { enumerable: true, get: function () { return test_model_1.testItemBMSchema; } });
|
|
17
18
|
Object.defineProperty(exports, "testItemTMSchema", { enumerable: true, get: function () { return test_model_1.testItemTMSchema; } });
|
|
18
|
-
Object.defineProperty(exports, "TEST_TABLE", { enumerable: true, get: function () { return test_model_1.TEST_TABLE; } });
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
_assert,
|
|
3
3
|
_by,
|
|
4
4
|
_deepEquals,
|
|
5
|
+
_filterUndefinedValues,
|
|
5
6
|
_since,
|
|
6
7
|
_sortBy,
|
|
7
8
|
_sortObjectDeep,
|
|
8
9
|
_stringMapValues,
|
|
10
|
+
generateJsonSchemaFromData,
|
|
9
11
|
JsonSchemaRootObject,
|
|
10
|
-
_filterUndefinedValues,
|
|
11
|
-
_assert,
|
|
12
12
|
ObjectWithId,
|
|
13
13
|
} from '@naturalcycles/js-lib'
|
|
14
|
-
import { readableCreate, ReadableTyped
|
|
14
|
+
import { dimGrey, readableCreate, ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
15
15
|
import {
|
|
16
16
|
BaseCommonDB,
|
|
17
17
|
commonDBFullSupport,
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { Readable } from 'node:stream'
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
JsonSchemaObject,
|
|
5
|
-
pMap,
|
|
6
|
-
StringMap,
|
|
3
|
+
_assert,
|
|
7
4
|
_by,
|
|
5
|
+
_deepCopy,
|
|
8
6
|
_since,
|
|
9
7
|
_sortObjectDeep,
|
|
10
|
-
JsonSchemaRootObject,
|
|
11
|
-
ObjectWithId,
|
|
12
8
|
_stringMapValues,
|
|
13
9
|
CommonLogger,
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
generateJsonSchemaFromData,
|
|
11
|
+
JsonSchemaObject,
|
|
12
|
+
JsonSchemaRootObject,
|
|
13
|
+
ObjectWithId,
|
|
14
|
+
pMap,
|
|
15
|
+
StringMap,
|
|
16
16
|
} from '@naturalcycles/js-lib'
|
|
17
17
|
import {
|
|
18
|
-
bufferReviver,
|
|
19
|
-
ReadableTyped,
|
|
20
18
|
_pipeline,
|
|
19
|
+
bufferReviver,
|
|
21
20
|
dimGrey,
|
|
22
|
-
yellow,
|
|
23
21
|
fs2,
|
|
22
|
+
ReadableTyped,
|
|
23
|
+
yellow,
|
|
24
24
|
} from '@naturalcycles/nodejs-lib'
|
|
25
25
|
import {
|
|
26
26
|
CommonDB,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
ErrorMode,
|
|
19
19
|
JsonSchemaObject,
|
|
20
20
|
JsonSchemaRootObject,
|
|
21
|
-
|
|
21
|
+
localTime,
|
|
22
22
|
ObjectWithId,
|
|
23
23
|
pMap,
|
|
24
24
|
SKIP,
|
|
@@ -605,7 +605,7 @@ export class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity = BM> {
|
|
|
605
605
|
* "Returns", just to have a type of "Saved"
|
|
606
606
|
*/
|
|
607
607
|
assignIdCreatedUpdated<T extends BaseDBEntity>(obj: Partial<T>, opt: CommonDaoOptions = {}): T {
|
|
608
|
-
const now = nowUnix()
|
|
608
|
+
const now = localTime.nowUnix()
|
|
609
609
|
|
|
610
610
|
if (this.cfg.useCreatedProperty) {
|
|
611
611
|
obj.created ||= obj.updated || now
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './commondao/common.dao'
|
|
|
7
7
|
export * from './commondao/common.dao.model'
|
|
8
8
|
export * from './db.model'
|
|
9
9
|
export * from './kv/commonKeyValueDao'
|
|
10
|
+
export * from './kv/commonKeyValueDaoMemoCache'
|
|
10
11
|
export * from './kv/commonKeyValueDB'
|
|
11
12
|
export * from './model.util'
|
|
12
13
|
export * from './pipeline/dbPipelineBackup'
|
|
@@ -14,4 +15,3 @@ export * from './pipeline/dbPipelineCopy'
|
|
|
14
15
|
export * from './pipeline/dbPipelineRestore'
|
|
15
16
|
export * from './query/dbQuery'
|
|
16
17
|
export * from './transaction/dbTransaction.util'
|
|
17
|
-
export * from './kv/commonKeyValueDaoMemoCache'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AsyncMemoCache,
|
|
1
|
+
import { AsyncMemoCache, localTime, MISS, NumberOfSeconds } from '@naturalcycles/js-lib'
|
|
2
2
|
import { CommonKeyValueDao } from './commonKeyValueDao'
|
|
3
3
|
|
|
4
4
|
export interface CommonKeyValueDaoMemoCacheCfg<VALUE> {
|
|
@@ -26,7 +26,7 @@ export class CommonKeyValueDaoMemoCache<VALUE = any> implements AsyncMemoCache<s
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
async set(k: string, v: VALUE): Promise<void> {
|
|
29
|
-
const opt = this.cfg.ttl ? { expireAt: nowUnix() + this.cfg.ttl } : undefined
|
|
29
|
+
const opt = this.cfg.ttl ? { expireAt: localTime.nowUnix() + this.cfg.ttl } : undefined
|
|
30
30
|
|
|
31
31
|
await this.cfg.dao.save(k, v, opt)
|
|
32
32
|
}
|
package/src/model.util.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CreatedUpdated, CreatedUpdatedId,
|
|
1
|
+
import { CreatedUpdated, CreatedUpdatedId, localTime } from '@naturalcycles/js-lib'
|
|
2
2
|
import { stringId } from '@naturalcycles/nodejs-lib'
|
|
3
3
|
|
|
4
4
|
export function createdUpdatedFields(
|
|
5
5
|
existingObject?: Partial<CreatedUpdated> | null,
|
|
6
6
|
): CreatedUpdated {
|
|
7
|
-
const now = nowUnix()
|
|
7
|
+
const now = localTime.nowUnix()
|
|
8
8
|
return {
|
|
9
9
|
created: existingObject?.created || now,
|
|
10
10
|
updated: now,
|
|
@@ -14,7 +14,7 @@ export function createdUpdatedFields(
|
|
|
14
14
|
export function createdUpdatedIdFields(
|
|
15
15
|
existingObject?: Partial<CreatedUpdatedId> | null,
|
|
16
16
|
): CreatedUpdatedId {
|
|
17
|
-
const now = nowUnix()
|
|
17
|
+
const now = localTime.nowUnix()
|
|
18
18
|
return {
|
|
19
19
|
created: existingObject?.created || now,
|
|
20
20
|
id: existingObject?.id || stringId(),
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
+
_passthroughMapper,
|
|
2
3
|
AppError,
|
|
3
4
|
AsyncMapper,
|
|
4
5
|
ErrorMode,
|
|
5
|
-
pMap,
|
|
6
|
-
_passthroughMapper,
|
|
7
6
|
localTime,
|
|
8
|
-
|
|
7
|
+
pMap,
|
|
9
8
|
StringMap,
|
|
9
|
+
UnixTimestampNumber,
|
|
10
10
|
} from '@naturalcycles/js-lib'
|
|
11
11
|
import {
|
|
12
|
+
_pipeline,
|
|
13
|
+
boldWhite,
|
|
14
|
+
dimWhite,
|
|
15
|
+
fs2,
|
|
16
|
+
grey,
|
|
12
17
|
NDJsonStats,
|
|
13
18
|
transformLogProgress,
|
|
14
19
|
TransformLogProgressOptions,
|
|
15
20
|
transformMap,
|
|
16
21
|
TransformMapOptions,
|
|
17
22
|
transformTap,
|
|
18
|
-
_pipeline,
|
|
19
|
-
boldWhite,
|
|
20
|
-
dimWhite,
|
|
21
|
-
grey,
|
|
22
23
|
yellow,
|
|
23
|
-
fs2,
|
|
24
24
|
} from '@naturalcycles/nodejs-lib'
|
|
25
25
|
import { CommonDB } from '../common.db'
|
|
26
26
|
import { DBQuery } from '../index'
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
_passthroughMapper,
|
|
2
3
|
AsyncMapper,
|
|
4
|
+
BaseDBEntity,
|
|
3
5
|
ErrorMode,
|
|
4
|
-
pMap,
|
|
5
|
-
_passthroughMapper,
|
|
6
6
|
localTime,
|
|
7
|
-
|
|
7
|
+
pMap,
|
|
8
8
|
} from '@naturalcycles/js-lib'
|
|
9
9
|
import {
|
|
10
|
+
_pipeline,
|
|
11
|
+
boldWhite,
|
|
12
|
+
dimWhite,
|
|
13
|
+
grey,
|
|
10
14
|
NDJsonStats,
|
|
11
15
|
transformChunk,
|
|
12
16
|
transformLogProgress,
|
|
@@ -15,10 +19,6 @@ import {
|
|
|
15
19
|
TransformMapOptions,
|
|
16
20
|
transformTap,
|
|
17
21
|
writableForEach,
|
|
18
|
-
_pipeline,
|
|
19
|
-
boldWhite,
|
|
20
|
-
dimWhite,
|
|
21
|
-
grey,
|
|
22
22
|
yellow,
|
|
23
23
|
} from '@naturalcycles/nodejs-lib'
|
|
24
24
|
import { CommonDB } from '../common.db'
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AsyncMapper,
|
|
3
|
-
ErrorMode,
|
|
4
|
-
pMap,
|
|
5
2
|
_hb,
|
|
6
3
|
_mapValues,
|
|
7
4
|
_passthroughMapper,
|
|
8
|
-
|
|
9
|
-
JsonSchemaObject,
|
|
5
|
+
AsyncMapper,
|
|
10
6
|
BaseDBEntity,
|
|
7
|
+
ErrorMode,
|
|
8
|
+
JsonSchemaObject,
|
|
9
|
+
localTime,
|
|
10
|
+
pMap,
|
|
11
11
|
} from '@naturalcycles/js-lib'
|
|
12
12
|
import {
|
|
13
|
+
_pipeline,
|
|
14
|
+
boldWhite,
|
|
15
|
+
dimWhite,
|
|
16
|
+
fs2,
|
|
17
|
+
grey,
|
|
13
18
|
NDJsonStats,
|
|
14
19
|
transformChunk,
|
|
15
20
|
transformFilterSync,
|
|
@@ -19,12 +24,7 @@ import {
|
|
|
19
24
|
TransformMapOptions,
|
|
20
25
|
transformTap,
|
|
21
26
|
writableForEach,
|
|
22
|
-
_pipeline,
|
|
23
|
-
boldWhite,
|
|
24
|
-
dimWhite,
|
|
25
|
-
grey,
|
|
26
27
|
yellow,
|
|
27
|
-
fs2,
|
|
28
28
|
} from '@naturalcycles/nodejs-lib'
|
|
29
29
|
import { CommonDB } from '../common.db'
|
|
30
30
|
import { CommonDBSaveOptions } from '../index'
|
package/src/query/dbQuery.ts
CHANGED
package/src/testing/daoTest.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Readable } from 'node:stream'
|
|
2
|
-
import { _deepCopy, _pick, _sortBy,
|
|
2
|
+
import { _deepCopy, _omit, _pick, _sortBy, localTime } from '@naturalcycles/js-lib'
|
|
3
3
|
import { _pipeline } from '@naturalcycles/nodejs-lib'
|
|
4
4
|
import { CommonDaoLogLevel, DBQuery } from '..'
|
|
5
5
|
import { CommonDB } from '../common.db'
|
|
6
6
|
import { CommonDao } from '../commondao/common.dao'
|
|
7
|
+
import { TestItemBM } from '.'
|
|
7
8
|
import { CommonDBImplementationQuirks, expectMatch } from './dbTest'
|
|
8
9
|
import {
|
|
10
|
+
createTestItemBM,
|
|
9
11
|
createTestItemsBM,
|
|
10
|
-
testItemBMSchema,
|
|
11
12
|
TEST_TABLE,
|
|
12
|
-
createTestItemBM,
|
|
13
13
|
testItemBMJsonSchema,
|
|
14
|
+
testItemBMSchema,
|
|
14
15
|
} from './test.model'
|
|
15
|
-
import { TestItemBM } from '.'
|
|
16
16
|
|
|
17
17
|
export function runCommonDaoTest(db: CommonDB, quirks: CommonDBImplementationQuirks = {}): void {
|
|
18
18
|
const { support } = db
|
|
@@ -255,7 +255,7 @@ export function runCommonDaoTest(db: CommonDB, quirks: CommonDBImplementationQui
|
|
|
255
255
|
await dao.query().deleteByQuery()
|
|
256
256
|
|
|
257
257
|
// Test that id, created, updated are created
|
|
258
|
-
const now = nowUnix()
|
|
258
|
+
const now = localTime.nowUnix()
|
|
259
259
|
|
|
260
260
|
await dao.runInTransaction(async tx => {
|
|
261
261
|
const row = _omit(item1, ['id', 'created', 'updated'])
|
package/src/testing/index.ts
CHANGED
|
@@ -6,27 +6,27 @@ import {
|
|
|
6
6
|
createTestItemDBM,
|
|
7
7
|
createTestItemsBM,
|
|
8
8
|
createTestItemsDBM,
|
|
9
|
+
TEST_TABLE,
|
|
9
10
|
TestItemBM,
|
|
10
11
|
testItemBMJsonSchema,
|
|
11
12
|
testItemBMSchema,
|
|
12
13
|
TestItemDBM,
|
|
13
14
|
TestItemTM,
|
|
14
15
|
testItemTMSchema,
|
|
15
|
-
TEST_TABLE,
|
|
16
16
|
} from './test.model'
|
|
17
17
|
|
|
18
|
-
export type {
|
|
18
|
+
export type { CommonDBImplementationQuirks, TestItemBM, TestItemDBM, TestItemTM }
|
|
19
19
|
|
|
20
20
|
export {
|
|
21
|
-
TEST_TABLE,
|
|
22
|
-
createTestItemDBM,
|
|
23
21
|
createTestItemBM,
|
|
24
|
-
|
|
22
|
+
createTestItemDBM,
|
|
25
23
|
createTestItemsBM,
|
|
26
|
-
|
|
27
|
-
testItemTMSchema,
|
|
28
|
-
testItemBMJsonSchema,
|
|
29
|
-
runCommonDBTest,
|
|
24
|
+
createTestItemsDBM,
|
|
30
25
|
runCommonDaoTest,
|
|
26
|
+
runCommonDBTest,
|
|
31
27
|
runCommonKeyValueDBTest,
|
|
28
|
+
TEST_TABLE,
|
|
29
|
+
testItemBMJsonSchema,
|
|
30
|
+
testItemBMSchema,
|
|
31
|
+
testItemTMSchema,
|
|
32
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _range, _sortBy } from '@naturalcycles/js-lib'
|
|
2
|
-
import { KeyValueDBTuple } from '../kv/commonKeyValueDB'
|
|
3
2
|
import { CommonKeyValueDao } from '../kv/commonKeyValueDao'
|
|
3
|
+
import { KeyValueDBTuple } from '../kv/commonKeyValueDB'
|
|
4
4
|
|
|
5
5
|
const testIds = _range(1, 4).map(n => `id${n}`)
|
|
6
6
|
const testEntries: KeyValueDBTuple[] = testIds.map(id => [id, Buffer.from(`${id}value`)])
|