@naturalcycles/db-lib
Advanced tools
Comparing version 8.21.3 to 8.22.0
@@ -0,1 +1,8 @@ | ||
# [8.22.0](https://github.com/NaturalCycles/db-lib/compare/v8.21.3...v8.22.0) (2021-10-19) | ||
### Features | ||
* CommonDaoCfg.filterNullishValues b/w compat option ([fb7f786](https://github.com/NaturalCycles/db-lib/commit/fb7f786414a8431d6e48b43b6343445fa6a3a016)) | ||
## [8.21.3](https://github.com/NaturalCycles/db-lib/compare/v8.21.2...v8.21.3) (2021-10-18) | ||
@@ -2,0 +9,0 @@ |
/// <reference types="node" /> | ||
import { Readable } from 'stream'; | ||
import { JsonSchemaObject, JsonSchemaRootObject } from '@naturalcycles/js-lib'; | ||
import { JsonSchemaObject, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { IDebugger } from '@naturalcycles/nodejs-lib'; | ||
import { BaseCommonDB } from '../../base.common.db'; | ||
import { CommonDB } from '../../common.db'; | ||
import { ObjectWithId, RunQueryResult } from '../../db.model'; | ||
import { RunQueryResult } from '../../db.model'; | ||
import { DBQuery } from '../../query/dbQuery'; | ||
@@ -9,0 +9,0 @@ import { CacheDBCfg, CacheDBCreateOptions, CacheDBOptions, CacheDBStreamOptions } from './cache.db.model'; |
@@ -0,3 +1,4 @@ | ||
import { ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { CommonDB } from '../../common.db'; | ||
import { CommonDBCreateOptions, CommonDBSaveOptions, CommonDBStreamOptions, ObjectWithId } from '../../db.model'; | ||
import { CommonDBCreateOptions, CommonDBSaveOptions, CommonDBStreamOptions } from '../../db.model'; | ||
export interface CacheDBCfg { | ||
@@ -4,0 +5,0 @@ name: string; |
@@ -1,4 +0,4 @@ | ||
import { JsonSchemaRootObject } from '@naturalcycles/js-lib'; | ||
import { JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { ReadableTyped } from '@naturalcycles/nodejs-lib'; | ||
import { BaseCommonDB, DBSaveBatchOperation, ObjectWithId } from '../..'; | ||
import { BaseCommonDB, DBSaveBatchOperation } from '../..'; | ||
import { CommonDB } from '../../common.db'; | ||
@@ -5,0 +5,0 @@ import { CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, RunQueryResult } from '../../db.model'; |
@@ -1,2 +0,3 @@ | ||
import { DBSaveBatchOperation, ObjectWithId } from '../../db.model'; | ||
import { ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { DBSaveBatchOperation } from '../../db.model'; | ||
import type { DBQueryOrder } from '../../query/dbQuery'; | ||
@@ -3,0 +4,0 @@ export interface FileDBPersistencePlugin { |
@@ -1,3 +0,3 @@ | ||
import { StringMap } from '@naturalcycles/js-lib'; | ||
import { DBSaveBatchOperation, ObjectWithId } from '../../db.model'; | ||
import { StringMap, ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { DBSaveBatchOperation } from '../../db.model'; | ||
import { FileDBPersistencePlugin } from './file.db.model'; | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,2 +0,3 @@ | ||
import { DBSaveBatchOperation, ObjectWithId } from '../../db.model'; | ||
import { ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { DBSaveBatchOperation } from '../../db.model'; | ||
import { FileDBPersistencePlugin } from './file.db.model'; | ||
@@ -3,0 +4,0 @@ export interface LocalFilePersistencePluginCfg { |
@@ -1,2 +0,3 @@ | ||
import { DBSaveBatchOperation, ObjectWithId } from '../../db.model'; | ||
import { ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { DBSaveBatchOperation } from '../../db.model'; | ||
import { FileDBPersistencePlugin } from './file.db.model'; | ||
@@ -3,0 +4,0 @@ export declare class NoopPersistencePlugin implements FileDBPersistencePlugin { |
@@ -1,4 +0,4 @@ | ||
import { JsonSchemaObject, StringMap, JsonSchemaRootObject } from '@naturalcycles/js-lib'; | ||
import { JsonSchemaObject, StringMap, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { ReadableTyped } from '@naturalcycles/nodejs-lib'; | ||
import { CommonDB, DBTransaction, ObjectWithId } from '../..'; | ||
import { CommonDB, DBTransaction } from '../..'; | ||
import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions, RunQueryResult } from '../../db.model'; | ||
@@ -5,0 +5,0 @@ import { DBQuery } from '../../query/dbQuery'; |
@@ -1,3 +0,3 @@ | ||
import { ObjectWithId } from '../../db.model'; | ||
import { ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { DBQuery } from '../../query/dbQuery'; | ||
export declare function queryInMemory<ROW extends ObjectWithId>(q: DBQuery<ROW>, rows?: ROW[]): ROW[]; |
@@ -1,5 +0,5 @@ | ||
import { JsonSchemaObject, JsonSchemaRootObject } from '@naturalcycles/js-lib'; | ||
import { JsonSchemaObject, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { ReadableTyped } from '@naturalcycles/nodejs-lib'; | ||
import { CommonDB } from './common.db'; | ||
import { CommonDBOptions, CommonDBSaveOptions, ObjectWithId, RunQueryResult } from './db.model'; | ||
import { CommonDBOptions, CommonDBSaveOptions, RunQueryResult } from './db.model'; | ||
import { DBQuery } from './query/dbQuery'; | ||
@@ -6,0 +6,0 @@ import { DBTransaction } from './transaction/dbTransaction'; |
@@ -1,4 +0,4 @@ | ||
import { JsonSchemaObject, JsonSchemaRootObject } from '@naturalcycles/js-lib'; | ||
import { JsonSchemaObject, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { ReadableTyped } from '@naturalcycles/nodejs-lib'; | ||
import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, ObjectWithId, RunQueryResult } from './db.model'; | ||
import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, RunQueryResult } from './db.model'; | ||
import { DBQuery } from './query/dbQuery'; | ||
@@ -5,0 +5,0 @@ import { DBTransaction } from './transaction/dbTransaction'; |
@@ -1,4 +0,4 @@ | ||
import { AsyncMapper, JsonSchemaObject, JsonSchemaRootObject, Saved } from '@naturalcycles/js-lib'; | ||
import { AsyncMapper, JsonSchemaObject, JsonSchemaRootObject, Saved, ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { AjvSchema, ObjectSchemaTyped, ReadableTyped } from '@naturalcycles/nodejs-lib'; | ||
import { DBModelType, ObjectWithId, RunQueryResult } from '../db.model'; | ||
import { DBModelType, RunQueryResult } from '../db.model'; | ||
import { DBQuery, RunnableDBQuery } from '../query/dbQuery'; | ||
@@ -5,0 +5,0 @@ import { CommonDaoCfg, CommonDaoCreateOptions, CommonDaoOptions, CommonDaoSaveOptions, CommonDaoStreamForEachOptions, CommonDaoStreamOptions } from './common.dao.model'; |
@@ -651,3 +651,8 @@ "use strict"; | ||
// and they can be annoying with snapshot tests | ||
obj = (0, js_lib_1._filterUndefinedValues)(obj); | ||
if (this.cfg.filterNullishValues) { | ||
obj = (0, js_lib_1._filterNullishValues)(obj); | ||
} | ||
else { | ||
obj = (0, js_lib_1._filterUndefinedValues)(obj); | ||
} | ||
// Pre-validation hooks | ||
@@ -654,0 +659,0 @@ if (modelType === db_model_1.DBModelType.DBM) { |
@@ -1,5 +0,5 @@ | ||
import { ErrorMode } from '@naturalcycles/js-lib'; | ||
import { ErrorMode, ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { AjvSchema, AjvValidationError, JoiValidationError, ObjectSchemaTyped, TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib'; | ||
import { CommonDB } from '../common.db'; | ||
import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions, ObjectWithId } from '../db.model'; | ||
import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model'; | ||
export declare type CommonDaoCreateIdHook<BM, DBM> = (obj: DBM | BM) => string; | ||
@@ -70,2 +70,12 @@ export declare type CommonDaoParseNaturalIdHook<DBM> = (id: string) => Partial<DBM>; | ||
createdUpdated?: boolean; | ||
/** | ||
* Default is false. | ||
* If true - will run `_filterNullishValues` inside `validateAndConvert` function | ||
* (instead of `_filterUndefinedValues`). | ||
* This was the old db-lib behavior. | ||
* This option allows to keep backwards-compatible behavior. | ||
* | ||
* @deprecated | ||
*/ | ||
filterNullishValues?: boolean; | ||
} | ||
@@ -72,0 +82,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { AnyObject } from '@naturalcycles/js-lib'; | ||
import { AnyObjectWithId, ObjectWithId } from '@naturalcycles/js-lib'; | ||
import { CommonDB } from './common.db'; | ||
@@ -43,14 +43,2 @@ export interface CommonDBOptions { | ||
} | ||
export interface CreatedUpdated { | ||
created: number; | ||
updated: number; | ||
} | ||
export interface CreatedUpdatedId extends CreatedUpdated { | ||
id: string; | ||
} | ||
export interface ObjectWithId { | ||
id: string; | ||
} | ||
export interface AnyObjectWithId extends AnyObject, ObjectWithId { | ||
} | ||
/** | ||
@@ -57,0 +45,0 @@ * Interface for a module (lib) that implements CommonDB. |
@@ -9,7 +9,7 @@ import { InMemoryDB, InMemoryDBCfg } from './adapter/inmemory/inMemory.db'; | ||
import { CommonDaoAnonymizeHook, CommonDaoBeforeBMToDBMHook, CommonDaoBeforeBMToTMHook, CommonDaoBeforeCreateHook, CommonDaoBeforeDBMToBMHook, CommonDaoBeforeDBMValidateHook, CommonDaoBeforeTMToBMHook, CommonDaoCfg, CommonDaoCreateIdHook, CommonDaoCreateOptions, CommonDaoLogLevel, CommonDaoOptions, CommonDaoParseNaturalIdHook, CommonDaoSaveOptions, CommonDaoStreamForEachOptions, CommonDaoStreamOptions } from './commondao/common.dao.model'; | ||
import { AnyObjectWithId, CommonDBAdapter, CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, CreatedUpdated, CreatedUpdatedId, DBDeleteByIdsOperation, DBModelType, DBOperation, DBRelation, DBSaveBatchOperation, ObjectWithId, RunQueryResult } from './db.model'; | ||
import { CommonDBAdapter, CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, DBDeleteByIdsOperation, DBModelType, DBOperation, DBRelation, DBSaveBatchOperation, RunQueryResult } from './db.model'; | ||
import { getDB } from './getDB'; | ||
import { CommonKeyValueDao, CommonKeyValueDaoCfg } from './kv/commonKeyValueDao'; | ||
import { CommonKeyValueDB, KeyValueDBTuple } from './kv/commonKeyValueDB'; | ||
import { createdUpdatedFields, createdUpdatedIdFields, deserializeJsonField, idField, serializeJsonField } from './model.util'; | ||
import { createdUpdatedFields, createdUpdatedIdFields, deserializeJsonField, serializeJsonField } from './model.util'; | ||
import { dbPipelineBackup, DBPipelineBackupOptions } from './pipeline/dbPipelineBackup'; | ||
@@ -21,3 +21,3 @@ import { dbPipelineCopy, DBPipelineCopyOptions } from './pipeline/dbPipelineCopy'; | ||
import { commitDBTransactionSimple, mergeDBOperations } from './transaction/dbTransaction.util'; | ||
export type { DBQueryFilterOperator, DBQueryFilter, DBQueryOrder, CommonDaoCreateOptions, CommonDaoOptions, CommonDaoSaveOptions, CommonDaoStreamForEachOptions, CommonDaoStreamOptions, CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, CommonDBCreateOptions, CommonDB, RunQueryResult, CreatedUpdated, CreatedUpdatedId, AnyObjectWithId, ObjectWithId, CommonDaoCfg, CommonDaoCreateIdHook, CommonDaoParseNaturalIdHook, CommonDaoBeforeCreateHook, CommonDaoBeforeDBMValidateHook, CommonDaoBeforeDBMToBMHook, CommonDaoBeforeBMToDBMHook, CommonDaoBeforeTMToBMHook, CommonDaoBeforeBMToTMHook, CommonDaoAnonymizeHook, InMemoryDBCfg, InMemoryKeyValueDBCfg, DBPipelineBackupOptions, DBPipelineRestoreOptions, DBPipelineCopyOptions, CommonDBAdapter, DBOperation, DBSaveBatchOperation, DBDeleteByIdsOperation, CommonKeyValueDB, CommonKeyValueDaoCfg, KeyValueDBTuple, }; | ||
export { DBQuery, dbQueryFilterOperatorValues, RunnableDBQuery, CommonDaoLogLevel, DBRelation, DBModelType, CommonDao, createdUpdatedFields, createdUpdatedIdFields, idField, InMemoryDB, InMemoryKeyValueDB, queryInMemory, serializeJsonField, deserializeJsonField, dbPipelineBackup, dbPipelineRestore, dbPipelineCopy, getDB, DBLibError, BaseCommonDB, DBTransaction, RunnableDBTransaction, mergeDBOperations, commitDBTransactionSimple, CommonKeyValueDao, }; | ||
export type { DBQueryFilterOperator, DBQueryFilter, DBQueryOrder, CommonDaoCreateOptions, CommonDaoOptions, CommonDaoSaveOptions, CommonDaoStreamForEachOptions, CommonDaoStreamOptions, CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, CommonDBCreateOptions, CommonDB, RunQueryResult, CommonDaoCfg, CommonDaoCreateIdHook, CommonDaoParseNaturalIdHook, CommonDaoBeforeCreateHook, CommonDaoBeforeDBMValidateHook, CommonDaoBeforeDBMToBMHook, CommonDaoBeforeBMToDBMHook, CommonDaoBeforeTMToBMHook, CommonDaoBeforeBMToTMHook, CommonDaoAnonymizeHook, InMemoryDBCfg, InMemoryKeyValueDBCfg, DBPipelineBackupOptions, DBPipelineRestoreOptions, DBPipelineCopyOptions, CommonDBAdapter, DBOperation, DBSaveBatchOperation, DBDeleteByIdsOperation, CommonKeyValueDB, CommonKeyValueDaoCfg, KeyValueDBTuple, }; | ||
export { DBQuery, dbQueryFilterOperatorValues, RunnableDBQuery, CommonDaoLogLevel, DBRelation, DBModelType, CommonDao, createdUpdatedFields, createdUpdatedIdFields, InMemoryDB, InMemoryKeyValueDB, queryInMemory, serializeJsonField, deserializeJsonField, dbPipelineBackup, dbPipelineRestore, dbPipelineCopy, getDB, DBLibError, BaseCommonDB, DBTransaction, RunnableDBTransaction, mergeDBOperations, commitDBTransactionSimple, CommonKeyValueDao, }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CommonKeyValueDao = exports.commitDBTransactionSimple = exports.mergeDBOperations = exports.RunnableDBTransaction = exports.DBTransaction = exports.BaseCommonDB = exports.DBLibError = exports.getDB = exports.dbPipelineCopy = exports.dbPipelineRestore = exports.dbPipelineBackup = exports.deserializeJsonField = exports.serializeJsonField = exports.queryInMemory = exports.InMemoryKeyValueDB = exports.InMemoryDB = exports.idField = exports.createdUpdatedIdFields = exports.createdUpdatedFields = exports.CommonDao = exports.DBModelType = exports.DBRelation = exports.CommonDaoLogLevel = exports.RunnableDBQuery = exports.dbQueryFilterOperatorValues = exports.DBQuery = void 0; | ||
exports.CommonKeyValueDao = exports.commitDBTransactionSimple = exports.mergeDBOperations = exports.RunnableDBTransaction = exports.DBTransaction = exports.BaseCommonDB = exports.DBLibError = exports.getDB = exports.dbPipelineCopy = exports.dbPipelineRestore = exports.dbPipelineBackup = exports.deserializeJsonField = exports.serializeJsonField = exports.queryInMemory = exports.InMemoryKeyValueDB = exports.InMemoryDB = exports.createdUpdatedIdFields = exports.createdUpdatedFields = exports.CommonDao = exports.DBModelType = exports.DBRelation = exports.CommonDaoLogLevel = exports.RunnableDBQuery = exports.dbQueryFilterOperatorValues = exports.DBQuery = void 0; | ||
const inMemory_db_1 = require("./adapter/inmemory/inMemory.db"); | ||
@@ -29,3 +29,2 @@ Object.defineProperty(exports, "InMemoryDB", { enumerable: true, get: function () { return inMemory_db_1.InMemoryDB; } }); | ||
Object.defineProperty(exports, "deserializeJsonField", { enumerable: true, get: function () { return model_util_1.deserializeJsonField; } }); | ||
Object.defineProperty(exports, "idField", { enumerable: true, get: function () { return model_util_1.idField; } }); | ||
Object.defineProperty(exports, "serializeJsonField", { enumerable: true, get: function () { return model_util_1.serializeJsonField; } }); | ||
@@ -32,0 +31,0 @@ const dbPipelineBackup_1 = require("./pipeline/dbPipelineBackup"); |
@@ -1,2 +0,2 @@ | ||
import { CreatedUpdated, CreatedUpdatedId, ObjectWithId } from './db.model'; | ||
import { CreatedUpdated, CreatedUpdatedId, ObjectWithId } from '@naturalcycles/js-lib'; | ||
export declare function createdUpdatedFields(existingObject?: Partial<CreatedUpdated> | null): CreatedUpdated; | ||
@@ -3,0 +3,0 @@ export declare function createdUpdatedIdFields(existingObject?: Partial<CreatedUpdatedId> | null): CreatedUpdatedId; |
@@ -1,6 +0,6 @@ | ||
import { AsyncMapper, Saved } from '@naturalcycles/js-lib'; | ||
import { AnyObjectWithId, ObjectWithId, AsyncMapper, Saved } from '@naturalcycles/js-lib'; | ||
import { ReadableTyped } from '@naturalcycles/nodejs-lib'; | ||
import { CommonDaoOptions, CommonDaoStreamForEachOptions, CommonDaoStreamOptions } from '..'; | ||
import { CommonDao } from '../commondao/common.dao'; | ||
import { AnyObjectWithId, ObjectWithId, RunQueryResult } from '../db.model'; | ||
import { RunQueryResult } from '../db.model'; | ||
/** | ||
@@ -7,0 +7,0 @@ * Modeled after Firestore operators (WhereFilterOp type) |
@@ -0,3 +1,4 @@ | ||
import { AnyObjectWithId, ObjectWithId } from '@naturalcycles/js-lib'; | ||
import type { CommonDB } from '../common.db'; | ||
import type { AnyObjectWithId, CommonDBSaveOptions, DBOperation, ObjectWithId } from '../db.model'; | ||
import type { CommonDBSaveOptions, DBOperation } from '../db.model'; | ||
/** | ||
@@ -4,0 +5,0 @@ * Convenience class that stores the list of DBOperations and provides a fluent API to add them. |
import { CommonDBOptions, CommonDBSaveOptions } from '../db.model'; | ||
import { DBQuery, DBQueryFilter, DBQueryOrder } from '../query/dbQuery'; | ||
export declare const commonDBOptionsSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<CommonDBOptions, CommonDBOptions>; | ||
export declare const commonDBSaveOptionsSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<CommonDBSaveOptions<import("../db.model").AnyObjectWithId>, CommonDBSaveOptions<import("../db.model").AnyObjectWithId>>; | ||
export declare const commonDBSaveOptionsSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<CommonDBSaveOptions<import("@naturalcycles/js-lib").AnyObjectWithId>, CommonDBSaveOptions<import("@naturalcycles/js-lib").AnyObjectWithId>>; | ||
export declare const dbQueryFilterOperatorSchema: import("@naturalcycles/nodejs-lib/dist/validation/joi/string.extensions").ExtendedStringSchema; | ||
export declare const dbQueryFilterSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<DBQueryFilter<import("../db.model").AnyObjectWithId>, DBQueryFilter<import("../db.model").AnyObjectWithId>>; | ||
export declare const dbQueryOrderSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<DBQueryOrder<import("../db.model").AnyObjectWithId>, DBQueryOrder<import("../db.model").AnyObjectWithId>>; | ||
export declare const dbQueryFilterSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<DBQueryFilter<import("@naturalcycles/js-lib").AnyObjectWithId>, DBQueryFilter<import("@naturalcycles/js-lib").AnyObjectWithId>>; | ||
export declare const dbQueryOrderSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<DBQueryOrder<import("@naturalcycles/js-lib").AnyObjectWithId>, DBQueryOrder<import("@naturalcycles/js-lib").AnyObjectWithId>>; | ||
export declare const dbQuerySchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<DBQuery<any>, DBQuery<any>>; |
@@ -45,3 +45,3 @@ { | ||
}, | ||
"version": "8.21.3", | ||
"version": "8.22.0", | ||
"description": "Lowest Common Denominator API to supported Databases", | ||
@@ -48,0 +48,0 @@ "keywords": [ |
@@ -0,8 +1,4 @@ | ||
import { ObjectWithId } from '@naturalcycles/js-lib' | ||
import { CommonDB } from '../../common.db' | ||
import { | ||
CommonDBCreateOptions, | ||
CommonDBSaveOptions, | ||
CommonDBStreamOptions, | ||
ObjectWithId, | ||
} from '../../db.model' | ||
import { CommonDBCreateOptions, CommonDBSaveOptions, CommonDBStreamOptions } from '../../db.model' | ||
@@ -9,0 +5,0 @@ export interface CacheDBCfg { |
import { Readable } from 'stream' | ||
import { JsonSchemaObject, JsonSchemaRootObject } from '@naturalcycles/js-lib' | ||
import { JsonSchemaObject, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib' | ||
import { Debug, IDebugger } from '@naturalcycles/nodejs-lib' | ||
import { BaseCommonDB } from '../../base.common.db' | ||
import { CommonDB } from '../../common.db' | ||
import { ObjectWithId, RunQueryResult } from '../../db.model' | ||
import { RunQueryResult } from '../../db.model' | ||
import { DBQuery } from '../../query/dbQuery' | ||
@@ -8,0 +8,0 @@ import { |
@@ -1,2 +0,3 @@ | ||
import { DBSaveBatchOperation, ObjectWithId } from '../../db.model' | ||
import { ObjectWithId } from '@naturalcycles/js-lib' | ||
import { DBSaveBatchOperation } from '../../db.model' | ||
import type { DBQueryOrder } from '../../query/dbQuery' | ||
@@ -3,0 +4,0 @@ |
@@ -14,12 +14,8 @@ import { | ||
_filterUndefinedValues, | ||
ObjectWithId, | ||
AnyObjectWithId, | ||
} from '@naturalcycles/js-lib' | ||
import { Debug, readableCreate, ReadableTyped } from '@naturalcycles/nodejs-lib' | ||
import { dimGrey } from '@naturalcycles/nodejs-lib/dist/colors' | ||
import { | ||
AnyObjectWithId, | ||
BaseCommonDB, | ||
DBSaveBatchOperation, | ||
ObjectWithId, | ||
queryInMemory, | ||
} from '../..' | ||
import { BaseCommonDB, DBSaveBatchOperation, queryInMemory } from '../..' | ||
import { CommonDB } from '../../common.db' | ||
@@ -26,0 +22,0 @@ import { |
@@ -1,3 +0,3 @@ | ||
import { StringMap, _by } from '@naturalcycles/js-lib' | ||
import { DBSaveBatchOperation, ObjectWithId } from '../../db.model' | ||
import { StringMap, _by, ObjectWithId } from '@naturalcycles/js-lib' | ||
import { DBSaveBatchOperation } from '../../db.model' | ||
import { FileDBPersistencePlugin } from './file.db.model' | ||
@@ -4,0 +4,0 @@ |
import { Readable } from 'stream' | ||
import { createGzip, createUnzip } from 'zlib' | ||
import { pMap } from '@naturalcycles/js-lib' | ||
import { pMap, ObjectWithId } from '@naturalcycles/js-lib' | ||
import { | ||
@@ -12,3 +12,3 @@ transformJsonParse, | ||
import * as fs from 'fs-extra' | ||
import { DBSaveBatchOperation, ObjectWithId } from '../../db.model' | ||
import { DBSaveBatchOperation } from '../../db.model' | ||
import { FileDBPersistencePlugin } from './file.db.model' | ||
@@ -15,0 +15,0 @@ |
@@ -1,2 +0,3 @@ | ||
import { DBSaveBatchOperation, ObjectWithId } from '../../db.model' | ||
import { ObjectWithId } from '@naturalcycles/js-lib' | ||
import { DBSaveBatchOperation } from '../../db.model' | ||
import { FileDBPersistencePlugin } from './file.db.model' | ||
@@ -3,0 +4,0 @@ |
@@ -12,2 +12,3 @@ import { Readable } from 'stream' | ||
JsonSchemaRootObject, | ||
ObjectWithId, | ||
} from '@naturalcycles/js-lib' | ||
@@ -26,3 +27,3 @@ import { | ||
import * as fs from 'fs-extra' | ||
import { CommonDB, DBTransaction, ObjectWithId, queryInMemory } from '../..' | ||
import { CommonDB, DBTransaction, queryInMemory } from '../..' | ||
import { | ||
@@ -29,0 +30,0 @@ CommonDBCreateOptions, |
@@ -1,3 +0,2 @@ | ||
import { _pick } from '@naturalcycles/js-lib' | ||
import { ObjectWithId } from '../../db.model' | ||
import { _pick, ObjectWithId } from '@naturalcycles/js-lib' | ||
import { DBQuery, DBQueryFilterOperator } from '../../query/dbQuery' | ||
@@ -4,0 +3,0 @@ |
import { Readable } from 'stream' | ||
import { JsonSchemaObject, JsonSchemaRootObject } from '@naturalcycles/js-lib' | ||
import { JsonSchemaObject, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib' | ||
import { ReadableTyped } from '@naturalcycles/nodejs-lib' | ||
import { CommonDB } from './common.db' | ||
import { CommonDBOptions, CommonDBSaveOptions, ObjectWithId, RunQueryResult } from './db.model' | ||
import { CommonDBOptions, CommonDBSaveOptions, RunQueryResult } from './db.model' | ||
import { DBQuery } from './query/dbQuery' | ||
@@ -7,0 +7,0 @@ import { DBTransaction } from './transaction/dbTransaction' |
@@ -1,2 +0,2 @@ | ||
import { JsonSchemaObject, JsonSchemaRootObject } from '@naturalcycles/js-lib' | ||
import { JsonSchemaObject, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib' | ||
import { ReadableTyped } from '@naturalcycles/nodejs-lib' | ||
@@ -8,3 +8,2 @@ import { | ||
CommonDBStreamOptions, | ||
ObjectWithId, | ||
RunQueryResult, | ||
@@ -11,0 +10,0 @@ } from './db.model' |
@@ -1,2 +0,2 @@ | ||
import { ErrorMode } from '@naturalcycles/js-lib' | ||
import { ErrorMode, ObjectWithId } from '@naturalcycles/js-lib' | ||
import { | ||
@@ -11,8 +11,3 @@ AjvSchema, | ||
import { CommonDB } from '../common.db' | ||
import { | ||
CommonDBCreateOptions, | ||
CommonDBOptions, | ||
CommonDBSaveOptions, | ||
ObjectWithId, | ||
} from '../db.model' | ||
import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model' | ||
@@ -97,2 +92,13 @@ // Hook DBM, BM, TM types should follow this exact order | ||
createdUpdated?: boolean | ||
/** | ||
* Default is false. | ||
* If true - will run `_filterNullishValues` inside `validateAndConvert` function | ||
* (instead of `_filterUndefinedValues`). | ||
* This was the old db-lib behavior. | ||
* This option allows to keep backwards-compatible behavior. | ||
* | ||
* @deprecated | ||
*/ | ||
filterNullishValues?: boolean | ||
} | ||
@@ -99,0 +105,0 @@ |
@@ -13,3 +13,5 @@ import { | ||
_uniqBy, | ||
ObjectWithId, | ||
_filterUndefinedValues, | ||
_filterNullishValues, | ||
} from '@naturalcycles/js-lib' | ||
@@ -34,3 +36,3 @@ import { | ||
import { DBLibError } from '../cnst' | ||
import { DBModelType, ObjectWithId, RunQueryResult } from '../db.model' | ||
import { DBModelType, RunQueryResult } from '../db.model' | ||
import { DBQuery, RunnableDBQuery } from '../query/dbQuery' | ||
@@ -879,3 +881,7 @@ import { | ||
// and they can be annoying with snapshot tests | ||
obj = _filterUndefinedValues(obj) | ||
if (this.cfg.filterNullishValues) { | ||
obj = _filterNullishValues(obj) | ||
} else { | ||
obj = _filterUndefinedValues(obj) | ||
} | ||
@@ -882,0 +888,0 @@ // Pre-validation hooks |
@@ -1,2 +0,2 @@ | ||
import { AnyObject } from '@naturalcycles/js-lib' | ||
import { AnyObjectWithId, ObjectWithId } from '@naturalcycles/js-lib' | ||
import { CommonDB } from './common.db' | ||
@@ -55,17 +55,2 @@ | ||
export interface CreatedUpdated { | ||
created: number | ||
updated: number | ||
} | ||
export interface CreatedUpdatedId extends CreatedUpdated { | ||
id: string | ||
} | ||
export interface ObjectWithId { | ||
id: string | ||
} | ||
export interface AnyObjectWithId extends AnyObject, ObjectWithId {} | ||
/** | ||
@@ -72,0 +57,0 @@ * Interface for a module (lib) that implements CommonDB. |
@@ -27,3 +27,2 @@ import { InMemoryDB, InMemoryDBCfg } from './adapter/inmemory/inMemory.db' | ||
import { | ||
AnyObjectWithId, | ||
CommonDBAdapter, | ||
@@ -34,4 +33,2 @@ CommonDBCreateOptions, | ||
CommonDBStreamOptions, | ||
CreatedUpdated, | ||
CreatedUpdatedId, | ||
DBDeleteByIdsOperation, | ||
@@ -42,3 +39,2 @@ DBModelType, | ||
DBSaveBatchOperation, | ||
ObjectWithId, | ||
RunQueryResult, | ||
@@ -53,3 +49,2 @@ } from './db.model' | ||
deserializeJsonField, | ||
idField, | ||
serializeJsonField, | ||
@@ -86,6 +81,2 @@ } from './model.util' | ||
RunQueryResult, | ||
CreatedUpdated, | ||
CreatedUpdatedId, | ||
AnyObjectWithId, | ||
ObjectWithId, | ||
CommonDaoCfg, | ||
@@ -125,3 +116,2 @@ CommonDaoCreateIdHook, | ||
createdUpdatedIdFields, | ||
idField, | ||
InMemoryDB, | ||
@@ -128,0 +118,0 @@ InMemoryKeyValueDB, |
import { stringId } from '@naturalcycles/nodejs-lib' | ||
import { CreatedUpdated, CreatedUpdatedId, ObjectWithId } from './db.model' | ||
import { CreatedUpdated, CreatedUpdatedId, ObjectWithId } from '@naturalcycles/js-lib' | ||
@@ -4,0 +4,0 @@ export function createdUpdatedFields( |
@@ -1,6 +0,6 @@ | ||
import { AsyncMapper, _truncate, Saved } from '@naturalcycles/js-lib' | ||
import { AnyObjectWithId, ObjectWithId, AsyncMapper, _truncate, Saved } from '@naturalcycles/js-lib' | ||
import { ReadableTyped } from '@naturalcycles/nodejs-lib' | ||
import { CommonDaoOptions, CommonDaoStreamForEachOptions, CommonDaoStreamOptions } from '..' | ||
import { CommonDao } from '../commondao/common.dao' | ||
import { AnyObjectWithId, ObjectWithId, RunQueryResult } from '../db.model' | ||
import { RunQueryResult } from '../db.model' | ||
@@ -7,0 +7,0 @@ /** |
@@ -0,3 +1,3 @@ | ||
import { ObjectWithId } from '@naturalcycles/js-lib' | ||
import { DBTransaction } from '..' | ||
import { ObjectWithId } from '../db.model' | ||
import { DBQuery } from '../query/dbQuery' | ||
@@ -4,0 +4,0 @@ import { |
@@ -0,3 +1,4 @@ | ||
import { AnyObjectWithId, ObjectWithId } from '@naturalcycles/js-lib' | ||
import type { CommonDB } from '../common.db' | ||
import type { AnyObjectWithId, CommonDBSaveOptions, DBOperation, ObjectWithId } from '../db.model' | ||
import type { CommonDBSaveOptions, DBOperation } from '../db.model' | ||
@@ -4,0 +5,0 @@ /** |
@@ -1,4 +0,4 @@ | ||
import { StringMap, _stringMapEntries } from '@naturalcycles/js-lib' | ||
import { StringMap, _stringMapEntries, ObjectWithId } from '@naturalcycles/js-lib' | ||
import type { CommonDB } from '../common.db' | ||
import { CommonDBSaveOptions, DBOperation, ObjectWithId } from '../db.model' | ||
import { CommonDBSaveOptions, DBOperation } from '../db.model' | ||
import { DBTransaction } from './dbTransaction' | ||
@@ -5,0 +5,0 @@ |
401419
9102