harperdb 3.2.1 → 3.3.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/README.md +20 -11
- package/bin/BinObjects.jsc +0 -0
- package/bin/harperdb.jsc +0 -0
- package/bin/install.jsc +0 -0
- package/bin/register.jsc +0 -0
- package/bin/run.jsc +0 -0
- package/bin/stop.jsc +0 -0
- package/bin/upgrade.jsc +0 -0
- package/bin/utility.jsc +0 -0
- package/bin/version.jsc +0 -0
- package/coverage/lcov.info +7142 -6704
- package/data_layer/CreateAttributeObject.jsc +0 -0
- package/data_layer/CreateTableObject.jsc +0 -0
- package/data_layer/DataLayerObjects.jsc +0 -0
- package/data_layer/DeleteBeforeObject.jsc +0 -0
- package/data_layer/DeleteObject.jsc +0 -0
- package/data_layer/DropAttributeObject.jsc +0 -0
- package/data_layer/InsertObject.jsc +0 -0
- package/data_layer/ReadTransactionLogObject.jsc +0 -0
- package/data_layer/SQLSearch.jsc +0 -0
- package/data_layer/SearchByConditionsObject.jsc +0 -0
- package/data_layer/SearchByHashObject.jsc +0 -0
- package/data_layer/SearchObject.jsc +0 -0
- package/data_layer/SqlSearchObject.jsc +0 -0
- package/data_layer/UpdateObject.jsc +0 -0
- package/data_layer/UpsertObject.jsc +0 -0
- package/data_layer/bulkLoad.jsc +0 -0
- package/data_layer/data_objects/BulkLoadObjects.jsc +0 -0
- package/data_layer/data_objects/UpsertObject.jsc +0 -0
- package/data_layer/delete.jsc +0 -0
- package/data_layer/export.jsc +0 -0
- package/data_layer/harperBridge/BridgeMethods.jsc +0 -0
- package/data_layer/harperBridge/bridgeUtility/checkForNewAttr.jsc +0 -0
- package/data_layer/harperBridge/bridgeUtility/convertOperationToTransaction.jsc +0 -0
- package/data_layer/harperBridge/bridgeUtility/evaluateTableGetAttributes.jsc +0 -0
- package/data_layer/harperBridge/bridgeUtility/insertUpdateReturnObj.jsc +0 -0
- package/data_layer/harperBridge/bridgeUtility/insertUpdateValidate.jsc +0 -0
- package/data_layer/harperBridge/harperBridge.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/LMDBBridge.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/DeleteTransactionsBeforeResults.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateAttribute.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateRecords.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateSchema.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateTable.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteRecords.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteRecordsBefore.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteTransactionLogsBefore.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropAttribute.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropSchema.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropTable.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByHash.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByValue.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbReadTransactionLog.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByConditions.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByHash.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByValue.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpdateRecords.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpsertRecords.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBCreateAttributeObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBDeleteTransactionObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBInsertTransactionObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBTransactionObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBUpdateTransactionObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBUpsertTransactionObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/ThreadSearchObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/initializeHashSearch.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/initializePaths.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbCheckForNewAttributes.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbCreateTransactionsEnvironment.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbDropAllAttributes.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbProcessRows.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbSearch.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbThreadSearch.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbWriteTransaction.jsc +0 -0
- package/data_layer/hdbInfoController.jsc +0 -0
- package/data_layer/insert.jsc +0 -0
- package/data_layer/readTransactionLog.jsc +0 -0
- package/data_layer/schema.jsc +0 -0
- package/data_layer/schemaDescribe.jsc +0 -0
- package/data_layer/search.jsc +0 -0
- package/data_layer/update.jsc +0 -0
- package/events/ClusterStatusEmitter.jsc +0 -0
- package/events/SioServerStoppedEvent.jsc +0 -0
- package/events/SocketClusterStatusEmitter.jsc +0 -0
- package/license/LICENSE +91 -1
- package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/README.md +1 -0
- package/node_modules/{node-addon-api/src/nothing.c → @msgpackr-extract/msgpackr-extract-linux-x64/index.js} +0 -0
- package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi93.glibc.node +0 -0
- package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi93.musl.node +0 -0
- package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.glibc.node +0 -0
- package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.musl.node +0 -0
- package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/package.json +53 -0
- package/node_modules/{msgpackr-extract → lmdb-store}/.github/workflows/prebuild.yml +9 -10
- package/node_modules/lmdb-store/.idea/lmdb-store.iml +12 -0
- package/node_modules/lmdb-store/.idea/misc.xml +6 -0
- package/node_modules/lmdb-store/.idea/modules.xml +8 -0
- package/node_modules/lmdb-store/.idea/workspace.xml +4 -0
- package/node_modules/lmdb-store/README.md +393 -388
- package/node_modules/lmdb-store/benchmark/index.js +162 -162
- package/node_modules/lmdb-store/binding.gyp +79 -88
- package/node_modules/lmdb-store/caching.js +113 -113
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/COPYRIGHT +20 -20
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/Doxyfile +1631 -1631
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/LICENSE +47 -47
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/chacha8.c +183 -183
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/chacha8.h +14 -14
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/crypto.c +121 -121
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/intro.doc +192 -192
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb.c +12125 -12125
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_copy.1 +74 -74
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_copy.c +106 -106
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_drop.1 +53 -53
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_drop.c +154 -154
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_dump.1 +94 -94
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_dump.c +333 -333
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_load.1 +97 -97
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_load.c +530 -530
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_stat.1 +83 -83
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_stat.c +276 -276
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/midl.c +452 -452
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/midl.h +208 -208
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/module.c +101 -101
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/module.h +16 -16
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest.c +178 -178
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest2.c +124 -124
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest3.c +133 -133
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest4.c +168 -168
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest5.c +135 -135
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest6.c +141 -141
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest_enc.c +190 -190
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest_enc2.c +189 -189
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest_remap.c +177 -177
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/sample-bdb.txt +73 -73
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/sample-mdb.txt +62 -62
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/tooltag +27 -27
- package/node_modules/lmdb-store/dependencies/lz4/LICENSE +11 -11
- package/node_modules/lmdb-store/dependencies/lz4/lib/README.md +137 -137
- package/node_modules/lmdb-store/dependencies/lz4/lib/dll/example/README.md +69 -69
- package/node_modules/lmdb-store/dependencies/lz4/lib/lz4frame.c +1899 -1899
- package/node_modules/lmdb-store/dependencies/lz4/lib/xxhash.c +1030 -1030
- package/node_modules/lmdb-store/dependencies/lz4/lib/xxhash.h +328 -328
- package/node_modules/lmdb-store/dist/index.cjs +2591 -0
- package/node_modules/lmdb-store/dist/index.cjs.map +1 -0
- package/node_modules/lmdb-store/index.d.ts +323 -323
- package/node_modules/lmdb-store/index.js +1274 -1274
- package/node_modules/lmdb-store/index.mjs +3 -3
- package/node_modules/lmdb-store/package.json +16 -11
- package/node_modules/lmdb-store/prebuilds/darwin-arm64/electron.abi98.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-arm64/node.abi83.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-arm64/node.abi93.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-x64/electron.abi98.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-x64/node.abi83.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-x64/node.abi93.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-arm64/electron.abi98.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-arm64/node.abi83.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-arm64/node.abi93.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-x64/electron.abi98.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-x64/node.abi83.musl.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-x64/node.abi83.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-x64/node.abi93.musl.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-x64/node.abi93.node +0 -0
- package/node_modules/lmdb-store/prebuilds/win32-x64/electron.abi98.node +0 -0
- package/node_modules/lmdb-store/prebuilds/win32-x64/node.abi83.node +0 -0
- package/node_modules/lmdb-store/prebuilds/win32-x64/node.abi93.node +0 -0
- package/node_modules/lmdb-store/src/compression.cpp +181 -181
- package/node_modules/lmdb-store/src/cursor.cpp +407 -407
- package/node_modules/lmdb-store/src/dbi.cpp +354 -354
- package/node_modules/lmdb-store/src/env.cpp +1134 -1134
- package/node_modules/lmdb-store/src/misc.cpp +528 -528
- package/node_modules/lmdb-store/src/node-lmdb.cpp +44 -44
- package/node_modules/lmdb-store/src/node-lmdb.h +965 -965
- package/node_modules/lmdb-store/src/ordered-binary.cpp +337 -337
- package/node_modules/lmdb-store/src/txn.cpp +513 -513
- package/node_modules/lmdb-store/src/v8-fast-api-calls.h +419 -419
- package/node_modules/lmdb-store/src/windows.c +30 -30
- package/node_modules/lmdb-store/test/index.test.js +584 -584
- package/node_modules/lmdb-store/test/node-lmdb.test.js +1525 -1525
- package/node_modules/lmdb-store/test/threads.js +100 -100
- package/node_modules/lmdb-store/util/ArrayLikeIterable.js +136 -136
- package/node_modules/lmdb-store/util/WeakValueMap.js +40 -40
- package/node_modules/lmdb-store/util/upgrade-lmdb.js +46 -46
- package/node_modules/lmdb-store/util/when.js +8 -8
- package/node_modules/microtime/.github/workflows/release.yml +76 -0
- package/node_modules/microtime/.github/workflows/test.yml +46 -0
- package/node_modules/microtime/README.md +0 -2
- package/node_modules/microtime/binding.gyp +28 -10
- package/node_modules/microtime/package.json +25 -20
- package/node_modules/microtime/prebuilds/darwin-x64+arm64/electron.napi.node +0 -0
- package/node_modules/microtime/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/node_modules/microtime/prebuilds/linux-arm/node.napi.armv7.node +0 -0
- package/node_modules/microtime/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
- package/node_modules/microtime/prebuilds/linux-x64/electron.napi.node +0 -0
- package/node_modules/microtime/prebuilds/linux-x64/node.napi.node +0 -0
- package/node_modules/microtime/prebuilds/win32-ia32/electron.napi.node +0 -0
- package/node_modules/microtime/prebuilds/win32-ia32/node.napi.node +0 -0
- package/node_modules/microtime/prebuilds/win32-x64/electron.napi.node +0 -0
- package/node_modules/microtime/prebuilds/win32-x64/node.napi.node +0 -0
- package/node_modules/msgpackr/dist/index.js +1929 -1917
- package/node_modules/msgpackr/dist/index.min.js +67 -68
- package/node_modules/msgpackr/dist/node.cjs +1994 -1980
- package/node_modules/msgpackr/dist/test.js +683 -1235
- package/node_modules/msgpackr/index.d.ts +23 -12
- package/node_modules/msgpackr/node-index.js +23 -21
- package/node_modules/msgpackr/pack.js +935 -931
- package/node_modules/msgpackr/package.json +24 -12
- package/node_modules/msgpackr/unpack.d.ts +52 -50
- package/node_modules/msgpackr/unpack.js +1061 -1053
- package/node_modules/msgpackr-extract/bin/download-prebuilds.js +11 -0
- package/node_modules/msgpackr-extract/binding.gyp +22 -5
- package/node_modules/msgpackr-extract/index.js +1 -1
- package/node_modules/msgpackr-extract/package.json +46 -21
- package/node_modules/msgpackr-extract/src/.vs/ProjectSettings.json +3 -0
- package/node_modules/msgpackr-extract/src/.vs/VSWorkspaceState.json +7 -0
- package/node_modules/msgpackr-extract/src/.vs/slnx.sqlite +0 -0
- package/node_modules/msgpackr-extract/src/.vs/src/v16/.suo +0 -0
- package/node_modules/msgpackr-extract/src/.vs/src/v16/Browse.VC.db +0 -0
- package/node_modules/msgpackr-extract/{prebuilds/darwin-x64/node.abi72.node → src/.vs/src/v16/Browse.VC.db-shm} +0 -0
- package/node_modules/msgpackr-extract/src/.vs/src/v16/Browse.VC.db-wal +0 -0
- package/node_modules/msgpackr-extract/src/extract.cpp +272 -269
- package/node_modules/nan/package.json +0 -1
- package/node_modules/node-addon-api/README.md +146 -53
- package/node_modules/node-addon-api/common.gypi +21 -0
- package/node_modules/node-addon-api/except.gypi +25 -0
- package/node_modules/node-addon-api/index.js +7 -41
- package/node_modules/node-addon-api/napi-inl.deprecated.h +8 -8
- package/node_modules/node-addon-api/napi-inl.h +2795 -633
- package/node_modules/node-addon-api/napi.h +1547 -597
- package/node_modules/node-addon-api/node_api.gyp +9 -0
- package/node_modules/node-addon-api/noexcept.gypi +26 -0
- package/node_modules/node-addon-api/nothing.c +0 -0
- package/node_modules/node-addon-api/package-support.json +21 -0
- package/node_modules/node-addon-api/package.json +203 -13
- package/node_modules/node-addon-api/tools/README.md +12 -6
- package/node_modules/node-addon-api/tools/clang-format.js +71 -0
- package/node_modules/node-addon-api/tools/conversion.js +4 -8
- package/node_modules/node-addon-api/tools/eslint-format.js +71 -0
- package/node_modules/node-gyp-build/README.md +17 -14
- package/node_modules/node-gyp-build/bin.js +28 -15
- package/node_modules/node-gyp-build/index.js +145 -34
- package/node_modules/node-gyp-build/package.json +18 -15
- package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/LICENSE +0 -0
- package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/README.md +0 -0
- package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/bin.js +1 -1
- package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/build-test.js +0 -0
- package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/index.js +17 -11
- package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/optional.js +0 -0
- package/node_modules/{msgpackr-extract/node_modules/node-gyp-build → node-gyp-build-optional-packages}/package.json +17 -17
- package/package.json +12 -11
- package/security/JWTObjects.jsc +0 -0
- package/security/auth.jsc +0 -0
- package/security/cryptoHash.jsc +0 -0
- package/security/data_objects/PermissionAttributeResponseObject.jsc +0 -0
- package/security/data_objects/PermissionResponseObject.jsc +0 -0
- package/security/data_objects/PermissionTableResponseObject.jsc +0 -0
- package/security/permissionsTranslator.jsc +0 -0
- package/security/role.jsc +0 -0
- package/security/tokenAuthentication.jsc +0 -0
- package/security/user.jsc +0 -0
- package/server/ClusteringOriginObject.jsc +0 -0
- package/server/JobObject.jsc +0 -0
- package/server/clustering/ClusterStatusObject.jsc +0 -0
- package/server/clustering/NodeObject.jsc +0 -0
- package/server/clustering/clusterUtilities.jsc +0 -0
- package/server/configuration.jsc +0 -0
- package/server/customFunctions/customFunctionsServer.jsc +0 -0
- package/server/customFunctions/helpers/getCORSOptions.jsc +0 -0
- package/server/customFunctions/helpers/getHeaderTimeoutConfig.jsc +0 -0
- package/server/customFunctions/helpers/getServerOptions.jsc +0 -0
- package/server/customFunctions/operations.jsc +0 -0
- package/server/customFunctions/operationsValidation.jsc +0 -0
- package/server/harperdb/hdbServer.jsc +0 -0
- package/server/ipc/IPCClient.jsc +0 -0
- package/server/ipc/hdbIpcServer.jsc +0 -0
- package/server/ipc/serverHandlers.jsc +0 -0
- package/server/ipc/utility/IPCEventObject.jsc +0 -0
- package/server/ipc/utility/ipcUtils.jsc +0 -0
- package/server/jobRunner.jsc +0 -0
- package/server/jobThread.jsc +0 -0
- package/server/jobs.jsc +0 -0
- package/server/serverHelpers/OperationFunctionObject.jsc +0 -0
- package/server/serverHelpers/requestTimePlugin.jsc +0 -0
- package/server/serverHelpers/serverHandlers.jsc +0 -0
- package/server/serverHelpers/serverUtilities.jsc +0 -0
- package/server/socketcluster/Server.jsc +0 -0
- package/server/socketcluster/broker.jsc +0 -0
- package/server/socketcluster/connector/HDBSocketConnector.jsc +0 -0
- package/server/socketcluster/connector/InterNodeSocketConnector.jsc +0 -0
- package/server/socketcluster/connector/SocketConnector.jsc +0 -0
- package/server/socketcluster/connector/spawnSCConnection.jsc +0 -0
- package/server/socketcluster/decisionMatrix/CoreDecisionMatrix.jsc +0 -0
- package/server/socketcluster/decisionMatrix/DecisionMatrixIF.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/AssignToHdbChildWorkerRule.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/CallRoomMsgHandlerRule.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/CleanDataObjectRule.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/CommandCollection.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/DummyRule.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/RulesIF.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/StripHdbHeaderRule.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/TestRule.jsc +0 -0
- package/server/socketcluster/handlers/NodeConnectionsHandler.jsc +0 -0
- package/server/socketcluster/handlers/SCServer.jsc +0 -0
- package/server/socketcluster/handlers/ServerSocket.jsc +0 -0
- package/server/socketcluster/interNodeConnectionLauncher.jsc +0 -0
- package/server/socketcluster/messageQueue/MessageQueueIF.jsc +0 -0
- package/server/socketcluster/middleware/AuthMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/ConnectionNameCheckMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/GenericMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/MessagePrepMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/MiddlewareFactory.jsc +0 -0
- package/server/socketcluster/middleware/MiddlewareIF.jsc +0 -0
- package/server/socketcluster/middleware/OriginatorCheckMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/RequestDataValidMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/StampOriginatorMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/StampRequestMiddleware.jsc +0 -0
- package/server/socketcluster/observer/EventableIF.jsc +0 -0
- package/server/socketcluster/room/AddUserRoom.jsc +0 -0
- package/server/socketcluster/room/AlterUserRoom.jsc +0 -0
- package/server/socketcluster/room/CoreRoom.jsc +0 -0
- package/server/socketcluster/room/CreateAttributeRoom.jsc +0 -0
- package/server/socketcluster/room/CreateSchemaRoom.jsc +0 -0
- package/server/socketcluster/room/CreateTableRoom.jsc +0 -0
- package/server/socketcluster/room/DropUserRoom.jsc +0 -0
- package/server/socketcluster/room/HDBNodeRoom.jsc +0 -0
- package/server/socketcluster/room/RoomIF.jsc +0 -0
- package/server/socketcluster/room/RoomMessageObjects.jsc +0 -0
- package/server/socketcluster/room/UsersRoom.jsc +0 -0
- package/server/socketcluster/room/WatchHDBWorkersRoom.jsc +0 -0
- package/server/socketcluster/room/WorkerRoom.jsc +0 -0
- package/server/socketcluster/room/roomFactory.jsc +0 -0
- package/server/socketcluster/socketClusterObjects.jsc +0 -0
- package/server/socketcluster/types.jsc +0 -0
- package/server/socketcluster/util/clusterData.jsc +0 -0
- package/server/socketcluster/util/socketClusterUtils.jsc +0 -0
- package/server/socketcluster/worker/ClusterWorker.jsc +0 -0
- package/server/socketcluster/worker/WorkerIF.jsc +0 -0
- package/server/socketcluster/worker/WorkerObjects.jsc +0 -0
- package/server/transactToClusteringUtilities.jsc +0 -0
- package/sqlTranslator/SelectValidator.jsc +0 -0
- package/sqlTranslator/alasqlFunctionImporter.jsc +0 -0
- package/sqlTranslator/conditionPatterns.jsc +0 -0
- package/sqlTranslator/deleteTranslator.jsc +0 -0
- package/sqlTranslator/index.jsc +0 -0
- package/sqlTranslator/sql_statement_bucket.jsc +0 -0
- package/upgrade/EnvironmentVariable.jsc +0 -0
- package/upgrade/UpgradeDirective.jsc +0 -0
- package/upgrade/UpgradeObjects.jsc +0 -0
- package/upgrade/directives/3-0-0.jsc +0 -0
- package/upgrade/directives/3-1-0.jsc +0 -0
- package/upgrade/directives/directivesController.jsc +0 -0
- package/upgrade/directives/upgrade_scripts/3_0_0_reindex_script.jsc +0 -0
- package/upgrade/directivesManager.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/DBIDefinition.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/OpenDBIObject.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/OpenEnvironmentObject.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/commonErrors.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/commonUtility.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/environmentUtility.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/terms.jsc +0 -0
- package/upgrade/upgradePrompt.jsc +0 -0
- package/upgrade/upgradeUtilities.jsc +0 -0
- package/utility/AWS/AWSConnector.jsc +0 -0
- package/utility/OperationFunctionCaller.jsc +0 -0
- package/utility/common_utils.jsc +0 -0
- package/utility/environment/SystemInformationObject.jsc +0 -0
- package/utility/environment/SystemInformationOperation.jsc +0 -0
- package/utility/environment/environmentManager.jsc +0 -0
- package/utility/environment/systemInformation.jsc +0 -0
- package/utility/errors/commonErrors.jsc +0 -0
- package/utility/errors/hdbError.jsc +0 -0
- package/utility/functions/date/dateFunctions.jsc +0 -0
- package/utility/functions/geo.jsc +0 -0
- package/utility/functions/math/avg.jsc +0 -0
- package/utility/functions/math/count.jsc +0 -0
- package/utility/functions/sql/alaSQLExtension.jsc +0 -0
- package/utility/functions/string/compare.jsc +0 -0
- package/utility/globalSchema.jsc +0 -0
- package/utility/hdbTerms.jsc +0 -0
- package/utility/install/checkJWTTokensExist.jsc +0 -0
- package/utility/install/installer.jsc +0 -0
- package/utility/install_user_permission.jsc +0 -0
- package/utility/lmdb/DBIDefinition.jsc +0 -0
- package/utility/lmdb/DeleteRecordsResponseObject.jsc +0 -0
- package/utility/lmdb/InsertRecordsResponseObject.jsc +0 -0
- package/utility/lmdb/OpenDBIObject.jsc +0 -0
- package/utility/lmdb/OpenEnvironmentObject.jsc +0 -0
- package/utility/lmdb/UpdateRecordsResponseObject.jsc +0 -0
- package/utility/lmdb/UpsertRecordsResponseObject.jsc +0 -0
- package/utility/lmdb/cleanLMDBMap.jsc +0 -0
- package/utility/lmdb/commonUtility.jsc +0 -0
- package/utility/lmdb/deleteUtility.jsc +0 -0
- package/utility/lmdb/environmentUtility.jsc +0 -0
- package/utility/lmdb/searchCursorFunctions.jsc +0 -0
- package/utility/lmdb/searchUtility.jsc +0 -0
- package/utility/lmdb/terms.jsc +0 -0
- package/utility/lmdb/writeUtility.jsc +0 -0
- package/utility/logging/harper_logger.jsc +0 -0
- package/utility/mount_hdb.jsc +0 -0
- package/utility/npmUtilities.jsc +0 -0
- package/utility/operation_authorization.jsc +0 -0
- package/utility/password.jsc +0 -0
- package/utility/pm2/servicesConfig.jsc +0 -0
- package/utility/pm2/utilityFunctions.jsc +0 -0
- package/utility/psList.jsc +0 -0
- package/utility/registration/hdb_license.jsc +0 -0
- package/utility/registration/licenseObjects.jsc +0 -0
- package/utility/registration/registrationHandler.jsc +0 -0
- package/utility/scripts/restartHdb.jsc +0 -0
- package/utility/signalling.jsc +0 -0
- package/utility/system_info.jsc +0 -0
- package/validation/bulkDeleteValidator.jsc +0 -0
- package/validation/check_permissions.jsc +0 -0
- package/validation/clustering/configureValidator.jsc +0 -0
- package/validation/common_validators.jsc +0 -0
- package/validation/conditionalDeleteValidator.jsc +0 -0
- package/validation/deleteValidator.jsc +0 -0
- package/validation/fileLoadValidator.jsc +0 -0
- package/validation/insertValidator.jsc +0 -0
- package/validation/nodeSubscriptionValidator.jsc +0 -0
- package/validation/nodeValidator.jsc +0 -0
- package/validation/readLogValidator.jsc +0 -0
- package/validation/registration/license_key_object.jsc +0 -0
- package/validation/role_validation.jsc +0 -0
- package/validation/schemaMetadataValidator.jsc +0 -0
- package/validation/schema_validator.jsc +0 -0
- package/validation/searchValidator.jsc +0 -0
- package/validation/user_validation.jsc +0 -0
- package/validation/validationWrapper.jsc +0 -0
- package/node_modules/lmdb-store/build/Makefile +0 -324
- package/node_modules/lmdb-store/build/Release/.deps/Release/lmdb-store.node.d +0 -1
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/chacha8.o.d +0 -6
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb.o.d +0 -8
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/midl.o.d +0 -8
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/dependencies/lz4/lib/lz4.o.d +0 -5
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/compression.o.d +0 -72
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/cursor.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/dbi.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/env.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/misc.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/node-lmdb.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/ordered-binary.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/txn.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/windows.o.d +0 -3
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store.node.d +0 -1
- package/node_modules/lmdb-store/build/Release/lmdb-store.node +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/chacha8.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/midl.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/dependencies/lz4/lib/lz4.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/compression.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/cursor.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/dbi.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/env.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/misc.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/node-lmdb.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/ordered-binary.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/txn.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/windows.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store.node +0 -0
- package/node_modules/lmdb-store/build/binding.Makefile +0 -6
- package/node_modules/lmdb-store/build/config.gypi +0 -426
- package/node_modules/lmdb-store/build/lmdb-store.target.mk +0 -206
- package/node_modules/lmdb-store/node_modules/node-gyp-build/package.json +0 -60
- package/node_modules/lmdb-store/prebuilds/darwin-x64/electron.abi87.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-x64/node.abi72.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-x64/node.abi88.node +0 -0
- package/node_modules/lmdb-store/prebuilds/win32-x64/electron.abi87.node +0 -0
- package/node_modules/lmdb-store/prebuilds/win32-x64/node.abi72.node +0 -0
- package/node_modules/lmdb-store/prebuilds/win32-x64/node.abi88.node +0 -0
- package/node_modules/microtime/prebuilds/darwin-x64/electron-napi.node +0 -0
- package/node_modules/microtime/prebuilds/darwin-x64/node-napi.node +0 -0
- package/node_modules/microtime/prebuilds/linux-arm/electron-napi.node +0 -0
- package/node_modules/microtime/prebuilds/linux-arm/node-napi.node +0 -0
- package/node_modules/microtime/prebuilds/linux-x64/electron-napi.node +0 -0
- package/node_modules/microtime/prebuilds/linux-x64/node-napi.node +0 -0
- package/node_modules/microtime/prebuilds/win32-x64/electron-napi.node +0 -0
- package/node_modules/microtime/prebuilds/win32-x64/node-napi.node +0 -0
- package/node_modules/msgpackr-extract/.circleci/config.yml +0 -19
- package/node_modules/msgpackr-extract/.travis.yml +0 -30
- package/node_modules/msgpackr-extract/node_modules/node-gyp-build/LICENSE +0 -21
- package/node_modules/msgpackr-extract/node_modules/node-gyp-build/README.md +0 -58
- package/node_modules/msgpackr-extract/node_modules/node-gyp-build/bin.js +0 -77
- package/node_modules/msgpackr-extract/node_modules/node-gyp-build/build-test.js +0 -19
- package/node_modules/msgpackr-extract/node_modules/node-gyp-build/index.js +0 -202
- package/node_modules/msgpackr-extract/node_modules/node-gyp-build/optional.js +0 -7
- package/node_modules/msgpackr-extract/prebuilds/darwin-arm64/electron.abi98.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-arm64/node.abi102.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-arm64/node.abi83.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-arm64/node.abi93.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-x64/electron.abi98.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-x64/node.abi102.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-x64/node.abi83.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-x64/node.abi88.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-x64/node.abi93.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-arm64/electron.abi98.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-arm64/node.abi102.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-arm64/node.abi83.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-arm64/node.abi93.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/electron.abi98.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi102.musl.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi102.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi72.musl.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi72.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi83.musl.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi83.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi88.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi93.musl.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi93.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/win32-x64/electron.abi98.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi102.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi72.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi83.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi88.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi93.node +0 -0
- package/node_modules/node-addon-api/.editorconfig +0 -8
- package/node_modules/node-addon-api/.travis.yml +0 -65
- package/node_modules/node-addon-api/CHANGELOG.md +0 -325
- package/node_modules/node-addon-api/CODE_OF_CONDUCT.md +0 -4
- package/node_modules/node-addon-api/CONTRIBUTING.md +0 -66
- package/node_modules/node-addon-api/appveyor.yml +0 -48
- package/node_modules/node-addon-api/doc/Doxyfile +0 -2450
- package/node_modules/node-addon-api/doc/array_buffer.md +0 -129
- package/node_modules/node-addon-api/doc/async_context.md +0 -76
- package/node_modules/node-addon-api/doc/async_operations.md +0 -31
- package/node_modules/node-addon-api/doc/async_worker.md +0 -397
- package/node_modules/node-addon-api/doc/basic_types.md +0 -415
- package/node_modules/node-addon-api/doc/bigint.md +0 -92
- package/node_modules/node-addon-api/doc/boolean.md +0 -64
- package/node_modules/node-addon-api/doc/buffer.md +0 -140
- package/node_modules/node-addon-api/doc/callback_scope.md +0 -54
- package/node_modules/node-addon-api/doc/callbackinfo.md +0 -97
- package/node_modules/node-addon-api/doc/checker-tool.md +0 -32
- package/node_modules/node-addon-api/doc/class_property_descriptor.md +0 -118
- package/node_modules/node-addon-api/doc/cmake-js.md +0 -19
- package/node_modules/node-addon-api/doc/conversion-tool.md +0 -28
- package/node_modules/node-addon-api/doc/creating_a_release.md +0 -62
- package/node_modules/node-addon-api/doc/dataview.md +0 -244
- package/node_modules/node-addon-api/doc/env.md +0 -63
- package/node_modules/node-addon-api/doc/error.md +0 -115
- package/node_modules/node-addon-api/doc/error_handling.md +0 -186
- package/node_modules/node-addon-api/doc/escapable_handle_scope.md +0 -82
- package/node_modules/node-addon-api/doc/external.md +0 -59
- package/node_modules/node-addon-api/doc/function.md +0 -294
- package/node_modules/node-addon-api/doc/function_reference.md +0 -238
- package/node_modules/node-addon-api/doc/generator.md +0 -13
- package/node_modules/node-addon-api/doc/handle_scope.md +0 -65
- package/node_modules/node-addon-api/doc/memory_management.md +0 -27
- package/node_modules/node-addon-api/doc/node-gyp.md +0 -82
- package/node_modules/node-addon-api/doc/number.md +0 -163
- package/node_modules/node-addon-api/doc/object.md +0 -202
- package/node_modules/node-addon-api/doc/object_lifetime_management.md +0 -83
- package/node_modules/node-addon-api/doc/object_reference.md +0 -117
- package/node_modules/node-addon-api/doc/object_wrap.md +0 -546
- package/node_modules/node-addon-api/doc/prebuild_tools.md +0 -16
- package/node_modules/node-addon-api/doc/promises.md +0 -74
- package/node_modules/node-addon-api/doc/property_descriptor.md +0 -231
- package/node_modules/node-addon-api/doc/range_error.md +0 -59
- package/node_modules/node-addon-api/doc/reference.md +0 -111
- package/node_modules/node-addon-api/doc/setup.md +0 -82
- package/node_modules/node-addon-api/doc/string.md +0 -89
- package/node_modules/node-addon-api/doc/symbol.md +0 -44
- package/node_modules/node-addon-api/doc/threadsafe_function.md +0 -303
- package/node_modules/node-addon-api/doc/type_error.md +0 -59
- package/node_modules/node-addon-api/doc/typed_array.md +0 -74
- package/node_modules/node-addon-api/doc/typed_array_of.md +0 -133
- package/node_modules/node-addon-api/doc/value.md +0 -269
- package/node_modules/node-addon-api/doc/version_management.md +0 -43
- package/node_modules/node-addon-api/doc/working_with_javascript_values.md +0 -14
- package/node_modules/node-addon-api/external-napi/node_api.h +0 -7
- package/node_modules/node-addon-api/src/node_api.cc +0 -3655
- package/node_modules/node-addon-api/src/node_api.gyp +0 -21
- package/node_modules/node-addon-api/src/node_api.h +0 -588
- package/node_modules/node-addon-api/src/node_api_types.h +0 -115
- package/node_modules/node-addon-api/src/node_internals.cc +0 -142
- package/node_modules/node-addon-api/src/node_internals.h +0 -157
- package/node_modules/node-addon-api/src/util-inl.h +0 -38
- package/node_modules/node-addon-api/src/util.h +0 -7
|
@@ -1,584 +1,584 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
let path = require('path');
|
|
4
|
-
let mkdirp = require('mkdirp');
|
|
5
|
-
let rimraf = require('rimraf');
|
|
6
|
-
let chai = require('chai');
|
|
7
|
-
let should = chai.should();
|
|
8
|
-
let expect = chai.expect;
|
|
9
|
-
let spawn = require('child_process').spawn;
|
|
10
|
-
|
|
11
|
-
let { open, getLastVersion, bufferToKeyValue, keyValueToBuffer, ABORT } = require('..');
|
|
12
|
-
const { ArrayLikeIterable } = require('../util/ArrayLikeIterable')
|
|
13
|
-
//var inspector = require('inspector'); inspector.open(9330, null, true); debugger
|
|
14
|
-
|
|
15
|
-
describe('lmdb-store', function() {
|
|
16
|
-
let testDirPath = path.resolve(__dirname, './testdata-ls');
|
|
17
|
-
|
|
18
|
-
// just to make a reasonable sized chunk of data...
|
|
19
|
-
function expand(str) {
|
|
20
|
-
str = '(' + str + ')';
|
|
21
|
-
str = str + str;
|
|
22
|
-
str = str + str;
|
|
23
|
-
str = str + str;
|
|
24
|
-
str = str + str;
|
|
25
|
-
str = str + str;
|
|
26
|
-
return str;
|
|
27
|
-
}
|
|
28
|
-
before(function(done) {
|
|
29
|
-
// cleanup previous test directory
|
|
30
|
-
rimraf(testDirPath, function(err) {
|
|
31
|
-
if (err) {
|
|
32
|
-
return done(err);
|
|
33
|
-
}
|
|
34
|
-
done();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
let testIteration = 1
|
|
38
|
-
describe('Basic use', basicTests({ compression: false }));
|
|
39
|
-
describe('Basic use with encryption', basicTests({ compression: false, encryptionKey: 'Use this key to encrypt the data' }));
|
|
40
|
-
//describe('Check encrypted data', basicTests({ compression: false, checkLast: true }));
|
|
41
|
-
describe('Basic use with JSON', basicTests({ encoding: 'json' }));
|
|
42
|
-
describe('Basic use with ordered-binary', basicTests({ encoding: 'ordered-binary' }));
|
|
43
|
-
describe('Basic use with caching', basicTests({ cache: true }));
|
|
44
|
-
function basicTests(options) { return function() {
|
|
45
|
-
this.timeout(1000000);
|
|
46
|
-
let db, db2;
|
|
47
|
-
before(function() {
|
|
48
|
-
db = open(testDirPath + '/test-' + testIteration + '.mdb', Object.assign({
|
|
49
|
-
name: 'mydb3',
|
|
50
|
-
create: true,
|
|
51
|
-
useVersions: true,
|
|
52
|
-
//asyncTransactionOrder: 'strict',
|
|
53
|
-
compression: {
|
|
54
|
-
threshold: 256,
|
|
55
|
-
},
|
|
56
|
-
}, options));
|
|
57
|
-
testIteration++;
|
|
58
|
-
if (!options.checkLast)
|
|
59
|
-
db.clear();
|
|
60
|
-
db2 = db.openDB(Object.assign({
|
|
61
|
-
name: 'mydb4',
|
|
62
|
-
create: true,
|
|
63
|
-
dupSort: true,
|
|
64
|
-
}));
|
|
65
|
-
if (!options.checkLast)
|
|
66
|
-
db2.clear();
|
|
67
|
-
});
|
|
68
|
-
if (options.checkLast) {
|
|
69
|
-
it('encrypted data can not be accessed', function() {
|
|
70
|
-
let data = db.get('key1');
|
|
71
|
-
console.log({data})
|
|
72
|
-
data.should.deep.equal({foo: 1, bar: true})
|
|
73
|
-
})
|
|
74
|
-
return
|
|
75
|
-
}
|
|
76
|
-
it('query of keys', async function() {
|
|
77
|
-
let keys = [
|
|
78
|
-
Symbol.for('test'),
|
|
79
|
-
false,
|
|
80
|
-
true,
|
|
81
|
-
-33,
|
|
82
|
-
-1.1,
|
|
83
|
-
3.3,
|
|
84
|
-
5,
|
|
85
|
-
[5,4],
|
|
86
|
-
[5,55],
|
|
87
|
-
'hello',
|
|
88
|
-
['hello', 3],
|
|
89
|
-
['hello', 'world'],
|
|
90
|
-
[ 'uid', 'I-7l9ySkD-wAOULIjOEnb', 'Rwsu6gqOw8cqdCZG5_YNF' ],
|
|
91
|
-
'z'
|
|
92
|
-
]
|
|
93
|
-
for (let key of keys)
|
|
94
|
-
await db.put(key, 3);
|
|
95
|
-
let returnedKeys = []
|
|
96
|
-
for (let { key, value } of db.getRange({
|
|
97
|
-
start: Symbol.for('A')
|
|
98
|
-
})) {
|
|
99
|
-
returnedKeys.push(key)
|
|
100
|
-
}
|
|
101
|
-
keys.should.deep.equal(returnedKeys)
|
|
102
|
-
});
|
|
103
|
-
it('string', async function() {
|
|
104
|
-
await db.put('key1', 'Hello world!');
|
|
105
|
-
let data = db.get('key1');
|
|
106
|
-
data.should.equal('Hello world!');
|
|
107
|
-
await db.remove('key1')
|
|
108
|
-
let data2 = db.get('key1');
|
|
109
|
-
should.equal(data2, undefined);
|
|
110
|
-
});
|
|
111
|
-
it('string with version', async function() {
|
|
112
|
-
await db.put('key1', 'Hello world!', 53252);
|
|
113
|
-
let entry = db.getEntry('key1');
|
|
114
|
-
entry.value.should.equal('Hello world!');
|
|
115
|
-
entry.version.should.equal(53252);
|
|
116
|
-
(await db.remove('key1', 33)).should.equal(false);
|
|
117
|
-
entry = db.getEntry('key1');
|
|
118
|
-
entry.value.should.equal('Hello world!');
|
|
119
|
-
entry.version.should.equal(53252);
|
|
120
|
-
(await db.remove('key1', 53252)).should.equal(true);
|
|
121
|
-
entry = db.getEntry('key1');
|
|
122
|
-
should.equal(entry, undefined);
|
|
123
|
-
});
|
|
124
|
-
it('string with version branching', async function() {
|
|
125
|
-
await db.put('key1', 'Hello world!', 53252);
|
|
126
|
-
let entry = db.getEntry('key1');
|
|
127
|
-
entry.value.should.equal('Hello world!');
|
|
128
|
-
entry.version.should.equal(53252);
|
|
129
|
-
(await db.ifVersion('key1', 777, () => {
|
|
130
|
-
db.put('newKey', 'test', 6);
|
|
131
|
-
db2.put('keyB', 'test', 6);
|
|
132
|
-
})).should.equal(false);
|
|
133
|
-
should.equal(db.get('newKey'), undefined);
|
|
134
|
-
should.equal(db2.get('keyB'), undefined);
|
|
135
|
-
let result = (await db.ifVersion('key1', 53252, () => {
|
|
136
|
-
db.put('newKey', 'test', 6);
|
|
137
|
-
db2.put('keyB', 'test', 6);
|
|
138
|
-
}))
|
|
139
|
-
should.equal(db.get('newKey'), 'test')
|
|
140
|
-
should.equal(db2.get('keyB'), 'test')
|
|
141
|
-
should.equal(result, true);
|
|
142
|
-
result = await db.ifNoExists('key1', () => {
|
|
143
|
-
db.put('newKey', 'changed', 7);
|
|
144
|
-
})
|
|
145
|
-
should.equal(db.get('newKey'), 'test');
|
|
146
|
-
should.equal(result, false);
|
|
147
|
-
result = await db.ifNoExists('key-no-exist', () => {
|
|
148
|
-
db.put('newKey', 'changed', 7);
|
|
149
|
-
})
|
|
150
|
-
should.equal(db.get('newKey'), 'changed')
|
|
151
|
-
should.equal(result, true);
|
|
152
|
-
});
|
|
153
|
-
it('string with compression and versions', async function() {
|
|
154
|
-
let str = expand('Hello world!')
|
|
155
|
-
await db.put('key1', str, 53252);
|
|
156
|
-
let entry = db.getEntry('key1');
|
|
157
|
-
entry.value.should.equal(str);
|
|
158
|
-
entry.version.should.equal(53252);
|
|
159
|
-
(await db.remove('key1', 33)).should.equal(false);
|
|
160
|
-
let data = db.get('key1');
|
|
161
|
-
data.should.equal(str);
|
|
162
|
-
(await db.remove('key1', 53252)).should.equal(true);
|
|
163
|
-
data = db.get('key1');
|
|
164
|
-
should.equal(data, undefined);
|
|
165
|
-
});
|
|
166
|
-
if (options.encoding == 'ordered-binary')
|
|
167
|
-
return // no more tests need to be applied for this
|
|
168
|
-
it('store objects', async function() {
|
|
169
|
-
let dataIn = {foo: 3, bar: true}
|
|
170
|
-
await db.put('key1', dataIn);
|
|
171
|
-
let dataOut = db.get('key1');
|
|
172
|
-
dataOut.should.deep.equal(dataIn);
|
|
173
|
-
db.removeSync('not-there').should.equal(false);
|
|
174
|
-
});
|
|
175
|
-
it.skip('trigger sync commit', async function() {
|
|
176
|
-
let dataIn = {foo: 4, bar: false}
|
|
177
|
-
db.immediateBatchThreshold = 1
|
|
178
|
-
db.syncBatchThreshold = 1
|
|
179
|
-
await db.put('key1', dataIn);
|
|
180
|
-
await db.put('key2', dataIn);
|
|
181
|
-
db.immediateBatchThreshold = 100000
|
|
182
|
-
db.syncBatchThreshold = 1000000
|
|
183
|
-
let dataOut = db.get('key1');
|
|
184
|
-
dataOut.should.deep.equal(dataIn);
|
|
185
|
-
});
|
|
186
|
-
function iterateQuery(acrossTransactions) { return async () => {
|
|
187
|
-
let data1 = {foo: 1, bar: true}
|
|
188
|
-
let data2 = {foo: 2, bar: false}
|
|
189
|
-
db.put('key1', data1);
|
|
190
|
-
await db.put('key2', data2);
|
|
191
|
-
let count = 0
|
|
192
|
-
for (let { key, value } of db.getRange({start:'key', end:'keyz', snapshot: !acrossTransactions})) {
|
|
193
|
-
if (acrossTransactions)
|
|
194
|
-
await delay(10)
|
|
195
|
-
count++
|
|
196
|
-
switch(key) {
|
|
197
|
-
case 'key1': data1.should.deep.equal(value); break;
|
|
198
|
-
case 'key2': data2.should.deep.equal(value); break;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
should.equal(count >= 2, true);
|
|
202
|
-
should.equal(db.getCount({start:'key', end:'keyz'}) >= 2, true);
|
|
203
|
-
}}
|
|
204
|
-
it('should iterate over query', iterateQuery(false));
|
|
205
|
-
it('should iterate over query, across transactions', iterateQuery(true));
|
|
206
|
-
it('should break out of query', async function() {
|
|
207
|
-
let data1 = {foo: 1, bar: true}
|
|
208
|
-
let data2 = {foo: 2, bar: false}
|
|
209
|
-
db.put('key1', data1);
|
|
210
|
-
await db.put('key2', data2);
|
|
211
|
-
let count = 0;
|
|
212
|
-
for (let { key, value } of db.getRange({start:'key', end:'keyz'})) {
|
|
213
|
-
if (count > 0)
|
|
214
|
-
break;
|
|
215
|
-
count++;
|
|
216
|
-
data1.should.deep.equal(value);
|
|
217
|
-
'key1'.should.equal(key);
|
|
218
|
-
}
|
|
219
|
-
count.should.equal(1);
|
|
220
|
-
});
|
|
221
|
-
it('should iterate over query with offset/limit', async function() {
|
|
222
|
-
let data1 = {foo: 1, bar: true}
|
|
223
|
-
let data2 = {foo: 2, bar: false}
|
|
224
|
-
let data3 = {foo: 3, bar: false}
|
|
225
|
-
db.put('key1', data1);
|
|
226
|
-
db.put('key2', data2);
|
|
227
|
-
await db.put('key3', data3);
|
|
228
|
-
let count = 0
|
|
229
|
-
for (let { key, value } of db.getRange({start:'key', end:'keyz', offset: 1, limit: 1})) {
|
|
230
|
-
count++
|
|
231
|
-
switch(key) {
|
|
232
|
-
case 'key2': data2.should.deep.equal(value); break;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
count.should.equal(1)
|
|
236
|
-
count = 0
|
|
237
|
-
for (let { key, value } of db.getRange({start:'key', end:'keyz', offset: 3, limit: 3})) {
|
|
238
|
-
count++
|
|
239
|
-
}
|
|
240
|
-
count.should.equal(0)
|
|
241
|
-
for (let { key, value } of db.getRange({start:'key', end:'keyz', offset: 10, limit: 3})) {
|
|
242
|
-
count++
|
|
243
|
-
}
|
|
244
|
-
count.should.equal(0)
|
|
245
|
-
for (let { key, value } of db.getRange({start:'key', end:'keyz', offset: 2, limit: 3})) {
|
|
246
|
-
count++
|
|
247
|
-
switch(key) {
|
|
248
|
-
case 'key3': data3.should.deep.equal(value); break;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
count.should.equal(1)
|
|
252
|
-
});
|
|
253
|
-
it('should iterate over dupsort query, with removal', async function() {
|
|
254
|
-
let data1 = {foo: 1, bar: true}
|
|
255
|
-
let data2 = {foo: 2, bar: false}
|
|
256
|
-
let data3 = {foo: 3, bar: true}
|
|
257
|
-
db2.put('key1', data1);
|
|
258
|
-
db2.put('key1', data2);
|
|
259
|
-
db2.put('key1', data3);
|
|
260
|
-
await db2.put('key2', data3);
|
|
261
|
-
let count = 0;
|
|
262
|
-
for (let value of db2.getValues('key1')) {
|
|
263
|
-
count++
|
|
264
|
-
switch(count) {
|
|
265
|
-
case 1: data1.should.deep.equal(value); break;
|
|
266
|
-
case 2: data2.should.deep.equal(value); break;
|
|
267
|
-
case 3: data3.should.deep.equal(value); break;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
count.should.equal(3);
|
|
271
|
-
db2.getValuesCount('key1').should.equal(3);
|
|
272
|
-
await db2.remove('key1', data2);
|
|
273
|
-
count = 0;
|
|
274
|
-
for (let value of db2.getValues('key1')) {
|
|
275
|
-
count++;
|
|
276
|
-
switch(count) {
|
|
277
|
-
case 1: data1.should.deep.equal(value); break;
|
|
278
|
-
case 2: data3.should.deep.equal(value); break;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
count.should.equal(2)
|
|
282
|
-
db2.getValuesCount('key1').should.equal(2);
|
|
283
|
-
count = 0;
|
|
284
|
-
for (let value of db2.getValues('key1', { reverse: true })) {
|
|
285
|
-
count++;
|
|
286
|
-
switch(count) {
|
|
287
|
-
case 1: data3.should.deep.equal(value); break;
|
|
288
|
-
case 2: data1.should.deep.equal(value); break;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
count.should.equal(2);
|
|
292
|
-
db2.getValuesCount('key1').should.equal(2);
|
|
293
|
-
|
|
294
|
-
count = 0;
|
|
295
|
-
for (let value of db2.getValues('key0')) {
|
|
296
|
-
count++;
|
|
297
|
-
}
|
|
298
|
-
count.should.equal(0);
|
|
299
|
-
db2.getValuesCount('key0').should.equal(0);
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it('doesExist', async function() {
|
|
303
|
-
let data1 = {foo: 1, bar: true}
|
|
304
|
-
let data2 = {foo: 2, bar: false}
|
|
305
|
-
let data3 = {foo: 3, bar: true}
|
|
306
|
-
db2.put('key1', data1);
|
|
307
|
-
db2.put('key1', data3);
|
|
308
|
-
db2.put(false, 3);
|
|
309
|
-
await db2.put('key2', data3);
|
|
310
|
-
should.equal(db2.doesExist('key1'), true);
|
|
311
|
-
should.equal(db2.doesExist('key1', data1), true);
|
|
312
|
-
should.equal(db2.doesExist('key1', data2), false);
|
|
313
|
-
should.equal(db2.doesExist('key1', data3), true);
|
|
314
|
-
should.equal(db2.doesExist(false), true);
|
|
315
|
-
should.equal(db2.doesExist(false, 3), true);
|
|
316
|
-
should.equal(db2.doesExist(false, 4), false);
|
|
317
|
-
})
|
|
318
|
-
it('should iterate over keys without duplicates', async function() {
|
|
319
|
-
let lastKey
|
|
320
|
-
for (let key of db2.getKeys({ start: 'k' })) {
|
|
321
|
-
if (key == lastKey)
|
|
322
|
-
throw new Error('duplicate key returned')
|
|
323
|
-
lastKey = key
|
|
324
|
-
}
|
|
325
|
-
})
|
|
326
|
-
it('invalid key', async function() {
|
|
327
|
-
expect(() => db.get({ foo: 'bar' })).to.throw();
|
|
328
|
-
//expect(() => db.put({ foo: 'bar' }, 'hello')).to.throw();
|
|
329
|
-
});
|
|
330
|
-
it('put options (sync)', function() {
|
|
331
|
-
db.putSync('zkey6', 'test', { append: true, version: 33 });
|
|
332
|
-
let entry = db.getEntry('zkey6');
|
|
333
|
-
entry.value.should.equal('test');
|
|
334
|
-
entry.version.should.equal(33);
|
|
335
|
-
db.putSync('zkey7', 'test', { append: true, noOverwrite: true });
|
|
336
|
-
db2.putSync('zkey6', 'test1', { appendDup: true });
|
|
337
|
-
db2.putSync('zkey6', 'test2', { appendDup: true });
|
|
338
|
-
expect(() => db.putSync('zkey5', 'test', { append: true, version: 44 })).to.throw();
|
|
339
|
-
expect(() => db.putSync('zkey7', 'test', { noOverwrite: true })).to.throw();
|
|
340
|
-
expect(() => db2.putSync('zkey6', 'test1', { noDupData: true })).to.throw();
|
|
341
|
-
});
|
|
342
|
-
it('async transactions', async function() {
|
|
343
|
-
let ranTransaction
|
|
344
|
-
db.put('key1', 'async initial value'); // should be queued for async write, but should put before queued transaction
|
|
345
|
-
let errorHandled
|
|
346
|
-
if (!db.cache) {
|
|
347
|
-
db.childTransaction(() => {
|
|
348
|
-
db.put('key1', 'should be rolled back');
|
|
349
|
-
throw new Error('Make sure this is properly propagated without interfering with next transaction')
|
|
350
|
-
}).catch(error => {
|
|
351
|
-
if (error)
|
|
352
|
-
errorHandled = true
|
|
353
|
-
})
|
|
354
|
-
await db.childTransaction(() => {
|
|
355
|
-
should.equal(db.get('key1'), 'async initial value');
|
|
356
|
-
db.put('key-a', 'async test a');
|
|
357
|
-
should.equal(db.get('key-a'), 'async test a');
|
|
358
|
-
})
|
|
359
|
-
should.equal(errorHandled, true);
|
|
360
|
-
}
|
|
361
|
-
await db.transactionAsync(() => {
|
|
362
|
-
ranTransaction = true;
|
|
363
|
-
should.equal(db.get('key1'), 'async initial value');
|
|
364
|
-
db.put('key1', 'async test 1');
|
|
365
|
-
should.equal(db.get('key1'), 'async test 1');
|
|
366
|
-
for (let { key, value } of db.getRange({start: 'key1', end: 'key1z' })) {
|
|
367
|
-
should.equal(value, 'async test 1');
|
|
368
|
-
}
|
|
369
|
-
db2.put('key2-async', 'async test 2');
|
|
370
|
-
should.equal(db2.get('key2-async'), 'async test 2');
|
|
371
|
-
});
|
|
372
|
-
should.equal(db.get('key1'), 'async test 1');
|
|
373
|
-
should.equal(db2.get('key2-async'), 'async test 2');
|
|
374
|
-
should.equal(ranTransaction, true);
|
|
375
|
-
});
|
|
376
|
-
it('child transaction in sync transaction', async function() {
|
|
377
|
-
if (db.cache)
|
|
378
|
-
return
|
|
379
|
-
await db.transactionSync(async () => {
|
|
380
|
-
db.put('key3', 'test-sync-txn');
|
|
381
|
-
db.childTransaction(() => {
|
|
382
|
-
db.put('key3', 'test-child-txn');
|
|
383
|
-
return ABORT;
|
|
384
|
-
})
|
|
385
|
-
should.equal(db.get('key3'), 'test-sync-txn');
|
|
386
|
-
db.childTransaction(() => {
|
|
387
|
-
db.put('key3', 'test-child-txn');
|
|
388
|
-
})
|
|
389
|
-
should.equal(db.get('key3'), 'test-child-txn');
|
|
390
|
-
await db.childTransaction(async () => {
|
|
391
|
-
await new Promise(resolve => setTimeout(resolve, 1))
|
|
392
|
-
db.put('key3', 'test-async-child-txn');
|
|
393
|
-
})
|
|
394
|
-
should.equal(db.get('key3'), 'test-async-child-txn');
|
|
395
|
-
})
|
|
396
|
-
});
|
|
397
|
-
it('async transaction with interrupting sync transaction default order', async function() {
|
|
398
|
-
db.strictAsyncOrder = false
|
|
399
|
-
let order = []
|
|
400
|
-
let ranSyncTxn
|
|
401
|
-
db.transactionAsync(() => {
|
|
402
|
-
order.push('a1');
|
|
403
|
-
db.put('async1', 'test');
|
|
404
|
-
if (!ranSyncTxn) {
|
|
405
|
-
ranSyncTxn = true;
|
|
406
|
-
setImmediate(() => db.transactionSync(() => {
|
|
407
|
-
order.push('s1');
|
|
408
|
-
db.put('inside-sync', 'test');
|
|
409
|
-
}));
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
db.put('outside-txn', 'test');
|
|
413
|
-
await db.transactionAsync(() => {
|
|
414
|
-
order.push('a2');
|
|
415
|
-
db.put('async2', 'test');
|
|
416
|
-
});
|
|
417
|
-
order.should.deep.equal(['a1', 'a2', 's1']);
|
|
418
|
-
should.equal(db.get('async1'), 'test');
|
|
419
|
-
should.equal(db.get('outside-txn'), 'test');
|
|
420
|
-
should.equal(db.get('inside-sync'), 'test');
|
|
421
|
-
should.equal(db.get('async2'), 'test');
|
|
422
|
-
});
|
|
423
|
-
it.skip('big child transactions', async function() {
|
|
424
|
-
let ranTransaction
|
|
425
|
-
db.put('key1', 'async initial value'); // should be queued for async write, but should put before queued transaction
|
|
426
|
-
let errorHandled
|
|
427
|
-
if (!db.cache) {
|
|
428
|
-
db.childTransaction(() => {
|
|
429
|
-
let value
|
|
430
|
-
for (let i = 0; i < 4; i++) {
|
|
431
|
-
value += ' test string ' + value
|
|
432
|
-
}
|
|
433
|
-
for (let i = 0; i < 4000; i++) {
|
|
434
|
-
db.put('key' + i, value)
|
|
435
|
-
}
|
|
436
|
-
})
|
|
437
|
-
await db.put('key1', 'test');
|
|
438
|
-
should.equal(db.get('key1'), 'test');
|
|
439
|
-
}
|
|
440
|
-
});
|
|
441
|
-
it('read and write with binary encoding', async function() {
|
|
442
|
-
let dbBinary = db.openDB(Object.assign({
|
|
443
|
-
name: 'mydb5',
|
|
444
|
-
create: true,
|
|
445
|
-
encoding: 'binary'
|
|
446
|
-
}));
|
|
447
|
-
dbBinary.put('buffer', Buffer.from('hello'));
|
|
448
|
-
dbBinary.put('empty', Buffer.from([]));
|
|
449
|
-
await dbBinary.put('Uint8Array', new Uint8Array([1,2,3]));
|
|
450
|
-
dbBinary.get('buffer').toString().should.equal('hello');
|
|
451
|
-
dbBinary.get('Uint8Array')[1].should.equal(2);
|
|
452
|
-
dbBinary.get('empty').length.should.equal(0);
|
|
453
|
-
});
|
|
454
|
-
it.skip('read and write with binary methods', async function() {
|
|
455
|
-
debugger
|
|
456
|
-
let dbBinary = db.openDB(Object.assign({
|
|
457
|
-
name: 'mydb6',
|
|
458
|
-
keyIsUint32: true,
|
|
459
|
-
create: true,
|
|
460
|
-
}));
|
|
461
|
-
dbBinary.put(3, Buffer.from('hello'));
|
|
462
|
-
await dbBinary.put(4, new Uint8Array([1,2,3]));
|
|
463
|
-
console.log(dbBinary.getBinaryLocation(3))
|
|
464
|
-
console.log(dbBinary.getBinaryLocation(4))
|
|
465
|
-
});
|
|
466
|
-
after(function(done) {
|
|
467
|
-
db.get('key1');
|
|
468
|
-
let iterator = db.getRange({})[Symbol.iterator]()
|
|
469
|
-
setTimeout(() => {
|
|
470
|
-
db.get('key1');
|
|
471
|
-
// should have open read and cursor transactions
|
|
472
|
-
db2.close();
|
|
473
|
-
db.close();
|
|
474
|
-
done();
|
|
475
|
-
},10);
|
|
476
|
-
});
|
|
477
|
-
}}
|
|
478
|
-
describe('direct key', function() {
|
|
479
|
-
it('should serialize and deserialize keys', function() {
|
|
480
|
-
let keys = [
|
|
481
|
-
Symbol.for('test'),
|
|
482
|
-
false,
|
|
483
|
-
true,
|
|
484
|
-
-33,
|
|
485
|
-
-1.1,
|
|
486
|
-
3.3,
|
|
487
|
-
5,
|
|
488
|
-
[5,4],
|
|
489
|
-
[5,55],
|
|
490
|
-
'hello',
|
|
491
|
-
['hello', 3],
|
|
492
|
-
['hello', 'world'],
|
|
493
|
-
[ 'uid', 'I-7l9ySkD-wAOULIjOEnb', 'Rwsu6gqOw8cqdCZG5_YNF' ],
|
|
494
|
-
'x'.repeat(1978),
|
|
495
|
-
'z'
|
|
496
|
-
]
|
|
497
|
-
let serializedKeys = []
|
|
498
|
-
for (let key of keys) {
|
|
499
|
-
let buffer = keyValueToBuffer(key)
|
|
500
|
-
serializedKeys.push(bufferToKeyValue(buffer))
|
|
501
|
-
}
|
|
502
|
-
serializedKeys.should.deep.equal(keys)
|
|
503
|
-
})
|
|
504
|
-
});
|
|
505
|
-
describe('uint32 keys', function() {
|
|
506
|
-
this.timeout(10000);
|
|
507
|
-
let db, db2;
|
|
508
|
-
before(function() {
|
|
509
|
-
db = open(testDirPath, {
|
|
510
|
-
name: 'uint32',
|
|
511
|
-
keyIsUint32: true,
|
|
512
|
-
compression: true,
|
|
513
|
-
});
|
|
514
|
-
});
|
|
515
|
-
it('write and read range', async function() {
|
|
516
|
-
let lastPromise
|
|
517
|
-
for (let i = 0; i < 10; i++) {
|
|
518
|
-
lastPromise = db.put(i, 'value' + i);
|
|
519
|
-
}
|
|
520
|
-
await lastPromise
|
|
521
|
-
let i = 0
|
|
522
|
-
for (let { key, value } of db.getRange()) {
|
|
523
|
-
key.should.equal(i);
|
|
524
|
-
value.should.equal('value' + i);
|
|
525
|
-
i++;
|
|
526
|
-
}
|
|
527
|
-
i = 0
|
|
528
|
-
for (let { key, value } of db.getRange({ start: 0 })) {
|
|
529
|
-
key.should.equal(i);
|
|
530
|
-
value.should.equal('value' + i);
|
|
531
|
-
i++;
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
after(function() {
|
|
535
|
-
db.close();
|
|
536
|
-
});
|
|
537
|
-
});
|
|
538
|
-
describe('ArrayLikeIterable', function() {
|
|
539
|
-
it('concat and iterate', async function() {
|
|
540
|
-
let a = new ArrayLikeIterable([1, 2, 3])
|
|
541
|
-
let b = new ArrayLikeIterable([4, 5, 6])
|
|
542
|
-
let all = []
|
|
543
|
-
for (let v of a.concat(b)) {
|
|
544
|
-
all.push(v)
|
|
545
|
-
}
|
|
546
|
-
all.should.deep.equal([1, 2, 3, 4, 5, 6])
|
|
547
|
-
});
|
|
548
|
-
});
|
|
549
|
-
describe('mixed keys', function() {
|
|
550
|
-
this.timeout(10000);
|
|
551
|
-
let intKeys, strKeys;
|
|
552
|
-
before(function() {
|
|
553
|
-
const rootDb = open({
|
|
554
|
-
name: `root`,
|
|
555
|
-
path: testDirPath + '/test-mixedkeys.mdb',
|
|
556
|
-
keyIsUint32: false,
|
|
557
|
-
})
|
|
558
|
-
|
|
559
|
-
intKeys = rootDb.openDB({
|
|
560
|
-
name: `intKeys`,
|
|
561
|
-
keyIsUint32: true,
|
|
562
|
-
})
|
|
563
|
-
|
|
564
|
-
strKeys = rootDb.openDB({
|
|
565
|
-
name: `strKeys`,
|
|
566
|
-
keyIsUint32: false,
|
|
567
|
-
})
|
|
568
|
-
|
|
569
|
-
})
|
|
570
|
-
it('create with keys', async function() {
|
|
571
|
-
let lastPromise
|
|
572
|
-
for (let intKey = 0; intKey < 100; intKey++) {
|
|
573
|
-
const strKey = `k${intKey}`
|
|
574
|
-
intKeys.put(intKey, `${intKey}-value`)
|
|
575
|
-
lastPromise = strKeys.put(strKey, `${strKey}-value`)
|
|
576
|
-
}
|
|
577
|
-
await lastPromise
|
|
578
|
-
});
|
|
579
|
-
});
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
function delay(ms) {
|
|
583
|
-
return new Promise(resolve => setTimeout(resolve, ms))
|
|
584
|
-
}
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
let path = require('path');
|
|
4
|
+
let mkdirp = require('mkdirp');
|
|
5
|
+
let rimraf = require('rimraf');
|
|
6
|
+
let chai = require('chai');
|
|
7
|
+
let should = chai.should();
|
|
8
|
+
let expect = chai.expect;
|
|
9
|
+
let spawn = require('child_process').spawn;
|
|
10
|
+
|
|
11
|
+
let { open, getLastVersion, bufferToKeyValue, keyValueToBuffer, ABORT } = require('..');
|
|
12
|
+
const { ArrayLikeIterable } = require('../util/ArrayLikeIterable')
|
|
13
|
+
//var inspector = require('inspector'); inspector.open(9330, null, true); debugger
|
|
14
|
+
|
|
15
|
+
describe('lmdb-store', function() {
|
|
16
|
+
let testDirPath = path.resolve(__dirname, './testdata-ls');
|
|
17
|
+
|
|
18
|
+
// just to make a reasonable sized chunk of data...
|
|
19
|
+
function expand(str) {
|
|
20
|
+
str = '(' + str + ')';
|
|
21
|
+
str = str + str;
|
|
22
|
+
str = str + str;
|
|
23
|
+
str = str + str;
|
|
24
|
+
str = str + str;
|
|
25
|
+
str = str + str;
|
|
26
|
+
return str;
|
|
27
|
+
}
|
|
28
|
+
before(function(done) {
|
|
29
|
+
// cleanup previous test directory
|
|
30
|
+
rimraf(testDirPath, function(err) {
|
|
31
|
+
if (err) {
|
|
32
|
+
return done(err);
|
|
33
|
+
}
|
|
34
|
+
done();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
let testIteration = 1
|
|
38
|
+
describe('Basic use', basicTests({ compression: false }));
|
|
39
|
+
describe('Basic use with encryption', basicTests({ compression: false, encryptionKey: 'Use this key to encrypt the data' }));
|
|
40
|
+
//describe('Check encrypted data', basicTests({ compression: false, checkLast: true }));
|
|
41
|
+
describe('Basic use with JSON', basicTests({ encoding: 'json' }));
|
|
42
|
+
describe('Basic use with ordered-binary', basicTests({ encoding: 'ordered-binary' }));
|
|
43
|
+
describe('Basic use with caching', basicTests({ cache: true }));
|
|
44
|
+
function basicTests(options) { return function() {
|
|
45
|
+
this.timeout(1000000);
|
|
46
|
+
let db, db2;
|
|
47
|
+
before(function() {
|
|
48
|
+
db = open(testDirPath + '/test-' + testIteration + '.mdb', Object.assign({
|
|
49
|
+
name: 'mydb3',
|
|
50
|
+
create: true,
|
|
51
|
+
useVersions: true,
|
|
52
|
+
//asyncTransactionOrder: 'strict',
|
|
53
|
+
compression: {
|
|
54
|
+
threshold: 256,
|
|
55
|
+
},
|
|
56
|
+
}, options));
|
|
57
|
+
testIteration++;
|
|
58
|
+
if (!options.checkLast)
|
|
59
|
+
db.clear();
|
|
60
|
+
db2 = db.openDB(Object.assign({
|
|
61
|
+
name: 'mydb4',
|
|
62
|
+
create: true,
|
|
63
|
+
dupSort: true,
|
|
64
|
+
}));
|
|
65
|
+
if (!options.checkLast)
|
|
66
|
+
db2.clear();
|
|
67
|
+
});
|
|
68
|
+
if (options.checkLast) {
|
|
69
|
+
it('encrypted data can not be accessed', function() {
|
|
70
|
+
let data = db.get('key1');
|
|
71
|
+
console.log({data})
|
|
72
|
+
data.should.deep.equal({foo: 1, bar: true})
|
|
73
|
+
})
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
it('query of keys', async function() {
|
|
77
|
+
let keys = [
|
|
78
|
+
Symbol.for('test'),
|
|
79
|
+
false,
|
|
80
|
+
true,
|
|
81
|
+
-33,
|
|
82
|
+
-1.1,
|
|
83
|
+
3.3,
|
|
84
|
+
5,
|
|
85
|
+
[5,4],
|
|
86
|
+
[5,55],
|
|
87
|
+
'hello',
|
|
88
|
+
['hello', 3],
|
|
89
|
+
['hello', 'world'],
|
|
90
|
+
[ 'uid', 'I-7l9ySkD-wAOULIjOEnb', 'Rwsu6gqOw8cqdCZG5_YNF' ],
|
|
91
|
+
'z'
|
|
92
|
+
]
|
|
93
|
+
for (let key of keys)
|
|
94
|
+
await db.put(key, 3);
|
|
95
|
+
let returnedKeys = []
|
|
96
|
+
for (let { key, value } of db.getRange({
|
|
97
|
+
start: Symbol.for('A')
|
|
98
|
+
})) {
|
|
99
|
+
returnedKeys.push(key)
|
|
100
|
+
}
|
|
101
|
+
keys.should.deep.equal(returnedKeys)
|
|
102
|
+
});
|
|
103
|
+
it('string', async function() {
|
|
104
|
+
await db.put('key1', 'Hello world!');
|
|
105
|
+
let data = db.get('key1');
|
|
106
|
+
data.should.equal('Hello world!');
|
|
107
|
+
await db.remove('key1')
|
|
108
|
+
let data2 = db.get('key1');
|
|
109
|
+
should.equal(data2, undefined);
|
|
110
|
+
});
|
|
111
|
+
it('string with version', async function() {
|
|
112
|
+
await db.put('key1', 'Hello world!', 53252);
|
|
113
|
+
let entry = db.getEntry('key1');
|
|
114
|
+
entry.value.should.equal('Hello world!');
|
|
115
|
+
entry.version.should.equal(53252);
|
|
116
|
+
(await db.remove('key1', 33)).should.equal(false);
|
|
117
|
+
entry = db.getEntry('key1');
|
|
118
|
+
entry.value.should.equal('Hello world!');
|
|
119
|
+
entry.version.should.equal(53252);
|
|
120
|
+
(await db.remove('key1', 53252)).should.equal(true);
|
|
121
|
+
entry = db.getEntry('key1');
|
|
122
|
+
should.equal(entry, undefined);
|
|
123
|
+
});
|
|
124
|
+
it('string with version branching', async function() {
|
|
125
|
+
await db.put('key1', 'Hello world!', 53252);
|
|
126
|
+
let entry = db.getEntry('key1');
|
|
127
|
+
entry.value.should.equal('Hello world!');
|
|
128
|
+
entry.version.should.equal(53252);
|
|
129
|
+
(await db.ifVersion('key1', 777, () => {
|
|
130
|
+
db.put('newKey', 'test', 6);
|
|
131
|
+
db2.put('keyB', 'test', 6);
|
|
132
|
+
})).should.equal(false);
|
|
133
|
+
should.equal(db.get('newKey'), undefined);
|
|
134
|
+
should.equal(db2.get('keyB'), undefined);
|
|
135
|
+
let result = (await db.ifVersion('key1', 53252, () => {
|
|
136
|
+
db.put('newKey', 'test', 6);
|
|
137
|
+
db2.put('keyB', 'test', 6);
|
|
138
|
+
}))
|
|
139
|
+
should.equal(db.get('newKey'), 'test')
|
|
140
|
+
should.equal(db2.get('keyB'), 'test')
|
|
141
|
+
should.equal(result, true);
|
|
142
|
+
result = await db.ifNoExists('key1', () => {
|
|
143
|
+
db.put('newKey', 'changed', 7);
|
|
144
|
+
})
|
|
145
|
+
should.equal(db.get('newKey'), 'test');
|
|
146
|
+
should.equal(result, false);
|
|
147
|
+
result = await db.ifNoExists('key-no-exist', () => {
|
|
148
|
+
db.put('newKey', 'changed', 7);
|
|
149
|
+
})
|
|
150
|
+
should.equal(db.get('newKey'), 'changed')
|
|
151
|
+
should.equal(result, true);
|
|
152
|
+
});
|
|
153
|
+
it('string with compression and versions', async function() {
|
|
154
|
+
let str = expand('Hello world!')
|
|
155
|
+
await db.put('key1', str, 53252);
|
|
156
|
+
let entry = db.getEntry('key1');
|
|
157
|
+
entry.value.should.equal(str);
|
|
158
|
+
entry.version.should.equal(53252);
|
|
159
|
+
(await db.remove('key1', 33)).should.equal(false);
|
|
160
|
+
let data = db.get('key1');
|
|
161
|
+
data.should.equal(str);
|
|
162
|
+
(await db.remove('key1', 53252)).should.equal(true);
|
|
163
|
+
data = db.get('key1');
|
|
164
|
+
should.equal(data, undefined);
|
|
165
|
+
});
|
|
166
|
+
if (options.encoding == 'ordered-binary')
|
|
167
|
+
return // no more tests need to be applied for this
|
|
168
|
+
it('store objects', async function() {
|
|
169
|
+
let dataIn = {foo: 3, bar: true}
|
|
170
|
+
await db.put('key1', dataIn);
|
|
171
|
+
let dataOut = db.get('key1');
|
|
172
|
+
dataOut.should.deep.equal(dataIn);
|
|
173
|
+
db.removeSync('not-there').should.equal(false);
|
|
174
|
+
});
|
|
175
|
+
it.skip('trigger sync commit', async function() {
|
|
176
|
+
let dataIn = {foo: 4, bar: false}
|
|
177
|
+
db.immediateBatchThreshold = 1
|
|
178
|
+
db.syncBatchThreshold = 1
|
|
179
|
+
await db.put('key1', dataIn);
|
|
180
|
+
await db.put('key2', dataIn);
|
|
181
|
+
db.immediateBatchThreshold = 100000
|
|
182
|
+
db.syncBatchThreshold = 1000000
|
|
183
|
+
let dataOut = db.get('key1');
|
|
184
|
+
dataOut.should.deep.equal(dataIn);
|
|
185
|
+
});
|
|
186
|
+
function iterateQuery(acrossTransactions) { return async () => {
|
|
187
|
+
let data1 = {foo: 1, bar: true}
|
|
188
|
+
let data2 = {foo: 2, bar: false}
|
|
189
|
+
db.put('key1', data1);
|
|
190
|
+
await db.put('key2', data2);
|
|
191
|
+
let count = 0
|
|
192
|
+
for (let { key, value } of db.getRange({start:'key', end:'keyz', snapshot: !acrossTransactions})) {
|
|
193
|
+
if (acrossTransactions)
|
|
194
|
+
await delay(10)
|
|
195
|
+
count++
|
|
196
|
+
switch(key) {
|
|
197
|
+
case 'key1': data1.should.deep.equal(value); break;
|
|
198
|
+
case 'key2': data2.should.deep.equal(value); break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
should.equal(count >= 2, true);
|
|
202
|
+
should.equal(db.getCount({start:'key', end:'keyz'}) >= 2, true);
|
|
203
|
+
}}
|
|
204
|
+
it('should iterate over query', iterateQuery(false));
|
|
205
|
+
it('should iterate over query, across transactions', iterateQuery(true));
|
|
206
|
+
it('should break out of query', async function() {
|
|
207
|
+
let data1 = {foo: 1, bar: true}
|
|
208
|
+
let data2 = {foo: 2, bar: false}
|
|
209
|
+
db.put('key1', data1);
|
|
210
|
+
await db.put('key2', data2);
|
|
211
|
+
let count = 0;
|
|
212
|
+
for (let { key, value } of db.getRange({start:'key', end:'keyz'})) {
|
|
213
|
+
if (count > 0)
|
|
214
|
+
break;
|
|
215
|
+
count++;
|
|
216
|
+
data1.should.deep.equal(value);
|
|
217
|
+
'key1'.should.equal(key);
|
|
218
|
+
}
|
|
219
|
+
count.should.equal(1);
|
|
220
|
+
});
|
|
221
|
+
it('should iterate over query with offset/limit', async function() {
|
|
222
|
+
let data1 = {foo: 1, bar: true}
|
|
223
|
+
let data2 = {foo: 2, bar: false}
|
|
224
|
+
let data3 = {foo: 3, bar: false}
|
|
225
|
+
db.put('key1', data1);
|
|
226
|
+
db.put('key2', data2);
|
|
227
|
+
await db.put('key3', data3);
|
|
228
|
+
let count = 0
|
|
229
|
+
for (let { key, value } of db.getRange({start:'key', end:'keyz', offset: 1, limit: 1})) {
|
|
230
|
+
count++
|
|
231
|
+
switch(key) {
|
|
232
|
+
case 'key2': data2.should.deep.equal(value); break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
count.should.equal(1)
|
|
236
|
+
count = 0
|
|
237
|
+
for (let { key, value } of db.getRange({start:'key', end:'keyz', offset: 3, limit: 3})) {
|
|
238
|
+
count++
|
|
239
|
+
}
|
|
240
|
+
count.should.equal(0)
|
|
241
|
+
for (let { key, value } of db.getRange({start:'key', end:'keyz', offset: 10, limit: 3})) {
|
|
242
|
+
count++
|
|
243
|
+
}
|
|
244
|
+
count.should.equal(0)
|
|
245
|
+
for (let { key, value } of db.getRange({start:'key', end:'keyz', offset: 2, limit: 3})) {
|
|
246
|
+
count++
|
|
247
|
+
switch(key) {
|
|
248
|
+
case 'key3': data3.should.deep.equal(value); break;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
count.should.equal(1)
|
|
252
|
+
});
|
|
253
|
+
it('should iterate over dupsort query, with removal', async function() {
|
|
254
|
+
let data1 = {foo: 1, bar: true}
|
|
255
|
+
let data2 = {foo: 2, bar: false}
|
|
256
|
+
let data3 = {foo: 3, bar: true}
|
|
257
|
+
db2.put('key1', data1);
|
|
258
|
+
db2.put('key1', data2);
|
|
259
|
+
db2.put('key1', data3);
|
|
260
|
+
await db2.put('key2', data3);
|
|
261
|
+
let count = 0;
|
|
262
|
+
for (let value of db2.getValues('key1')) {
|
|
263
|
+
count++
|
|
264
|
+
switch(count) {
|
|
265
|
+
case 1: data1.should.deep.equal(value); break;
|
|
266
|
+
case 2: data2.should.deep.equal(value); break;
|
|
267
|
+
case 3: data3.should.deep.equal(value); break;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
count.should.equal(3);
|
|
271
|
+
db2.getValuesCount('key1').should.equal(3);
|
|
272
|
+
await db2.remove('key1', data2);
|
|
273
|
+
count = 0;
|
|
274
|
+
for (let value of db2.getValues('key1')) {
|
|
275
|
+
count++;
|
|
276
|
+
switch(count) {
|
|
277
|
+
case 1: data1.should.deep.equal(value); break;
|
|
278
|
+
case 2: data3.should.deep.equal(value); break;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
count.should.equal(2)
|
|
282
|
+
db2.getValuesCount('key1').should.equal(2);
|
|
283
|
+
count = 0;
|
|
284
|
+
for (let value of db2.getValues('key1', { reverse: true })) {
|
|
285
|
+
count++;
|
|
286
|
+
switch(count) {
|
|
287
|
+
case 1: data3.should.deep.equal(value); break;
|
|
288
|
+
case 2: data1.should.deep.equal(value); break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
count.should.equal(2);
|
|
292
|
+
db2.getValuesCount('key1').should.equal(2);
|
|
293
|
+
|
|
294
|
+
count = 0;
|
|
295
|
+
for (let value of db2.getValues('key0')) {
|
|
296
|
+
count++;
|
|
297
|
+
}
|
|
298
|
+
count.should.equal(0);
|
|
299
|
+
db2.getValuesCount('key0').should.equal(0);
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it('doesExist', async function() {
|
|
303
|
+
let data1 = {foo: 1, bar: true}
|
|
304
|
+
let data2 = {foo: 2, bar: false}
|
|
305
|
+
let data3 = {foo: 3, bar: true}
|
|
306
|
+
db2.put('key1', data1);
|
|
307
|
+
db2.put('key1', data3);
|
|
308
|
+
db2.put(false, 3);
|
|
309
|
+
await db2.put('key2', data3);
|
|
310
|
+
should.equal(db2.doesExist('key1'), true);
|
|
311
|
+
should.equal(db2.doesExist('key1', data1), true);
|
|
312
|
+
should.equal(db2.doesExist('key1', data2), false);
|
|
313
|
+
should.equal(db2.doesExist('key1', data3), true);
|
|
314
|
+
should.equal(db2.doesExist(false), true);
|
|
315
|
+
should.equal(db2.doesExist(false, 3), true);
|
|
316
|
+
should.equal(db2.doesExist(false, 4), false);
|
|
317
|
+
})
|
|
318
|
+
it('should iterate over keys without duplicates', async function() {
|
|
319
|
+
let lastKey
|
|
320
|
+
for (let key of db2.getKeys({ start: 'k' })) {
|
|
321
|
+
if (key == lastKey)
|
|
322
|
+
throw new Error('duplicate key returned')
|
|
323
|
+
lastKey = key
|
|
324
|
+
}
|
|
325
|
+
})
|
|
326
|
+
it('invalid key', async function() {
|
|
327
|
+
expect(() => db.get({ foo: 'bar' })).to.throw();
|
|
328
|
+
//expect(() => db.put({ foo: 'bar' }, 'hello')).to.throw();
|
|
329
|
+
});
|
|
330
|
+
it('put options (sync)', function() {
|
|
331
|
+
db.putSync('zkey6', 'test', { append: true, version: 33 });
|
|
332
|
+
let entry = db.getEntry('zkey6');
|
|
333
|
+
entry.value.should.equal('test');
|
|
334
|
+
entry.version.should.equal(33);
|
|
335
|
+
db.putSync('zkey7', 'test', { append: true, noOverwrite: true });
|
|
336
|
+
db2.putSync('zkey6', 'test1', { appendDup: true });
|
|
337
|
+
db2.putSync('zkey6', 'test2', { appendDup: true });
|
|
338
|
+
expect(() => db.putSync('zkey5', 'test', { append: true, version: 44 })).to.throw();
|
|
339
|
+
expect(() => db.putSync('zkey7', 'test', { noOverwrite: true })).to.throw();
|
|
340
|
+
expect(() => db2.putSync('zkey6', 'test1', { noDupData: true })).to.throw();
|
|
341
|
+
});
|
|
342
|
+
it('async transactions', async function() {
|
|
343
|
+
let ranTransaction
|
|
344
|
+
db.put('key1', 'async initial value'); // should be queued for async write, but should put before queued transaction
|
|
345
|
+
let errorHandled
|
|
346
|
+
if (!db.cache) {
|
|
347
|
+
db.childTransaction(() => {
|
|
348
|
+
db.put('key1', 'should be rolled back');
|
|
349
|
+
throw new Error('Make sure this is properly propagated without interfering with next transaction')
|
|
350
|
+
}).catch(error => {
|
|
351
|
+
if (error)
|
|
352
|
+
errorHandled = true
|
|
353
|
+
})
|
|
354
|
+
await db.childTransaction(() => {
|
|
355
|
+
should.equal(db.get('key1'), 'async initial value');
|
|
356
|
+
db.put('key-a', 'async test a');
|
|
357
|
+
should.equal(db.get('key-a'), 'async test a');
|
|
358
|
+
})
|
|
359
|
+
should.equal(errorHandled, true);
|
|
360
|
+
}
|
|
361
|
+
await db.transactionAsync(() => {
|
|
362
|
+
ranTransaction = true;
|
|
363
|
+
should.equal(db.get('key1'), 'async initial value');
|
|
364
|
+
db.put('key1', 'async test 1');
|
|
365
|
+
should.equal(db.get('key1'), 'async test 1');
|
|
366
|
+
for (let { key, value } of db.getRange({start: 'key1', end: 'key1z' })) {
|
|
367
|
+
should.equal(value, 'async test 1');
|
|
368
|
+
}
|
|
369
|
+
db2.put('key2-async', 'async test 2');
|
|
370
|
+
should.equal(db2.get('key2-async'), 'async test 2');
|
|
371
|
+
});
|
|
372
|
+
should.equal(db.get('key1'), 'async test 1');
|
|
373
|
+
should.equal(db2.get('key2-async'), 'async test 2');
|
|
374
|
+
should.equal(ranTransaction, true);
|
|
375
|
+
});
|
|
376
|
+
it('child transaction in sync transaction', async function() {
|
|
377
|
+
if (db.cache)
|
|
378
|
+
return
|
|
379
|
+
await db.transactionSync(async () => {
|
|
380
|
+
db.put('key3', 'test-sync-txn');
|
|
381
|
+
db.childTransaction(() => {
|
|
382
|
+
db.put('key3', 'test-child-txn');
|
|
383
|
+
return ABORT;
|
|
384
|
+
})
|
|
385
|
+
should.equal(db.get('key3'), 'test-sync-txn');
|
|
386
|
+
db.childTransaction(() => {
|
|
387
|
+
db.put('key3', 'test-child-txn');
|
|
388
|
+
})
|
|
389
|
+
should.equal(db.get('key3'), 'test-child-txn');
|
|
390
|
+
await db.childTransaction(async () => {
|
|
391
|
+
await new Promise(resolve => setTimeout(resolve, 1))
|
|
392
|
+
db.put('key3', 'test-async-child-txn');
|
|
393
|
+
})
|
|
394
|
+
should.equal(db.get('key3'), 'test-async-child-txn');
|
|
395
|
+
})
|
|
396
|
+
});
|
|
397
|
+
it('async transaction with interrupting sync transaction default order', async function() {
|
|
398
|
+
db.strictAsyncOrder = false
|
|
399
|
+
let order = []
|
|
400
|
+
let ranSyncTxn
|
|
401
|
+
db.transactionAsync(() => {
|
|
402
|
+
order.push('a1');
|
|
403
|
+
db.put('async1', 'test');
|
|
404
|
+
if (!ranSyncTxn) {
|
|
405
|
+
ranSyncTxn = true;
|
|
406
|
+
setImmediate(() => db.transactionSync(() => {
|
|
407
|
+
order.push('s1');
|
|
408
|
+
db.put('inside-sync', 'test');
|
|
409
|
+
}));
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
db.put('outside-txn', 'test');
|
|
413
|
+
await db.transactionAsync(() => {
|
|
414
|
+
order.push('a2');
|
|
415
|
+
db.put('async2', 'test');
|
|
416
|
+
});
|
|
417
|
+
order.should.deep.equal(['a1', 'a2', 's1']);
|
|
418
|
+
should.equal(db.get('async1'), 'test');
|
|
419
|
+
should.equal(db.get('outside-txn'), 'test');
|
|
420
|
+
should.equal(db.get('inside-sync'), 'test');
|
|
421
|
+
should.equal(db.get('async2'), 'test');
|
|
422
|
+
});
|
|
423
|
+
it.skip('big child transactions', async function() {
|
|
424
|
+
let ranTransaction
|
|
425
|
+
db.put('key1', 'async initial value'); // should be queued for async write, but should put before queued transaction
|
|
426
|
+
let errorHandled
|
|
427
|
+
if (!db.cache) {
|
|
428
|
+
db.childTransaction(() => {
|
|
429
|
+
let value
|
|
430
|
+
for (let i = 0; i < 4; i++) {
|
|
431
|
+
value += ' test string ' + value
|
|
432
|
+
}
|
|
433
|
+
for (let i = 0; i < 4000; i++) {
|
|
434
|
+
db.put('key' + i, value)
|
|
435
|
+
}
|
|
436
|
+
})
|
|
437
|
+
await db.put('key1', 'test');
|
|
438
|
+
should.equal(db.get('key1'), 'test');
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
it('read and write with binary encoding', async function() {
|
|
442
|
+
let dbBinary = db.openDB(Object.assign({
|
|
443
|
+
name: 'mydb5',
|
|
444
|
+
create: true,
|
|
445
|
+
encoding: 'binary'
|
|
446
|
+
}));
|
|
447
|
+
dbBinary.put('buffer', Buffer.from('hello'));
|
|
448
|
+
dbBinary.put('empty', Buffer.from([]));
|
|
449
|
+
await dbBinary.put('Uint8Array', new Uint8Array([1,2,3]));
|
|
450
|
+
dbBinary.get('buffer').toString().should.equal('hello');
|
|
451
|
+
dbBinary.get('Uint8Array')[1].should.equal(2);
|
|
452
|
+
dbBinary.get('empty').length.should.equal(0);
|
|
453
|
+
});
|
|
454
|
+
it.skip('read and write with binary methods', async function() {
|
|
455
|
+
debugger
|
|
456
|
+
let dbBinary = db.openDB(Object.assign({
|
|
457
|
+
name: 'mydb6',
|
|
458
|
+
keyIsUint32: true,
|
|
459
|
+
create: true,
|
|
460
|
+
}));
|
|
461
|
+
dbBinary.put(3, Buffer.from('hello'));
|
|
462
|
+
await dbBinary.put(4, new Uint8Array([1,2,3]));
|
|
463
|
+
console.log(dbBinary.getBinaryLocation(3))
|
|
464
|
+
console.log(dbBinary.getBinaryLocation(4))
|
|
465
|
+
});
|
|
466
|
+
after(function(done) {
|
|
467
|
+
db.get('key1');
|
|
468
|
+
let iterator = db.getRange({})[Symbol.iterator]()
|
|
469
|
+
setTimeout(() => {
|
|
470
|
+
db.get('key1');
|
|
471
|
+
// should have open read and cursor transactions
|
|
472
|
+
db2.close();
|
|
473
|
+
db.close();
|
|
474
|
+
done();
|
|
475
|
+
},10);
|
|
476
|
+
});
|
|
477
|
+
}}
|
|
478
|
+
describe('direct key', function() {
|
|
479
|
+
it('should serialize and deserialize keys', function() {
|
|
480
|
+
let keys = [
|
|
481
|
+
Symbol.for('test'),
|
|
482
|
+
false,
|
|
483
|
+
true,
|
|
484
|
+
-33,
|
|
485
|
+
-1.1,
|
|
486
|
+
3.3,
|
|
487
|
+
5,
|
|
488
|
+
[5,4],
|
|
489
|
+
[5,55],
|
|
490
|
+
'hello',
|
|
491
|
+
['hello', 3],
|
|
492
|
+
['hello', 'world'],
|
|
493
|
+
[ 'uid', 'I-7l9ySkD-wAOULIjOEnb', 'Rwsu6gqOw8cqdCZG5_YNF' ],
|
|
494
|
+
'x'.repeat(1978),
|
|
495
|
+
'z'
|
|
496
|
+
]
|
|
497
|
+
let serializedKeys = []
|
|
498
|
+
for (let key of keys) {
|
|
499
|
+
let buffer = keyValueToBuffer(key)
|
|
500
|
+
serializedKeys.push(bufferToKeyValue(buffer))
|
|
501
|
+
}
|
|
502
|
+
serializedKeys.should.deep.equal(keys)
|
|
503
|
+
})
|
|
504
|
+
});
|
|
505
|
+
describe('uint32 keys', function() {
|
|
506
|
+
this.timeout(10000);
|
|
507
|
+
let db, db2;
|
|
508
|
+
before(function() {
|
|
509
|
+
db = open(testDirPath, {
|
|
510
|
+
name: 'uint32',
|
|
511
|
+
keyIsUint32: true,
|
|
512
|
+
compression: true,
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
it('write and read range', async function() {
|
|
516
|
+
let lastPromise
|
|
517
|
+
for (let i = 0; i < 10; i++) {
|
|
518
|
+
lastPromise = db.put(i, 'value' + i);
|
|
519
|
+
}
|
|
520
|
+
await lastPromise
|
|
521
|
+
let i = 0
|
|
522
|
+
for (let { key, value } of db.getRange()) {
|
|
523
|
+
key.should.equal(i);
|
|
524
|
+
value.should.equal('value' + i);
|
|
525
|
+
i++;
|
|
526
|
+
}
|
|
527
|
+
i = 0
|
|
528
|
+
for (let { key, value } of db.getRange({ start: 0 })) {
|
|
529
|
+
key.should.equal(i);
|
|
530
|
+
value.should.equal('value' + i);
|
|
531
|
+
i++;
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
after(function() {
|
|
535
|
+
db.close();
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
describe('ArrayLikeIterable', function() {
|
|
539
|
+
it('concat and iterate', async function() {
|
|
540
|
+
let a = new ArrayLikeIterable([1, 2, 3])
|
|
541
|
+
let b = new ArrayLikeIterable([4, 5, 6])
|
|
542
|
+
let all = []
|
|
543
|
+
for (let v of a.concat(b)) {
|
|
544
|
+
all.push(v)
|
|
545
|
+
}
|
|
546
|
+
all.should.deep.equal([1, 2, 3, 4, 5, 6])
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
describe('mixed keys', function() {
|
|
550
|
+
this.timeout(10000);
|
|
551
|
+
let intKeys, strKeys;
|
|
552
|
+
before(function() {
|
|
553
|
+
const rootDb = open({
|
|
554
|
+
name: `root`,
|
|
555
|
+
path: testDirPath + '/test-mixedkeys.mdb',
|
|
556
|
+
keyIsUint32: false,
|
|
557
|
+
})
|
|
558
|
+
|
|
559
|
+
intKeys = rootDb.openDB({
|
|
560
|
+
name: `intKeys`,
|
|
561
|
+
keyIsUint32: true,
|
|
562
|
+
})
|
|
563
|
+
|
|
564
|
+
strKeys = rootDb.openDB({
|
|
565
|
+
name: `strKeys`,
|
|
566
|
+
keyIsUint32: false,
|
|
567
|
+
})
|
|
568
|
+
|
|
569
|
+
})
|
|
570
|
+
it('create with keys', async function() {
|
|
571
|
+
let lastPromise
|
|
572
|
+
for (let intKey = 0; intKey < 100; intKey++) {
|
|
573
|
+
const strKey = `k${intKey}`
|
|
574
|
+
intKeys.put(intKey, `${intKey}-value`)
|
|
575
|
+
lastPromise = strKeys.put(strKey, `${strKey}-value`)
|
|
576
|
+
}
|
|
577
|
+
await lastPromise
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
function delay(ms) {
|
|
583
|
+
return new Promise(resolve => setTimeout(resolve, ms))
|
|
584
|
+
}
|