react-native-nitro-sqlite 9.1.7 → 9.1.8
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/cpp/specs/HybridNitroSQLite.cpp +2 -2
- package/cpp/specs/HybridNitroSQLite.hpp +2 -2
- package/cpp/sqliteExecuteBatch.cpp +1 -1
- package/cpp/sqliteExecuteBatch.hpp +2 -2
- package/lib/commonjs/index.js +30 -21
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nullHandling.js +33 -0
- package/lib/commonjs/nullHandling.js.map +1 -0
- package/lib/commonjs/operations/execute.js +7 -11
- package/lib/commonjs/operations/execute.js.map +1 -1
- package/lib/commonjs/operations/executeBatch.js +34 -0
- package/lib/commonjs/operations/executeBatch.js.map +1 -0
- package/lib/commonjs/operations/session.js +3 -2
- package/lib/commonjs/operations/session.js.map +1 -1
- package/lib/commonjs/types.js +4 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/index.js +5 -17
- package/lib/module/index.js.map +1 -1
- package/lib/module/nullHandling.js +25 -0
- package/lib/module/nullHandling.js.map +1 -0
- package/lib/module/operations/execute.js +5 -8
- package/lib/module/operations/execute.js.map +1 -1
- package/lib/module/operations/executeBatch.js +29 -0
- package/lib/module/operations/executeBatch.js.map +1 -0
- package/lib/module/operations/session.js +3 -2
- package/lib/module/operations/session.js.map +1 -1
- package/lib/module/types.js +6 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +4 -7
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/nullHandling.d.ts +8 -0
- package/lib/typescript/commonjs/nullHandling.d.ts.map +1 -0
- package/lib/typescript/commonjs/operations/execute.d.ts.map +1 -1
- package/lib/typescript/commonjs/operations/executeBatch.d.ts +4 -0
- package/lib/typescript/commonjs/operations/executeBatch.d.ts.map +1 -0
- package/lib/typescript/commonjs/operations/session.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/NitroSQLite.nitro.d.ts +3 -3
- package/lib/typescript/commonjs/specs/NitroSQLite.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +8 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +4 -7
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/nullHandling.d.ts +8 -0
- package/lib/typescript/module/nullHandling.d.ts.map +1 -0
- package/lib/typescript/module/operations/execute.d.ts.map +1 -1
- package/lib/typescript/module/operations/executeBatch.d.ts +4 -0
- package/lib/typescript/module/operations/executeBatch.d.ts.map +1 -0
- package/lib/typescript/module/operations/session.d.ts.map +1 -1
- package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts +3 -3
- package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +8 -0
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.hpp +5 -5
- package/nitrogen/generated/shared/c++/{BatchQueryCommand.hpp → NativeBatchQueryCommand.hpp} +10 -10
- package/package.json +1 -1
- package/src/index.ts +9 -19
- package/src/nullHandling.ts +31 -0
- package/src/operations/execute.ts +8 -12
- package/src/operations/executeBatch.ts +56 -0
- package/src/operations/session.ts +3 -2
- package/src/specs/NitroSQLite.nitro.ts +6 -3
- package/src/types.ts +10 -0
|
@@ -66,7 +66,7 @@ std::shared_ptr<Promise<std::shared_ptr<HybridNativeQueryResultSpec>>> HybridNit
|
|
|
66
66
|
});
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
BatchQueryResult HybridNitroSQLite::executeBatch(const std::string& dbName, const std::vector<
|
|
69
|
+
BatchQueryResult HybridNitroSQLite::executeBatch(const std::string& dbName, const std::vector<NativeBatchQueryCommand>& batchParams) {
|
|
70
70
|
const auto commands = batchParamsToCommands(batchParams);
|
|
71
71
|
|
|
72
72
|
auto result = sqliteExecuteBatch(dbName, commands);
|
|
@@ -74,7 +74,7 @@ BatchQueryResult HybridNitroSQLite::executeBatch(const std::string& dbName, cons
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
std::shared_ptr<Promise<BatchQueryResult>> HybridNitroSQLite::executeBatchAsync(const std::string& dbName,
|
|
77
|
-
const std::vector<
|
|
77
|
+
const std::vector<NativeBatchQueryCommand>& batchParams) {
|
|
78
78
|
return Promise<BatchQueryResult>::async([=, this]() -> BatchQueryResult {
|
|
79
79
|
auto result = executeBatch(dbName, batchParams);
|
|
80
80
|
return result;
|
|
@@ -32,8 +32,8 @@ public:
|
|
|
32
32
|
|
|
33
33
|
std::shared_ptr<Promise<std::shared_ptr<HybridNativeQueryResultSpec>>> executeAsync(const std::string& dbName, const std::string& query, const std::optional<SQLiteQueryParams>& params) override;
|
|
34
34
|
|
|
35
|
-
BatchQueryResult executeBatch(const std::string& dbName, const std::vector<
|
|
36
|
-
std::shared_ptr<Promise<BatchQueryResult>> executeBatchAsync(const std::string& dbName, const std::vector<
|
|
35
|
+
BatchQueryResult executeBatch(const std::string& dbName, const std::vector<NativeBatchQueryCommand>& commands) override;
|
|
36
|
+
std::shared_ptr<Promise<BatchQueryResult>> executeBatchAsync(const std::string& dbName, const std::vector<NativeBatchQueryCommand>& commands) override;
|
|
37
37
|
|
|
38
38
|
FileLoadResult loadFile(const std::string& dbName, const std::string& location) override;
|
|
39
39
|
std::shared_ptr<Promise<FileLoadResult>> loadFileAsync(const std::string& dbName, const std::string& location) override;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
namespace margelo::rnnitrosqlite {
|
|
10
10
|
|
|
11
|
-
std::vector<BatchQuery> batchParamsToCommands(const std::vector<
|
|
11
|
+
std::vector<BatchQuery> batchParamsToCommands(const std::vector<NativeBatchQueryCommand>& batchParams) {
|
|
12
12
|
auto commands = std::vector<BatchQuery>();
|
|
13
13
|
|
|
14
14
|
for (auto& command : batchParams) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
#pragma once
|
|
5
5
|
|
|
6
|
-
#include "
|
|
6
|
+
#include "NativeBatchQueryCommand.hpp"
|
|
7
7
|
#include "types.hpp"
|
|
8
8
|
|
|
9
9
|
using namespace facebook;
|
|
@@ -20,7 +20,7 @@ struct BatchQuery {
|
|
|
20
20
|
* Local Helper method to translate JSI objects BatchQuery datastructure
|
|
21
21
|
* MUST be called in the JavaScript Thread
|
|
22
22
|
*/
|
|
23
|
-
std::vector<BatchQuery> batchParamsToCommands(const std::vector<
|
|
23
|
+
std::vector<BatchQuery> batchParamsToCommands(const std::vector<NativeBatchQueryCommand>& batchParams);
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Execute a batch of commands in a exclusive transaction
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,10 +3,31 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
Object.defineProperty(exports, "NITRO_SQLITE_NULL", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _nullHandling.NITRO_SQLITE_NULL;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.NitroSQLite = void 0;
|
|
13
|
+
Object.defineProperty(exports, "enableSimpleNullHandling", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _nullHandling.enableSimpleNullHandling;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "isNitroSQLiteNull", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _nullHandling.isNitroSQLiteNull;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "isSimpleNullHandlingEnabled", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _nullHandling.isSimpleNullHandlingEnabled;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
10
31
|
Object.defineProperty(exports, "open", {
|
|
11
32
|
enumerable: true,
|
|
12
33
|
get: function () {
|
|
@@ -24,7 +45,9 @@ var _nitro = require("./nitro.js");
|
|
|
24
45
|
var _session = require("./operations/session.js");
|
|
25
46
|
var _execute = require("./operations/execute.js");
|
|
26
47
|
var _OnLoad = require("./OnLoad");
|
|
48
|
+
var _executeBatch = require("./operations/executeBatch.js");
|
|
27
49
|
var _typeORM = require("./typeORM.js");
|
|
50
|
+
var _nullHandling = require("./nullHandling.js");
|
|
28
51
|
(0, _OnLoad.init)();
|
|
29
52
|
const NitroSQLite = exports.NitroSQLite = {
|
|
30
53
|
..._nitro.HybridNitroSQLite,
|
|
@@ -35,22 +58,8 @@ const NitroSQLite = exports.NitroSQLite = {
|
|
|
35
58
|
// More JS abstractions, that perform type casting and validation.
|
|
36
59
|
transaction: _transaction.transaction,
|
|
37
60
|
execute: _execute.execute,
|
|
38
|
-
executeAsync: _execute.executeAsync
|
|
61
|
+
executeAsync: _execute.executeAsync,
|
|
62
|
+
executeBatch: _executeBatch.executeBatch,
|
|
63
|
+
executeBatchAsync: _executeBatch.executeBatchAsync
|
|
39
64
|
};
|
|
40
|
-
let ENABLE_SIMPLE_NULL_HANDLING = false;
|
|
41
|
-
function enableSimpleNullHandling(shouldEnableSimpleNullHandling = true) {
|
|
42
|
-
ENABLE_SIMPLE_NULL_HANDLING = shouldEnableSimpleNullHandling;
|
|
43
|
-
}
|
|
44
|
-
function isSimpleNullHandlingEnabled() {
|
|
45
|
-
return ENABLE_SIMPLE_NULL_HANDLING;
|
|
46
|
-
}
|
|
47
|
-
const NITRO_SQLITE_NULL = exports.NITRO_SQLITE_NULL = {
|
|
48
|
-
isNitroSQLiteNull: true
|
|
49
|
-
};
|
|
50
|
-
function isNitroSQLiteNull(value) {
|
|
51
|
-
if (typeof value === 'object' && 'isNitroSQLiteNull' in value) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
65
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_transaction","require","_nitro","_session","_execute","_OnLoad","_typeORM","init","NitroSQLite","exports","HybridNitroSQLite","native","open","transaction","execute","executeAsync","
|
|
1
|
+
{"version":3,"names":["_transaction","require","_nitro","_session","_execute","_OnLoad","_executeBatch","_typeORM","_nullHandling","init","NitroSQLite","exports","HybridNitroSQLite","native","open","transaction","execute","executeAsync","executeBatch","executeBatchAsync"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAEA,IAAAM,QAAA,GAAAN,OAAA;AAmBA,IAAAO,aAAA,GAAAP,OAAA;AAjBA,IAAAQ,YAAI,EAAC,CAAC;AAEC,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACzB,GAAGE,wBAAiB;EACpBC,MAAM,EAAED,wBAAiB;EACzB;EACA;EACAE,IAAI,EAAJA,aAAI;EACJ;EACAC,WAAW,EAAXA,wBAAW;EACXC,OAAO,EAAPA,gBAAO;EACPC,YAAY,EAAZA,qBAAY;EACZC,YAAY,EAAZA,0BAAY;EACZC,iBAAiB,EAAjBA;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NITRO_SQLITE_NULL = void 0;
|
|
7
|
+
exports.enableSimpleNullHandling = enableSimpleNullHandling;
|
|
8
|
+
exports.isNitroSQLiteNull = isNitroSQLiteNull;
|
|
9
|
+
exports.isSimpleNullHandlingEnabled = isSimpleNullHandlingEnabled;
|
|
10
|
+
exports.replaceWithNativeNullValue = replaceWithNativeNullValue;
|
|
11
|
+
let ENABLE_SIMPLE_NULL_HANDLING = false;
|
|
12
|
+
function enableSimpleNullHandling(shouldEnableSimpleNullHandling = true) {
|
|
13
|
+
ENABLE_SIMPLE_NULL_HANDLING = shouldEnableSimpleNullHandling;
|
|
14
|
+
}
|
|
15
|
+
function isSimpleNullHandlingEnabled() {
|
|
16
|
+
return ENABLE_SIMPLE_NULL_HANDLING;
|
|
17
|
+
}
|
|
18
|
+
const NITRO_SQLITE_NULL = exports.NITRO_SQLITE_NULL = {
|
|
19
|
+
isNitroSQLiteNull: true
|
|
20
|
+
};
|
|
21
|
+
function isNitroSQLiteNull(value) {
|
|
22
|
+
if (typeof value === 'object' && 'isNitroSQLiteNull' in value) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
function replaceWithNativeNullValue(value) {
|
|
28
|
+
if (value === undefined || value === null) {
|
|
29
|
+
return NITRO_SQLITE_NULL;
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=nullHandling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ENABLE_SIMPLE_NULL_HANDLING","enableSimpleNullHandling","shouldEnableSimpleNullHandling","isSimpleNullHandlingEnabled","NITRO_SQLITE_NULL","exports","isNitroSQLiteNull","value","replaceWithNativeNullValue","undefined"],"sourceRoot":"../../src","sources":["nullHandling.ts"],"mappings":";;;;;;;;;;AAGA,IAAIA,2BAA2B,GAAG,KAAK;AAEhC,SAASC,wBAAwBA,CACtCC,8BAA8B,GAAG,IAAI,EACrC;EACAF,2BAA2B,GAAGE,8BAA8B;AAC9D;AAEO,SAASC,2BAA2BA,CAAA,EAAG;EAC5C,OAAOH,2BAA2B;AACpC;AAEO,MAAMI,iBAAkC,GAAAC,OAAA,CAAAD,iBAAA,GAAG;EAAEE,iBAAiB,EAAE;AAAK,CAAC;AACtE,SAASA,iBAAiBA,CAACC,KAAU,EAA4B;EACtE,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,mBAAmB,IAAIA,KAAK,EAAE;IAC7D,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd;AAEO,SAASC,0BAA0BA,CACxCD,KAA2B,EACd;EACb,IAAIA,KAAK,KAAKE,SAAS,IAAIF,KAAK,KAAK,IAAI,EAAE;IACzC,OAAOH,iBAAiB;EAC1B;EACA,OAAOG,KAAK;AACd","ignoreList":[]}
|
|
@@ -5,26 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.execute = execute;
|
|
7
7
|
exports.executeAsync = executeAsync;
|
|
8
|
-
var
|
|
8
|
+
var _nullHandling = require("../nullHandling.js");
|
|
9
9
|
var _nitro = require("../nitro.js");
|
|
10
10
|
function execute(dbName, query, params) {
|
|
11
|
-
const
|
|
11
|
+
const transformedParams = (0, _nullHandling.isSimpleNullHandlingEnabled)() ? toNativeQueryParams(params) : params;
|
|
12
|
+
const nativeResult = _nitro.HybridNitroSQLite.execute(dbName, query, transformedParams);
|
|
12
13
|
const result = buildJsQueryResult(nativeResult);
|
|
13
14
|
return result;
|
|
14
15
|
}
|
|
15
16
|
async function executeAsync(dbName, query, params) {
|
|
16
|
-
const transformedParams = (0,
|
|
17
|
+
const transformedParams = (0, _nullHandling.isSimpleNullHandlingEnabled)() ? toNativeQueryParams(params) : params;
|
|
17
18
|
const nativeResult = await _nitro.HybridNitroSQLite.executeAsync(dbName, query, transformedParams);
|
|
18
19
|
const result = buildJsQueryResult(nativeResult);
|
|
19
20
|
return result;
|
|
20
21
|
}
|
|
21
22
|
function toNativeQueryParams(params) {
|
|
22
|
-
return params?.map(param =>
|
|
23
|
-
if (param === undefined || param === null) {
|
|
24
|
-
return _index.NITRO_SQLITE_NULL;
|
|
25
|
-
}
|
|
26
|
-
return param;
|
|
27
|
-
});
|
|
23
|
+
return params?.map(param => (0, _nullHandling.replaceWithNativeNullValue)(param));
|
|
28
24
|
}
|
|
29
25
|
function buildJsQueryResult({
|
|
30
26
|
insertId,
|
|
@@ -32,9 +28,9 @@ function buildJsQueryResult({
|
|
|
32
28
|
results
|
|
33
29
|
}) {
|
|
34
30
|
let data = results;
|
|
35
|
-
if ((0,
|
|
31
|
+
if ((0, _nullHandling.isSimpleNullHandlingEnabled)()) {
|
|
36
32
|
data = results.map(row => Object.fromEntries(Object.entries(row).map(([key, value]) => {
|
|
37
|
-
if ((0,
|
|
33
|
+
if ((0, _nullHandling.isNitroSQLiteNull)(value)) {
|
|
38
34
|
return [key, null];
|
|
39
35
|
}
|
|
40
36
|
return [key, value];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_nullHandling","require","_nitro","execute","dbName","query","params","transformedParams","isSimpleNullHandlingEnabled","toNativeQueryParams","nativeResult","HybridNitroSQLite","result","buildJsQueryResult","executeAsync","map","param","replaceWithNativeNullValue","insertId","rowsAffected","results","data","row","Object","fromEntries","entries","key","value","isNitroSQLiteNull","rows","_array","length","item","idx"],"sourceRoot":"../../../src","sources":["operations/execute.ts"],"mappings":";;;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAUO,SAASE,OAAOA,CACrBC,MAAc,EACdC,KAAa,EACbC,MAA0B,EACR;EAClB,MAAMC,iBAAiB,GAAG,IAAAC,yCAA2B,EAAC,CAAC,GACnDC,mBAAmB,CAACH,MAAM,CAAC,GAC1BA,MAAkC;EAEvC,MAAMI,YAAY,GAAGC,wBAAiB,CAACR,OAAO,CAC5CC,MAAM,EACNC,KAAK,EACLE,iBACF,CAAC;EACD,MAAMK,MAAM,GAAGC,kB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,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.executeBatch = executeBatch;
|
|
7
|
+
exports.executeBatchAsync = executeBatchAsync;
|
|
8
|
+
var _nullHandling = require("../nullHandling.js");
|
|
9
|
+
var _nitro = require("../nitro.js");
|
|
10
|
+
function executeBatch(dbName, commands) {
|
|
11
|
+
const transformedCommands = (0, _nullHandling.isSimpleNullHandlingEnabled)() ? toNativeBatchQueryCommands(commands) : commands;
|
|
12
|
+
const result = _nitro.HybridNitroSQLite.executeBatch(dbName, transformedCommands);
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
async function executeBatchAsync(dbName, commands) {
|
|
16
|
+
const transformedCommands = (0, _nullHandling.isSimpleNullHandlingEnabled)() ? toNativeBatchQueryCommands(commands) : commands;
|
|
17
|
+
const result = await _nitro.HybridNitroSQLite.executeBatchAsync(dbName, transformedCommands);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
function toNativeBatchQueryCommands(commands) {
|
|
21
|
+
return commands.map(command => {
|
|
22
|
+
const transformedParams = command.params?.map(param => {
|
|
23
|
+
if (Array.isArray(param)) {
|
|
24
|
+
return param.map(p => (0, _nullHandling.replaceWithNativeNullValue)(p));
|
|
25
|
+
}
|
|
26
|
+
return (0, _nullHandling.replaceWithNativeNullValue)(param);
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
query: command.query,
|
|
30
|
+
params: transformedParams
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=executeBatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_nullHandling","require","_nitro","executeBatch","dbName","commands","transformedCommands","isSimpleNullHandlingEnabled","toNativeBatchQueryCommands","result","HybridNitroSQLite","executeBatchAsync","map","command","transformedParams","params","param","Array","isArray","p","replaceWithNativeNullValue","query"],"sourceRoot":"../../../src","sources":["operations/executeBatch.ts"],"mappings":";;;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAQO,SAASE,YAAYA,CAC1BC,MAAc,EACdC,QAA6B,EACX;EAClB,MAAMC,mBAAmB,GAAG,IAAAC,yCAA2B,EAAC,CAAC,GACrDC,0BAA0B,CAACH,QAAQ,CAAC,GACnCA,QAAsC;EAE3C,MAAMI,MAAM,GAAGC,wBAAiB,CAACP,YAAY,CAACC,MAAM,EAAEE,mBAAmB,CAAC;EAC1E,OAAOG,MAAM;AACf;AAEO,eAAeE,iBAAiBA,CACrCP,MAAc,EACdC,QAA6B,EACF;EAC3B,MAAMC,mBAAmB,GAAG,IAAAC,yCAA2B,EAAC,CAAC,GACrDC,0BAA0B,CAACH,QAAQ,CAAC,GACnCA,QAAsC;EAE3C,MAAMI,MAAM,GAAG,MAAMC,wBAAiB,CAACC,iBAAiB,CACtDP,MAAM,EACNE,mBACF,CAAC;EACD,OAAOG,MAAM;AACf;AAEA,SAASD,0BAA0BA,CACjCH,QAA6B,EACF;EAC3B,OAAOA,QAAQ,CAACO,GAAG,CAAEC,OAAO,IAAK;IAC/B,MAAMC,iBAAiB,GAAGD,OAAO,CAACE,MAAM,EAAEH,GAAG,CAAEI,KAAK,IAAK;MACvD,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;QACxB,OAAOA,KAAK,CAACJ,GAAG,CAAEO,CAAC,IAAK,IAAAC,wCAA0B,EAACD,CAAC,CAAC,CAAC;MACxD;MACA,OAAO,IAAAC,wCAA0B,EAACJ,KAAK,CAAC;IAC1C,CAAC,CAAwD;IAEzD,OAAO;MACLK,KAAK,EAAER,OAAO,CAACQ,KAAK;MACpBN,MAAM,EAAED;IACV,CAAC;EACH,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -9,6 +9,7 @@ exports.openDb = openDb;
|
|
|
9
9
|
var _nitro = require("../nitro.js");
|
|
10
10
|
var _transaction = require("./transaction.js");
|
|
11
11
|
var _execute = require("./execute.js");
|
|
12
|
+
var _executeBatch = require("./executeBatch.js");
|
|
12
13
|
function open(options) {
|
|
13
14
|
openDb(options.name, options.location);
|
|
14
15
|
return {
|
|
@@ -19,8 +20,8 @@ function open(options) {
|
|
|
19
20
|
transaction: fn => (0, _transaction.transaction)(options.name, fn),
|
|
20
21
|
execute: (query, params) => (0, _execute.execute)(options.name, query, params),
|
|
21
22
|
executeAsync: (query, params) => (0, _execute.executeAsync)(options.name, query, params),
|
|
22
|
-
executeBatch: commands =>
|
|
23
|
-
executeBatchAsync: commands =>
|
|
23
|
+
executeBatch: commands => (0, _executeBatch.executeBatch)(options.name, commands),
|
|
24
|
+
executeBatchAsync: commands => (0, _executeBatch.executeBatchAsync)(options.name, commands),
|
|
24
25
|
loadFile: location => _nitro.HybridNitroSQLite.loadFile(options.name, location),
|
|
25
26
|
loadFileAsync: location => _nitro.HybridNitroSQLite.loadFileAsync(options.name, location)
|
|
26
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_nitro","require","_transaction","_execute","open","options","openDb","name","location","close","delete","HybridNitroSQLite","drop","attach","dbNameToAttach","alias","detach","transaction","fn","execute","query","params","executeAsync","executeBatch","commands","executeBatchAsync","loadFile","loadFileAsync","dbName","locks","queue","inProgress"],"sourceRoot":"../../../src","sources":["operations/session.ts"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAUA,IAAAE,QAAA,GAAAF,OAAA;AAEO,
|
|
1
|
+
{"version":3,"names":["_nitro","require","_transaction","_execute","_executeBatch","open","options","openDb","name","location","close","delete","HybridNitroSQLite","drop","attach","dbNameToAttach","alias","detach","transaction","fn","execute","query","params","executeAsync","executeBatch","commands","executeBatchAsync","loadFile","loadFileAsync","dbName","locks","que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AAiB,EAACpB,OAAO,CAACE,IAAI,EAAEiB,QAAQ,CAAC;IAC3CE,QAAQ,EAAGlB,QAAgB,IACzBG,wBAAiB,CAACe,QAAQ,CAACrB,OAAO,CAACE,IAAI,EAAEC,QAAQ,CAAC;IACpDmB,aAAa,EAAGnB,QAAgB,IAC9BG,wBAAiB,CAACgB,aAAa,CAACtB,OAAO,CAACE,IAAI,EAAEC,QAAQ;EAC1D,CAAC;AACH;AAEO,SAASF,MAAMA,CAACsB,MAAc,EAAEpB,QAAiB,EAAE;EACxDG,wBAAiB,CAACP,IAAI,CAACwB,MAAM,EAAEpB,QAAQ,CAAC;EAExCqB,YAAK,CAACD,MAAM,CAAC,GAAG;IACdE,KAAK,EAAE,EAAE;IACTC,UAAU,EAAE;EACd,CAAC;AACH;AAEO,SAAStB,KAAKA,CAACmB,MAAc,EAAE;EACpCjB,wBAAiB,CAACF,KAAK,CAACmB,MAAM,CAAC;EAC/B,OAAOC,YAAK,CAACD,MAAM,CAAC;AACtB","ignoreList":[]}
|
package/lib/commonjs/types.js
CHANGED
|
@@ -13,6 +13,7 @@ let ColumnType = exports.ColumnType = /*#__PURE__*/function (ColumnType) {
|
|
|
13
13
|
ColumnType[ColumnType["NULL_VALUE"] = 5] = "NULL_VALUE";
|
|
14
14
|
return ColumnType;
|
|
15
15
|
}({}); // Passing null/undefined in array types is not possible, so we us a special struct as a workaround.
|
|
16
|
+
/** Used internally to transform the query params into a native format without nullish values */
|
|
16
17
|
/**
|
|
17
18
|
* Represents a value that can be stored in a SQLite database
|
|
18
19
|
*/
|
|
@@ -22,6 +23,9 @@ let ColumnType = exports.ColumnType = /*#__PURE__*/function (ColumnType) {
|
|
|
22
23
|
* If a single query must be executed many times with different arguments, its preferred
|
|
23
24
|
* to declare it a single time, and use an array of array parameters.
|
|
24
25
|
*/
|
|
26
|
+
/**
|
|
27
|
+
* Used internally to transform the batch query commands into a native format without nullish values
|
|
28
|
+
*/
|
|
25
29
|
/**
|
|
26
30
|
* status: 0 or undefined for correct execution, 1 for error
|
|
27
31
|
* message: if status === 1, here you will find error description
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ColumnType","exports"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;;;;;IAmBYA,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA,OAStB;
|
|
1
|
+
{"version":3,"names":["ColumnType","exports"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;;;;;IAmBYA,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA,OAStB;AAWA;AAGA;AACA;AACA;AAwCA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { HybridNitroSQLite } from "./nitro.js";
|
|
|
5
5
|
import { open } from "./operations/session.js";
|
|
6
6
|
import { execute, executeAsync } from "./operations/execute.js";
|
|
7
7
|
import { init } from './OnLoad';
|
|
8
|
+
import { executeBatch, executeBatchAsync } from "./operations/executeBatch.js";
|
|
8
9
|
export { typeORMDriver } from "./typeORM.js";
|
|
9
10
|
init();
|
|
10
11
|
export const NitroSQLite = {
|
|
@@ -16,23 +17,10 @@ export const NitroSQLite = {
|
|
|
16
17
|
// More JS abstractions, that perform type casting and validation.
|
|
17
18
|
transaction,
|
|
18
19
|
execute,
|
|
19
|
-
executeAsync
|
|
20
|
+
executeAsync,
|
|
21
|
+
executeBatch,
|
|
22
|
+
executeBatchAsync
|
|
20
23
|
};
|
|
21
24
|
export { open } from "./operations/session.js";
|
|
22
|
-
|
|
23
|
-
export function enableSimpleNullHandling(shouldEnableSimpleNullHandling = true) {
|
|
24
|
-
ENABLE_SIMPLE_NULL_HANDLING = shouldEnableSimpleNullHandling;
|
|
25
|
-
}
|
|
26
|
-
export function isSimpleNullHandlingEnabled() {
|
|
27
|
-
return ENABLE_SIMPLE_NULL_HANDLING;
|
|
28
|
-
}
|
|
29
|
-
export const NITRO_SQLITE_NULL = {
|
|
30
|
-
isNitroSQLiteNull: true
|
|
31
|
-
};
|
|
32
|
-
export function isNitroSQLiteNull(value) {
|
|
33
|
-
if (typeof value === 'object' && 'isNitroSQLiteNull' in value) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
25
|
+
export { isNitroSQLiteNull, NITRO_SQLITE_NULL, isSimpleNullHandlingEnabled, enableSimpleNullHandling } from "./nullHandling.js";
|
|
38
26
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["transaction","HybridNitroSQLite","open","execute","executeAsync","init","
|
|
1
|
+
{"version":3,"names":["transaction","HybridNitroSQLite","open","execute","executeAsync","init","executeBatch","executeBatchAsync","typeORMDriver","NitroSQLite","native","isNitroSQLiteNull","NITRO_SQLITE_NULL","isSimpleNullHandlingEnabled","enableSimpleNullHandling"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,6BAA0B;AACtD,SAASC,iBAAiB,QAAQ,YAAS;AAC3C,SAASC,IAAI,QAAQ,yBAAsB;AAC3C,SAASC,OAAO,EAAEC,YAAY,QAAQ,yBAAsB;AAC5D,SAASC,IAAI,QAAQ,UAAU;AAC/B,SAASC,YAAY,EAAEC,iBAAiB,QAAQ,8BAA2B;AAE3E,SAASC,aAAa,QAAQ,cAAW;AAEzCH,IAAI,CAAC,CAAC;AAEN,OAAO,MAAMI,WAAW,GAAG;EACzB,GAAGR,iBAAiB;EACpBS,MAAM,EAAET,iBAAiB;EACzB;EACA;EACAC,IAAI;EACJ;EACAF,WAAW;EACXG,OAAO;EACPC,YAAY;EACZE,YAAY;EACZC;AACF,CAAC;AAED,SAASL,IAAI,QAAQ,yBAAsB;AAC3C,SACES,iBAAiB,EACjBC,iBAAiB,EACjBC,2BAA2B,EAC3BC,wBAAwB,QACnB,mBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
let ENABLE_SIMPLE_NULL_HANDLING = false;
|
|
4
|
+
export function enableSimpleNullHandling(shouldEnableSimpleNullHandling = true) {
|
|
5
|
+
ENABLE_SIMPLE_NULL_HANDLING = shouldEnableSimpleNullHandling;
|
|
6
|
+
}
|
|
7
|
+
export function isSimpleNullHandlingEnabled() {
|
|
8
|
+
return ENABLE_SIMPLE_NULL_HANDLING;
|
|
9
|
+
}
|
|
10
|
+
export const NITRO_SQLITE_NULL = {
|
|
11
|
+
isNitroSQLiteNull: true
|
|
12
|
+
};
|
|
13
|
+
export function isNitroSQLiteNull(value) {
|
|
14
|
+
if (typeof value === 'object' && 'isNitroSQLiteNull' in value) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
export function replaceWithNativeNullValue(value) {
|
|
20
|
+
if (value === undefined || value === null) {
|
|
21
|
+
return NITRO_SQLITE_NULL;
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=nullHandling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ENABLE_SIMPLE_NULL_HANDLING","enableSimpleNullHandling","shouldEnableSimpleNullHandling","isSimpleNullHandlingEnabled","NITRO_SQLITE_NULL","isNitroSQLiteNull","value","replaceWithNativeNullValue","undefined"],"sourceRoot":"../../src","sources":["nullHandling.ts"],"mappings":";;AAGA,IAAIA,2BAA2B,GAAG,KAAK;AAEvC,OAAO,SAASC,wBAAwBA,CACtCC,8BAA8B,GAAG,IAAI,EACrC;EACAF,2BAA2B,GAAGE,8BAA8B;AAC9D;AAEA,OAAO,SAASC,2BAA2BA,CAAA,EAAG;EAC5C,OAAOH,2BAA2B;AACpC;AAEA,OAAO,MAAMI,iBAAkC,GAAG;EAAEC,iBAAiB,EAAE;AAAK,CAAC;AAC7E,OAAO,SAASA,iBAAiBA,CAACC,KAAU,EAA4B;EACtE,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,mBAAmB,IAAIA,KAAK,EAAE;IAC7D,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd;AAEA,OAAO,SAASC,0BAA0BA,CACxCD,KAA2B,EACd;EACb,IAAIA,KAAK,KAAKE,SAAS,IAAIF,KAAK,KAAK,IAAI,EAAE;IACzC,OAAOF,iBAAiB;EAC1B;EACA,OAAOE,KAAK;AACd","ignoreList":[]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { isNitroSQLiteNull, isSimpleNullHandlingEnabled } from "../nullHandling.js";
|
|
4
4
|
import { HybridNitroSQLite } from "../nitro.js";
|
|
5
|
+
import { replaceWithNativeNullValue } from "../nullHandling.js";
|
|
5
6
|
export function execute(dbName, query, params) {
|
|
6
|
-
const
|
|
7
|
+
const transformedParams = isSimpleNullHandlingEnabled() ? toNativeQueryParams(params) : params;
|
|
8
|
+
const nativeResult = HybridNitroSQLite.execute(dbName, query, transformedParams);
|
|
7
9
|
const result = buildJsQueryResult(nativeResult);
|
|
8
10
|
return result;
|
|
9
11
|
}
|
|
@@ -14,12 +16,7 @@ export async function executeAsync(dbName, query, params) {
|
|
|
14
16
|
return result;
|
|
15
17
|
}
|
|
16
18
|
function toNativeQueryParams(params) {
|
|
17
|
-
return params?.map(param =>
|
|
18
|
-
if (param === undefined || param === null) {
|
|
19
|
-
return NITRO_SQLITE_NULL;
|
|
20
|
-
}
|
|
21
|
-
return param;
|
|
22
|
-
});
|
|
19
|
+
return params?.map(param => replaceWithNativeNullValue(param));
|
|
23
20
|
}
|
|
24
21
|
function buildJsQueryResult({
|
|
25
22
|
insertId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["isNitroSQLiteNull","isSimpleNullHandlingEnabled","HybridNitroSQLite","replaceWithNativeNullValue","execute","dbName","query","params","transformedParams","toNativeQueryParams","nativeResult","result","buildJsQueryResult","executeAsync","map","param","insertId","rowsAffected","results","data","row","Object","fromEntries","entries","key","value","rows","_array","length","item","idx"],"sourceRoot":"../../../src","sources":["operations/execute.ts"],"mappings":";;AAAA,SAASA,iBAAiB,EAAEC,2BAA2B,QAAQ,oBAAiB;AAChF,SAASC,iBAAiB,QAAQ,aAAU;AAC5C,SAASC,0BAA0B,QAAQ,oBAAiB;AAS5D,OAAO,SAASC,OAAOA,CACrBC,MAAc,EACdC,KAAa,EACbC,MAA0B,EACR;EAClB,MAAMC,iBAAiB,GAAGP,2BAA2B,CAAC,CAAC,GACnDQ,mBAAmB,CAACF,MAAM,CAAC,GAC1BA,MAAkC;EAEvC,MAAMG,YAAY,GAAGR,iBAAiB,CAACE,OAAO,CAC5CC,MAAM,EACNC,KAAK,EACLE,iBACF,CAAC;EACD,MAAMG,MAAM,GAAGC,kBAAkB,CAAMF,YAAY,CAAC;EACpD,OAAOC,MAAM;AACf;AAEA,OAAO,eAAeE,YAAYA,CAChCR,MAAc,EACdC,KAAa,EACbC,MAA0B,EACC;EAC3B,MAAMC,iBAAiB,GAAGP,2BAA2B,CAAC,CAAC,GACnDQ,mBAAmB,CAACF,MAAM,CAAC,GAC1BA,MAAkC;EAEvC,MAAMG,YAAY,GAAG,MAAMR,iBAAiB,CAACW,YAAY,CACvDR,MAAM,EACNC,KAAK,EACLE,iBACF,CAAC;EACD,MAAMG,MAAM,GAAGC,kBAAkB,CAAMF,YAAY,CAAC;EACpD,OAAOC,MAAM;AACf;AAEA,SAASF,mBAAmBA,CAC1BF,MAAqC,EACA;EACrC,OAAOA,MAAM,EAAEO,GAAG,CAAEC,KAAK,IAAKZ,0BAA0B,CAACY,KAAK,CAAC,CAAC;AAClE;AAEA,SAASH,kBAAkBA,CAAqC;EAC9DI,QAAQ;EACRC,YAAY;EACZC;AACiB,CAAC,EAAoB;EACtC,IAAIC,IAAW,GAAGD,OAAgB;EAElC,IAAIjB,2BAA2B,CAAC,CAAC,EAAE;IACjCkB,IAAI,GAAGD,OAAO,CAACJ,GAAG,CAAEM,GAAG,IACrBC,MAAM,CAACC,WAAW,CAChBD,MAAM,CAACE,OAAO,CAACH,GAAG,CAAC,CAACN,GAAG,CAAC,CAAC,CAACU,GAAG,EAAEC,KAAK,CAAC,KAAK;MACxC,IAAIzB,iBAAiB,CAACyB,KAAK,CAAC,EAAE;QAC5B,OAAO,CAACD,GAAG,EAAE,IAAI,CAAC;MACpB;MACA,OAAO,CAACA,GAAG,EAAEC,KAAK,CAAC;IACrB,CAAC,CACH,CACF,CAAU;EACZ;EAEA,OAAO;IACLT,QAAQ;IACRC,YAAY;IACZS,IAAI,EAAE;MACJC,MAAM,EAAER,IAAI;MACZS,MAAM,EAAET,IAAI,CAACS,MAAM;MACnBC,IAAI,EAAGC,GAAW,IAAKX,IAAI,CAACW,GAAG;IACjC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { isSimpleNullHandlingEnabled, replaceWithNativeNullValue } from "../nullHandling.js";
|
|
4
|
+
import { HybridNitroSQLite } from "../nitro.js";
|
|
5
|
+
export function executeBatch(dbName, commands) {
|
|
6
|
+
const transformedCommands = isSimpleNullHandlingEnabled() ? toNativeBatchQueryCommands(commands) : commands;
|
|
7
|
+
const result = HybridNitroSQLite.executeBatch(dbName, transformedCommands);
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
export async function executeBatchAsync(dbName, commands) {
|
|
11
|
+
const transformedCommands = isSimpleNullHandlingEnabled() ? toNativeBatchQueryCommands(commands) : commands;
|
|
12
|
+
const result = await HybridNitroSQLite.executeBatchAsync(dbName, transformedCommands);
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
function toNativeBatchQueryCommands(commands) {
|
|
16
|
+
return commands.map(command => {
|
|
17
|
+
const transformedParams = command.params?.map(param => {
|
|
18
|
+
if (Array.isArray(param)) {
|
|
19
|
+
return param.map(p => replaceWithNativeNullValue(p));
|
|
20
|
+
}
|
|
21
|
+
return replaceWithNativeNullValue(param);
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
query: command.query,
|
|
25
|
+
params: transformedParams
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=executeBatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isSimpleNullHandlingEnabled","replaceWithNativeNullValue","HybridNitroSQLite","executeBatch","dbName","commands","transformedCommands","toNativeBatchQueryCommands","result","executeBatchAsync","map","command","transformedParams","params","param","Array","isArray","p","query"],"sourceRoot":"../../../src","sources":["operations/executeBatch.ts"],"mappings":";;AAAA,SACEA,2BAA2B,EAC3BC,0BAA0B,QACrB,oBAAiB;AACxB,SAASC,iBAAiB,QAAQ,aAAU;AAQ5C,OAAO,SAASC,YAAYA,CAC1BC,MAAc,EACdC,QAA6B,EACX;EAClB,MAAMC,mBAAmB,GAAGN,2BAA2B,CAAC,CAAC,GACrDO,0BAA0B,CAACF,QAAQ,CAAC,GACnCA,QAAsC;EAE3C,MAAMG,MAAM,GAAGN,iBAAiB,CAACC,YAAY,CAACC,MAAM,EAAEE,mBAAmB,CAAC;EAC1E,OAAOE,MAAM;AACf;AAEA,OAAO,eAAeC,iBAAiBA,CACrCL,MAAc,EACdC,QAA6B,EACF;EAC3B,MAAMC,mBAAmB,GAAGN,2BAA2B,CAAC,CAAC,GACrDO,0BAA0B,CAACF,QAAQ,CAAC,GACnCA,QAAsC;EAE3C,MAAMG,MAAM,GAAG,MAAMN,iBAAiB,CAACO,iBAAiB,CACtDL,MAAM,EACNE,mBACF,CAAC;EACD,OAAOE,MAAM;AACf;AAEA,SAASD,0BAA0BA,CACjCF,QAA6B,EACF;EAC3B,OAAOA,QAAQ,CAACK,GAAG,CAAEC,OAAO,IAAK;IAC/B,MAAMC,iBAAiB,GAAGD,OAAO,CAACE,MAAM,EAAEH,GAAG,CAAEI,KAAK,IAAK;MACvD,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;QACxB,OAAOA,KAAK,CAACJ,GAAG,CAAEO,CAAC,IAAKhB,0BAA0B,CAACgB,CAAC,CAAC,CAAC;MACxD;MACA,OAAOhB,0BAA0B,CAACa,KAAK,CAAC;IAC1C,CAAC,CAAwD;IAEzD,OAAO;MACLI,KAAK,EAAEP,OAAO,CAACO,KAAK;MACpBL,MAAM,EAAED;IACV,CAAC;EACH,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { locks, HybridNitroSQLite } from "../nitro.js";
|
|
4
4
|
import { transaction } from "./transaction.js";
|
|
5
5
|
import { execute, executeAsync } from "./execute.js";
|
|
6
|
+
import { executeBatch, executeBatchAsync } from "./executeBatch.js";
|
|
6
7
|
export function open(options) {
|
|
7
8
|
openDb(options.name, options.location);
|
|
8
9
|
return {
|
|
@@ -13,8 +14,8 @@ export function open(options) {
|
|
|
13
14
|
transaction: fn => transaction(options.name, fn),
|
|
14
15
|
execute: (query, params) => execute(options.name, query, params),
|
|
15
16
|
executeAsync: (query, params) => executeAsync(options.name, query, params),
|
|
16
|
-
executeBatch: commands =>
|
|
17
|
-
executeBatchAsync: commands =>
|
|
17
|
+
executeBatch: commands => executeBatch(options.name, commands),
|
|
18
|
+
executeBatchAsync: commands => executeBatchAsync(options.name, commands),
|
|
18
19
|
loadFile: location => HybridNitroSQLite.loadFile(options.name, location),
|
|
19
20
|
loadFileAsync: location => HybridNitroSQLite.loadFileAsync(options.name, location)
|
|
20
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["locks","HybridNitroSQLite","transaction","execute","executeAsync","open","options","openDb","name","location","close","delete","drop","attach","dbNameToAttach","alias","detach","fn","query","params","
|
|
1
|
+
{"version":3,"names":["locks","HybridNitroSQLite","transaction","execute","executeAsync","executeBatch","executeBatchAsync","open","options","openDb","name","location","close","delete","drop","attach","dbNameToAttach","alias","detach","fn","query","params","commands","loadFile","loadFileAsync","dbName","queue","inProgress"],"sourceRoot":"../../../src","sources":["operations/session.ts"],"mappings":";;AAAA,SAASA,KAAK,EAAEC,iBAAiB,QAAQ,aAAU;AACnD,SAASC,WAAW,QAAQ,kBAAe;AAU3C,SAASC,OAAO,EAAEC,YAAY,QAAQ,cAAW;AACjD,SAASC,YAAY,EAAEC,iBAAiB,QAAQ,mBAAgB;AAEhE,OAAO,SAASC,IAAIA,CAClBC,OAAqC,EACd;EACvBC,MAAM,CAACD,OAAO,CAACE,IAAI,EAAEF,OAAO,CAACG,QAAQ,CAAC;EAEtC,OAAO;IACLC,KAAK,EAAEA,CAAA,KAAMA,KAAK,CAACJ,OAAO,CAACE,IAAI,CAAC;IAChCG,MAAM,EAAEA,CAAA,KAAMZ,iBAAiB,CAACa,IAAI,CAACN,OAAO,CAACE,IAAI,EAAEF,OAAO,CAACG,QAAQ,CAAC;IACpEI,MAAM,EAAEA,CAACC,cAAsB,EAAEC,KAAa,EAAEN,QAAiB,KAC/DV,iBAAiB,CAACc,MAAM,CAACP,OAAO,CAACE,IAAI,EAAEM,cAAc,EAAEC,KAAK,EAAEN,QAAQ,CAAC;IACzEO,MAAM,EAAGD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#__PURE__*/function (ColumnType) {
|
|
|
12
12
|
|
|
13
13
|
// Passing null/undefined in array types is not possible, so we us a special struct as a workaround.
|
|
14
14
|
|
|
15
|
+
/** Used internally to transform the query params into a native format without nullish values */
|
|
16
|
+
|
|
15
17
|
/**
|
|
16
18
|
* Represents a value that can be stored in a SQLite database
|
|
17
19
|
*/
|
|
@@ -23,6 +25,10 @@ export let ColumnType = /*#__PURE__*/function (ColumnType) {
|
|
|
23
25
|
* to declare it a single time, and use an array of array parameters.
|
|
24
26
|
*/
|
|
25
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Used internally to transform the batch query commands into a native format without nullish values
|
|
30
|
+
*/
|
|
31
|
+
|
|
26
32
|
/**
|
|
27
33
|
* status: 0 or undefined for correct execution, 1 for error
|
|
28
34
|
* message: if status === 1, here you will find error description
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ColumnType"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;AAmBA,WAAYA,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;;AAStB;;
|
|
1
|
+
{"version":3,"names":["ColumnType"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;AAmBA,WAAYA,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;;AAStB;;AAWA;;AAGA;AACA;AACA;;AAwCA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { open } from './operations/session';
|
|
2
2
|
import { execute, executeAsync } from './operations/execute';
|
|
3
|
-
import {
|
|
3
|
+
import { executeBatch, executeBatchAsync } from './operations/executeBatch';
|
|
4
4
|
export type * from './types';
|
|
5
5
|
export { typeORMDriver } from './typeORM';
|
|
6
6
|
export declare const NitroSQLite: {
|
|
@@ -9,12 +9,12 @@ export declare const NitroSQLite: {
|
|
|
9
9
|
transaction: (dbName: string, fn: (tx: import("./types").Transaction) => Promise<void> | void) => Promise<void>;
|
|
10
10
|
execute: typeof execute;
|
|
11
11
|
executeAsync: typeof executeAsync;
|
|
12
|
+
executeBatch: typeof executeBatch;
|
|
13
|
+
executeBatchAsync: typeof executeBatchAsync;
|
|
12
14
|
close(dbName: string): void;
|
|
13
15
|
drop(dbName: string, location?: string): void;
|
|
14
16
|
attach(mainDbName: string, dbNameToAttach: string, alias: string, location?: string): void;
|
|
15
17
|
detach(mainDbName: string, alias: string): void;
|
|
16
|
-
executeBatch(dbName: string, commands: import("./types").BatchQueryCommand[]): import("./types").BatchQueryResult;
|
|
17
|
-
executeBatchAsync(dbName: string, commands: import("./types").BatchQueryCommand[]): Promise<import("./types").BatchQueryResult>;
|
|
18
18
|
loadFile(dbName: string, location: string): import("./types").FileLoadResult;
|
|
19
19
|
loadFileAsync(dbName: string, location: string): Promise<import("./types").FileLoadResult>;
|
|
20
20
|
__type?: string;
|
|
@@ -27,8 +27,5 @@ export declare const NitroSQLite: {
|
|
|
27
27
|
dispose(): void;
|
|
28
28
|
};
|
|
29
29
|
export { open } from './operations/session';
|
|
30
|
-
export
|
|
31
|
-
export declare function isSimpleNullHandlingEnabled(): boolean;
|
|
32
|
-
export declare const NITRO_SQLITE_NULL: SQLiteNullValue;
|
|
33
|
-
export declare function isNitroSQLiteNull(value: any): value is SQLiteNullValue;
|
|
30
|
+
export { isNitroSQLiteNull, NITRO_SQLITE_NULL, isSimpleNullHandlingEnabled, enableSimpleNullHandling, } from './nullHandling';
|
|
34
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC3E,mBAAmB,SAAS,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAIzC,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;CAYvB,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SQLiteNullValue, SQLiteValue } from './types';
|
|
2
|
+
import { SQLiteQueryParamItem } from './types';
|
|
3
|
+
export declare function enableSimpleNullHandling(shouldEnableSimpleNullHandling?: boolean): void;
|
|
4
|
+
export declare function isSimpleNullHandlingEnabled(): boolean;
|
|
5
|
+
export declare const NITRO_SQLITE_NULL: SQLiteNullValue;
|
|
6
|
+
export declare function isNitroSQLiteNull(value: any): value is SQLiteNullValue;
|
|
7
|
+
export declare function replaceWithNativeNullValue(value: SQLiteQueryParamItem): SQLiteValue;
|
|
8
|
+
//# sourceMappingURL=nullHandling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nullHandling.d.ts","sourceRoot":"","sources":["../../../src/nullHandling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAI9C,wBAAgB,wBAAwB,CACtC,8BAA8B,UAAO,QAGtC;AAED,wBAAgB,2BAA2B,YAE1C;AAED,eAAO,MAAM,iBAAiB,EAAE,eAA6C,CAAA;AAC7E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,eAAe,CAKtE;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,oBAAoB,GAC1B,WAAW,CAKb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../../src/operations/execute.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../../src/operations/execute.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EAEX,iBAAiB,EACjB,cAAc,EACf,MAAM,UAAU,CAAA;AAEjB,wBAAgB,OAAO,CAAC,GAAG,SAAS,cAAc,GAAG,KAAK,EACxD,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,iBAAiB,GACzB,WAAW,CAAC,GAAG,CAAC,CAYlB;AAED,wBAAsB,YAAY,CAAC,GAAG,SAAS,cAAc,GAAG,KAAK,EACnE,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAY3B"}
|