react-native-nitro-sqlite 9.2.1 → 9.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/cpp/operations.cpp +3 -3
- package/cpp/specs/HybridNitroSQLite.cpp +11 -10
- package/cpp/specs/HybridNitroSQLite.hpp +6 -6
- package/cpp/specs/HybridNitroSQLiteQueryResult.cpp +49 -0
- package/cpp/specs/{HybridNativeQueryResult.hpp → HybridNitroSQLiteQueryResult.hpp} +5 -4
- package/cpp/sqliteExecuteBatch.cpp +1 -1
- package/cpp/sqliteExecuteBatch.hpp +2 -2
- package/cpp/types.hpp +3 -4
- package/lib/commonjs/index.js +4 -25
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/operations/execute.js +9 -26
- package/lib/commonjs/operations/execute.js.map +1 -1
- package/lib/commonjs/operations/executeBatch.js +2 -19
- package/lib/commonjs/operations/executeBatch.js.map +1 -1
- package/lib/commonjs/specs/{NativeQueryResult.nitro.js → NitroSQLiteQueryResult.nitro.js} +1 -1
- package/lib/commonjs/specs/NitroSQLiteQueryResult.nitro.js.map +1 -0
- package/lib/commonjs/types.js +1 -8
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/operations/execute.js +9 -27
- package/lib/module/operations/execute.js.map +1 -1
- package/lib/module/operations/executeBatch.js +2 -19
- package/lib/module/operations/executeBatch.js.map +1 -1
- package/lib/module/specs/NitroSQLiteQueryResult.nitro.js +4 -0
- package/lib/module/specs/NitroSQLiteQueryResult.nitro.js.map +1 -0
- package/lib/module/types.js +0 -12
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +2 -1
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/operations/execute.d.ts +1 -1
- package/lib/typescript/commonjs/operations/execute.d.ts.map +1 -1
- package/lib/typescript/commonjs/operations/executeBatch.d.ts +1 -1
- package/lib/typescript/commonjs/operations/executeBatch.d.ts.map +1 -1
- package/lib/typescript/commonjs/operations/transaction.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/NitroSQLite.nitro.d.ts +6 -6
- package/lib/typescript/commonjs/specs/NitroSQLite.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/{NativeQueryResult.nitro.d.ts → NitroSQLiteQueryResult.nitro.d.ts} +20 -13
- package/lib/typescript/commonjs/specs/NitroSQLiteQueryResult.nitro.d.ts.map +1 -0
- package/lib/typescript/commonjs/typeORM.d.ts +1 -1
- package/lib/typescript/commonjs/typeORM.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +16 -37
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +2 -1
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/operations/execute.d.ts +1 -1
- package/lib/typescript/module/operations/execute.d.ts.map +1 -1
- package/lib/typescript/module/operations/executeBatch.d.ts +1 -1
- package/lib/typescript/module/operations/executeBatch.d.ts.map +1 -1
- package/lib/typescript/module/operations/transaction.d.ts.map +1 -1
- package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts +6 -6
- package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts.map +1 -1
- package/lib/typescript/module/specs/{NativeQueryResult.nitro.d.ts → NitroSQLiteQueryResult.nitro.d.ts} +20 -13
- package/lib/typescript/module/specs/NitroSQLiteQueryResult.nitro.d.ts.map +1 -0
- package/lib/typescript/module/typeORM.d.ts +1 -1
- package/lib/typescript/module/typeORM.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +16 -37
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/nitrogen/generated/android/RNNitroSQLite+autolinking.cmake +9 -6
- package/nitrogen/generated/android/RNNitroSQLite+autolinking.gradle +1 -1
- package/nitrogen/generated/android/RNNitroSQLiteOnLoad.cpp +2 -4
- package/nitrogen/generated/android/RNNitroSQLiteOnLoad.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridNitroSQLiteOnLoadSpec.cpp +14 -1
- package/nitrogen/generated/android/c++/JHybridNitroSQLiteOnLoadSpec.hpp +4 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnnitrosqlite/HybridNitroSQLiteOnLoadSpec.kt +8 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnnitrosqlite/RNNitroSQLiteOnLoad.kt +1 -1
- package/nitrogen/generated/ios/RNNitroSQLite+autolinking.rb +2 -2
- package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Bridge.cpp +1 -1
- package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Bridge.hpp +1 -1
- package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Umbrella.hpp +1 -1
- package/nitrogen/generated/ios/RNNitroSQLiteAutolinking.mm +1 -1
- package/nitrogen/generated/ios/RNNitroSQLiteAutolinking.swift +5 -1
- package/nitrogen/generated/shared/c++/BatchQueryCommand.hpp +92 -0
- package/nitrogen/generated/shared/c++/BatchQueryResult.hpp +25 -11
- package/nitrogen/generated/shared/c++/ColumnType.hpp +5 -7
- package/nitrogen/generated/shared/c++/FileLoadResult.hpp +28 -14
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteOnLoadSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteOnLoadSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteQueryResultSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteQueryResultSpec.hpp +77 -0
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.hpp +12 -16
- package/nitrogen/generated/shared/c++/NitroSQLiteQueryColumnMetadata.hpp +93 -0
- package/nitrogen/generated/shared/c++/NitroSQLiteQueryResultRows.hpp +99 -0
- package/package.json +6 -6
- package/src/index.ts +3 -6
- package/src/operations/execute.ts +14 -58
- package/src/operations/executeBatch.ts +3 -41
- package/src/operations/session.ts +1 -1
- package/src/operations/transaction.ts +1 -1
- package/src/specs/NitroSQLite.nitro.ts +9 -12
- package/src/specs/{NativeQueryResult.nitro.ts → NitroSQLiteQueryResult.nitro.ts} +32 -17
- package/src/typeORM.ts +1 -1
- package/src/types.ts +26 -46
- package/cpp/specs/HybridNativeQueryResult.cpp +0 -21
- package/lib/commonjs/nullHandling.js +0 -33
- package/lib/commonjs/nullHandling.js.map +0 -1
- package/lib/commonjs/specs/NativeQueryResult.nitro.js.map +0 -1
- package/lib/module/nullHandling.js +0 -25
- package/lib/module/nullHandling.js.map +0 -1
- package/lib/module/specs/NativeQueryResult.nitro.js +0 -4
- package/lib/module/specs/NativeQueryResult.nitro.js.map +0 -1
- package/lib/typescript/commonjs/nullHandling.d.ts +0 -8
- package/lib/typescript/commonjs/nullHandling.d.ts.map +0 -1
- package/lib/typescript/commonjs/specs/NativeQueryResult.nitro.d.ts.map +0 -1
- package/lib/typescript/module/nullHandling.d.ts +0 -8
- package/lib/typescript/module/nullHandling.d.ts.map +0 -1
- package/lib/typescript/module/specs/NativeQueryResult.nitro.d.ts.map +0 -1
- package/nitrogen/generated/shared/c++/HybridNativeQueryResultSpec.cpp +0 -24
- package/nitrogen/generated/shared/c++/HybridNativeQueryResultSpec.hpp +0 -77
- package/nitrogen/generated/shared/c++/NativeBatchQueryCommand.hpp +0 -81
- package/nitrogen/generated/shared/c++/SQLiteNullValue.hpp +0 -69
- package/nitrogen/generated/shared/c++/SQLiteQueryColumnMetadata.hpp +0 -79
- package/src/nullHandling.ts +0 -35
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridNitroSQLiteSpec.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -13,30 +13,26 @@
|
|
|
13
13
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
14
|
#endif
|
|
15
15
|
|
|
16
|
-
// Forward declaration of `
|
|
17
|
-
namespace margelo::nitro::rnnitrosqlite { class
|
|
18
|
-
// Forward declaration of `ArrayBuffer` to properly resolve imports.
|
|
19
|
-
namespace NitroModules { class ArrayBuffer; }
|
|
20
|
-
// Forward declaration of `SQLiteNullValue` to properly resolve imports.
|
|
21
|
-
namespace margelo::nitro::rnnitrosqlite { struct SQLiteNullValue; }
|
|
16
|
+
// Forward declaration of `HybridNitroSQLiteQueryResultSpec` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::rnnitrosqlite { class HybridNitroSQLiteQueryResultSpec; }
|
|
22
18
|
// Forward declaration of `BatchQueryResult` to properly resolve imports.
|
|
23
19
|
namespace margelo::nitro::rnnitrosqlite { struct BatchQueryResult; }
|
|
24
|
-
// Forward declaration of `
|
|
25
|
-
namespace margelo::nitro::rnnitrosqlite { struct
|
|
20
|
+
// Forward declaration of `BatchQueryCommand` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::rnnitrosqlite { struct BatchQueryCommand; }
|
|
26
22
|
// Forward declaration of `FileLoadResult` to properly resolve imports.
|
|
27
23
|
namespace margelo::nitro::rnnitrosqlite { struct FileLoadResult; }
|
|
28
24
|
|
|
29
25
|
#include <string>
|
|
30
26
|
#include <optional>
|
|
31
27
|
#include <memory>
|
|
32
|
-
#include "
|
|
28
|
+
#include "HybridNitroSQLiteQueryResultSpec.hpp"
|
|
29
|
+
#include <NitroModules/Null.hpp>
|
|
33
30
|
#include <NitroModules/ArrayBuffer.hpp>
|
|
34
|
-
#include "SQLiteNullValue.hpp"
|
|
35
31
|
#include <variant>
|
|
36
32
|
#include <vector>
|
|
37
33
|
#include <NitroModules/Promise.hpp>
|
|
38
34
|
#include "BatchQueryResult.hpp"
|
|
39
|
-
#include "
|
|
35
|
+
#include "BatchQueryCommand.hpp"
|
|
40
36
|
#include "FileLoadResult.hpp"
|
|
41
37
|
|
|
42
38
|
namespace margelo::nitro::rnnitrosqlite {
|
|
@@ -75,10 +71,10 @@ namespace margelo::nitro::rnnitrosqlite {
|
|
|
75
71
|
virtual void drop(const std::string& dbName, const std::optional<std::string>& location) = 0;
|
|
76
72
|
virtual void attach(const std::string& mainDbName, const std::string& dbNameToAttach, const std::string& alias, const std::optional<std::string>& location) = 0;
|
|
77
73
|
virtual void detach(const std::string& mainDbName, const std::string& alias) = 0;
|
|
78
|
-
virtual std::shared_ptr<
|
|
79
|
-
virtual std::shared_ptr<Promise<std::shared_ptr<
|
|
80
|
-
virtual BatchQueryResult executeBatch(const std::string& dbName, const std::vector<
|
|
81
|
-
virtual std::shared_ptr<Promise<BatchQueryResult>> executeBatchAsync(const std::string& dbName, const std::vector<
|
|
74
|
+
virtual std::shared_ptr<HybridNitroSQLiteQueryResultSpec> execute(const std::string& dbName, const std::string& query, const std::optional<std::vector<std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>>& params) = 0;
|
|
75
|
+
virtual std::shared_ptr<Promise<std::shared_ptr<HybridNitroSQLiteQueryResultSpec>>> executeAsync(const std::string& dbName, const std::string& query, const std::optional<std::vector<std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>>& params) = 0;
|
|
76
|
+
virtual BatchQueryResult executeBatch(const std::string& dbName, const std::vector<BatchQueryCommand>& commands) = 0;
|
|
77
|
+
virtual std::shared_ptr<Promise<BatchQueryResult>> executeBatchAsync(const std::string& dbName, const std::vector<BatchQueryCommand>& commands) = 0;
|
|
82
78
|
virtual FileLoadResult loadFile(const std::string& dbName, const std::string& location) = 0;
|
|
83
79
|
virtual std::shared_ptr<Promise<FileLoadResult>> loadFileAsync(const std::string& dbName, const std::string& location) = 0;
|
|
84
80
|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroSQLiteQueryColumnMetadata.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
// Forward declaration of `ColumnType` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::rnnitrosqlite { enum class ColumnType; }
|
|
33
|
+
|
|
34
|
+
#include <string>
|
|
35
|
+
#include "ColumnType.hpp"
|
|
36
|
+
|
|
37
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A struct which can be represented as a JavaScript object (NitroSQLiteQueryColumnMetadata).
|
|
41
|
+
*/
|
|
42
|
+
struct NitroSQLiteQueryColumnMetadata final {
|
|
43
|
+
public:
|
|
44
|
+
std::string name SWIFT_PRIVATE;
|
|
45
|
+
ColumnType type SWIFT_PRIVATE;
|
|
46
|
+
double index SWIFT_PRIVATE;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
NitroSQLiteQueryColumnMetadata() = default;
|
|
50
|
+
explicit NitroSQLiteQueryColumnMetadata(std::string name, ColumnType type, double index): name(name), type(type), index(index) {}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
friend bool operator==(const NitroSQLiteQueryColumnMetadata& lhs, const NitroSQLiteQueryColumnMetadata& rhs) = default;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
|
57
|
+
|
|
58
|
+
namespace margelo::nitro {
|
|
59
|
+
|
|
60
|
+
// C++ NitroSQLiteQueryColumnMetadata <> JS NitroSQLiteQueryColumnMetadata (object)
|
|
61
|
+
template <>
|
|
62
|
+
struct JSIConverter<margelo::nitro::rnnitrosqlite::NitroSQLiteQueryColumnMetadata> final {
|
|
63
|
+
static inline margelo::nitro::rnnitrosqlite::NitroSQLiteQueryColumnMetadata fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
64
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
65
|
+
return margelo::nitro::rnnitrosqlite::NitroSQLiteQueryColumnMetadata(
|
|
66
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
|
|
67
|
+
JSIConverter<margelo::nitro::rnnitrosqlite::ColumnType>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))),
|
|
68
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "index")))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rnnitrosqlite::NitroSQLiteQueryColumnMetadata& arg) {
|
|
72
|
+
jsi::Object obj(runtime);
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter<margelo::nitro::rnnitrosqlite::ColumnType>::toJSI(runtime, arg.type));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "index"), JSIConverter<double>::toJSI(runtime, arg.index));
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
79
|
+
if (!value.isObject()) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
jsi::Object obj = value.getObject(runtime);
|
|
83
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
|
|
87
|
+
if (!JSIConverter<margelo::nitro::rnnitrosqlite::ColumnType>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false;
|
|
88
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "index")))) return false;
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroSQLiteQueryResultRows.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#include <string>
|
|
34
|
+
#include <NitroModules/Null.hpp>
|
|
35
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
36
|
+
#include <variant>
|
|
37
|
+
#include <unordered_map>
|
|
38
|
+
#include <vector>
|
|
39
|
+
#include <optional>
|
|
40
|
+
#include <NitroModules/Promise.hpp>
|
|
41
|
+
#include <functional>
|
|
42
|
+
|
|
43
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A struct which can be represented as a JavaScript object (NitroSQLiteQueryResultRows).
|
|
47
|
+
*/
|
|
48
|
+
struct NitroSQLiteQueryResultRows final {
|
|
49
|
+
public:
|
|
50
|
+
std::vector<std::unordered_map<std::string, std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>> _array SWIFT_PRIVATE;
|
|
51
|
+
double length SWIFT_PRIVATE;
|
|
52
|
+
std::function<std::shared_ptr<Promise<std::optional<std::unordered_map<std::string, std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>>>>(double /* idx */)> item SWIFT_PRIVATE;
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
NitroSQLiteQueryResultRows() = default;
|
|
56
|
+
explicit NitroSQLiteQueryResultRows(std::vector<std::unordered_map<std::string, std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>> _array, double length, std::function<std::shared_ptr<Promise<std::optional<std::unordered_map<std::string, std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>>>>(double /* idx */)> item): _array(_array), length(length), item(item) {}
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
// NitroSQLiteQueryResultRows is not equatable because these properties are not equatable: item
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
|
63
|
+
|
|
64
|
+
namespace margelo::nitro {
|
|
65
|
+
|
|
66
|
+
// C++ NitroSQLiteQueryResultRows <> JS NitroSQLiteQueryResultRows (object)
|
|
67
|
+
template <>
|
|
68
|
+
struct JSIConverter<margelo::nitro::rnnitrosqlite::NitroSQLiteQueryResultRows> final {
|
|
69
|
+
static inline margelo::nitro::rnnitrosqlite::NitroSQLiteQueryResultRows fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
70
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
71
|
+
return margelo::nitro::rnnitrosqlite::NitroSQLiteQueryResultRows(
|
|
72
|
+
JSIConverter<std::vector<std::unordered_map<std::string, std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "_array"))),
|
|
73
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "length"))),
|
|
74
|
+
JSIConverter<std::function<std::shared_ptr<Promise<std::optional<std::unordered_map<std::string, std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>>>>(double)>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "item")))
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rnnitrosqlite::NitroSQLiteQueryResultRows& arg) {
|
|
78
|
+
jsi::Object obj(runtime);
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "_array"), JSIConverter<std::vector<std::unordered_map<std::string, std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>>>::toJSI(runtime, arg._array));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "length"), JSIConverter<double>::toJSI(runtime, arg.length));
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "item"), JSIConverter<std::function<std::shared_ptr<Promise<std::optional<std::unordered_map<std::string, std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>>>>(double)>>::toJSI(runtime, arg.item));
|
|
82
|
+
return obj;
|
|
83
|
+
}
|
|
84
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
85
|
+
if (!value.isObject()) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
jsi::Object obj = value.getObject(runtime);
|
|
89
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if (!JSIConverter<std::vector<std::unordered_map<std::string, std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "_array")))) return false;
|
|
93
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "length")))) return false;
|
|
94
|
+
if (!JSIConverter<std::function<std::shared_ptr<Promise<std::optional<std::unordered_map<std::string, std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>>>>(double)>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "item")))) return false;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
} // namespace margelo::nitro
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-sqlite",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"description": "Fast SQLite library for React Native built using Nitro Modules",
|
|
5
5
|
"main": "./lib/module/index",
|
|
6
6
|
"module": "./lib/module/index",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "bun typecheck && bob build",
|
|
41
|
-
"specs": "bun typecheck && bun
|
|
41
|
+
"specs": "bun typecheck && bun nitrogen --logLevel=\"debug\"",
|
|
42
42
|
"typecheck": "tsc --noEmit",
|
|
43
43
|
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
|
|
44
44
|
"test": "jest",
|
|
@@ -66,20 +66,20 @@
|
|
|
66
66
|
"registry": "https://registry.npmjs.org/"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"typeorm": "0.3.
|
|
69
|
+
"typeorm": "0.3.27"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"jest": "^30.2.0",
|
|
73
|
-
"
|
|
73
|
+
"nitrogen": "0.33.5",
|
|
74
74
|
"react": "19.1.1",
|
|
75
75
|
"react-native": "0.82.1",
|
|
76
76
|
"react-native-builder-bob": "^0.31.0",
|
|
77
|
-
"react-native-nitro-modules": "0.
|
|
77
|
+
"react-native-nitro-modules": "0.33.5"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
80
|
"react": ">=17.0.0",
|
|
81
81
|
"react-native": ">=0.75.0",
|
|
82
|
-
"react-native-nitro-modules": ">=0.
|
|
82
|
+
"react-native-nitro-modules": ">=0.32.0"
|
|
83
83
|
},
|
|
84
84
|
"resolutions": {
|
|
85
85
|
"@types/react": "^18.2.44"
|
package/src/index.ts
CHANGED
|
@@ -21,13 +21,10 @@ export const NitroSQLite = {
|
|
|
21
21
|
executeBatchAsync,
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/** NOOP on NitroSQLite versions >= 9.3.0 */
|
|
25
|
+
export function enableSimpleNullHandling() {}
|
|
26
|
+
|
|
24
27
|
export { open } from './operations/session'
|
|
25
|
-
export {
|
|
26
|
-
isNitroSQLiteNull,
|
|
27
|
-
NITRO_SQLITE_NULL,
|
|
28
|
-
isSimpleNullHandlingEnabled,
|
|
29
|
-
enableSimpleNullHandling,
|
|
30
|
-
} from './nullHandling'
|
|
31
28
|
export { default as NitroSQLiteError } from './NitroSQLiteError'
|
|
32
29
|
export type * from './types'
|
|
33
30
|
export { typeORMDriver } from './typeORM'
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import { isNitroSQLiteNull, isSimpleNullHandlingEnabled } from '../nullHandling'
|
|
2
1
|
import { HybridNitroSQLite } from '../nitro'
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
QueryResult,
|
|
7
|
-
NativeSQLiteQueryParams,
|
|
8
|
-
SQLiteQueryParams,
|
|
9
|
-
QueryResultRow,
|
|
10
|
-
} from '../types'
|
|
2
|
+
import type { NitroSQLiteQueryResult } from '../specs/NitroSQLiteQueryResult.nitro'
|
|
3
|
+
import type { QueryResult, QueryResultRow, SQLiteQueryParams } from '../types'
|
|
11
4
|
import NitroSQLiteError from '../NitroSQLiteError'
|
|
12
5
|
|
|
13
6
|
export function execute<Row extends QueryResultRow = never>(
|
|
@@ -15,18 +8,9 @@ export function execute<Row extends QueryResultRow = never>(
|
|
|
15
8
|
query: string,
|
|
16
9
|
params?: SQLiteQueryParams,
|
|
17
10
|
): QueryResult<Row> {
|
|
18
|
-
const transformedParams = isSimpleNullHandlingEnabled()
|
|
19
|
-
? toNativeQueryParams(params)
|
|
20
|
-
: (params as NativeSQLiteQueryParams)
|
|
21
|
-
|
|
22
11
|
try {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
query,
|
|
26
|
-
transformedParams,
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
return buildJsQueryResult<Row>(nativeResult)
|
|
12
|
+
const result = HybridNitroSQLite.execute(dbName, query, params)
|
|
13
|
+
return buildJsQueryResult<Row>(result)
|
|
30
14
|
} catch (error) {
|
|
31
15
|
throw NitroSQLiteError.fromError(error)
|
|
32
16
|
}
|
|
@@ -37,55 +21,27 @@ export async function executeAsync<Row extends QueryResultRow = never>(
|
|
|
37
21
|
query: string,
|
|
38
22
|
params?: SQLiteQueryParams,
|
|
39
23
|
): Promise<QueryResult<Row>> {
|
|
40
|
-
const transformedParams = isSimpleNullHandlingEnabled()
|
|
41
|
-
? toNativeQueryParams(params)
|
|
42
|
-
: (params as NativeSQLiteQueryParams)
|
|
43
|
-
|
|
44
24
|
try {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
query,
|
|
48
|
-
transformedParams,
|
|
49
|
-
)
|
|
50
|
-
return buildJsQueryResult<Row>(nativeResult)
|
|
25
|
+
const result = await HybridNitroSQLite.executeAsync(dbName, query, params)
|
|
26
|
+
return buildJsQueryResult<Row>(result)
|
|
51
27
|
} catch (error) {
|
|
52
28
|
throw NitroSQLiteError.fromError(error)
|
|
53
29
|
}
|
|
54
30
|
}
|
|
55
31
|
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
):
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function buildJsQueryResult<Row extends QueryResultRow = never>({
|
|
63
|
-
insertId,
|
|
64
|
-
rowsAffected,
|
|
65
|
-
results,
|
|
66
|
-
}: NativeQueryResult): QueryResult<Row> {
|
|
67
|
-
let data: Row[] = results as Row[]
|
|
68
|
-
|
|
69
|
-
if (isSimpleNullHandlingEnabled()) {
|
|
70
|
-
data = results.map((row) =>
|
|
71
|
-
Object.fromEntries(
|
|
72
|
-
Object.entries(row).map(([key, value]) => {
|
|
73
|
-
if (isNitroSQLiteNull(value)) {
|
|
74
|
-
return [key, null]
|
|
75
|
-
}
|
|
76
|
-
return [key, value]
|
|
77
|
-
}),
|
|
78
|
-
),
|
|
79
|
-
) as Row[]
|
|
80
|
-
}
|
|
32
|
+
function buildJsQueryResult<Row extends QueryResultRow = never>(
|
|
33
|
+
result: NitroSQLiteQueryResult,
|
|
34
|
+
): QueryResult<Row> {
|
|
35
|
+
const data = result.results as Row[]
|
|
81
36
|
|
|
82
37
|
return {
|
|
83
|
-
|
|
84
|
-
|
|
38
|
+
...result,
|
|
39
|
+
insertId: result.insertId,
|
|
40
|
+
rowsAffected: result.rowsAffected,
|
|
85
41
|
rows: {
|
|
86
42
|
_array: data,
|
|
87
43
|
length: data.length,
|
|
88
44
|
item: (idx: number) => data[idx],
|
|
89
45
|
},
|
|
90
|
-
}
|
|
46
|
+
} as QueryResult<Row>
|
|
91
47
|
}
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isSimpleNullHandlingEnabled,
|
|
3
|
-
replaceWithNativeNullValue,
|
|
4
|
-
} from '../nullHandling'
|
|
5
1
|
import { HybridNitroSQLite } from '../nitro'
|
|
6
2
|
import {
|
|
7
3
|
queueOperationAsync,
|
|
8
4
|
startOperationSync,
|
|
9
5
|
throwIfDatabaseIsNotOpen,
|
|
10
6
|
} from '../DatabaseQueue'
|
|
11
|
-
import type {
|
|
12
|
-
NativeSQLiteQueryParams,
|
|
13
|
-
BatchQueryResult,
|
|
14
|
-
BatchQueryCommand,
|
|
15
|
-
NativeBatchQueryCommand,
|
|
16
|
-
} from '../types'
|
|
17
7
|
import NitroSQLiteError from '../NitroSQLiteError'
|
|
8
|
+
import type { BatchQueryCommand, BatchQueryResult } from '../types'
|
|
18
9
|
|
|
19
10
|
export function executeBatch(
|
|
20
11
|
dbName: string,
|
|
@@ -22,13 +13,9 @@ export function executeBatch(
|
|
|
22
13
|
): BatchQueryResult {
|
|
23
14
|
throwIfDatabaseIsNotOpen(dbName)
|
|
24
15
|
|
|
25
|
-
const transformedCommands = isSimpleNullHandlingEnabled()
|
|
26
|
-
? toNativeBatchQueryCommands(commands)
|
|
27
|
-
: (commands as NativeBatchQueryCommand[])
|
|
28
|
-
|
|
29
16
|
try {
|
|
30
17
|
return startOperationSync(dbName, () =>
|
|
31
|
-
HybridNitroSQLite.executeBatch(dbName,
|
|
18
|
+
HybridNitroSQLite.executeBatch(dbName, commands),
|
|
32
19
|
)
|
|
33
20
|
} catch (error) {
|
|
34
21
|
throw NitroSQLiteError.fromError(error)
|
|
@@ -41,36 +28,11 @@ export async function executeBatchAsync(
|
|
|
41
28
|
): Promise<BatchQueryResult> {
|
|
42
29
|
throwIfDatabaseIsNotOpen(dbName)
|
|
43
30
|
|
|
44
|
-
const transformedCommands = isSimpleNullHandlingEnabled()
|
|
45
|
-
? toNativeBatchQueryCommands(commands)
|
|
46
|
-
: (commands as NativeBatchQueryCommand[])
|
|
47
|
-
|
|
48
31
|
return queueOperationAsync(dbName, async () => {
|
|
49
32
|
try {
|
|
50
|
-
return await HybridNitroSQLite.executeBatchAsync(
|
|
51
|
-
dbName,
|
|
52
|
-
transformedCommands,
|
|
53
|
-
)
|
|
33
|
+
return await HybridNitroSQLite.executeBatchAsync(dbName, commands)
|
|
54
34
|
} catch (error) {
|
|
55
35
|
throw NitroSQLiteError.fromError(error)
|
|
56
36
|
}
|
|
57
37
|
})
|
|
58
38
|
}
|
|
59
|
-
|
|
60
|
-
function toNativeBatchQueryCommands(
|
|
61
|
-
commands: BatchQueryCommand[],
|
|
62
|
-
): NativeBatchQueryCommand[] {
|
|
63
|
-
return commands.map((command) => {
|
|
64
|
-
const transformedParams = command.params?.map((param) => {
|
|
65
|
-
if (Array.isArray(param)) {
|
|
66
|
-
return param.map((p) => replaceWithNativeNullValue(p))
|
|
67
|
-
}
|
|
68
|
-
return replaceWithNativeNullValue(param)
|
|
69
|
-
}) as NativeSQLiteQueryParams | NativeSQLiteQueryParams[]
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
query: command.query,
|
|
73
|
-
params: transformedParams,
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
}
|
|
@@ -4,10 +4,10 @@ import type {
|
|
|
4
4
|
BatchQueryCommand,
|
|
5
5
|
NitroSQLiteConnection,
|
|
6
6
|
NitroSQLiteConnectionOptions,
|
|
7
|
-
QueryResult,
|
|
8
7
|
Transaction,
|
|
9
8
|
SQLiteQueryParams,
|
|
10
9
|
QueryResultRow,
|
|
10
|
+
QueryResult,
|
|
11
11
|
} from '../types'
|
|
12
12
|
import { execute, executeAsync } from './execute'
|
|
13
13
|
import { executeBatch, executeBatchAsync } from './executeBatch'
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { HybridObject } from 'react-native-nitro-modules'
|
|
2
2
|
import type {
|
|
3
|
+
BatchQueryCommand,
|
|
3
4
|
BatchQueryResult,
|
|
4
5
|
FileLoadResult,
|
|
5
|
-
|
|
6
|
-
NativeBatchQueryCommand,
|
|
6
|
+
SQLiteQueryParams,
|
|
7
7
|
} from '../types'
|
|
8
|
-
import type {
|
|
8
|
+
import type { NitroSQLiteQueryResult } from './NitroSQLiteQueryResult.nitro'
|
|
9
9
|
|
|
10
10
|
export interface NitroSQLite
|
|
11
11
|
extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
@@ -22,20 +22,17 @@ export interface NitroSQLite
|
|
|
22
22
|
execute(
|
|
23
23
|
dbName: string,
|
|
24
24
|
query: string,
|
|
25
|
-
params?:
|
|
26
|
-
):
|
|
25
|
+
params?: SQLiteQueryParams,
|
|
26
|
+
): NitroSQLiteQueryResult
|
|
27
27
|
executeAsync(
|
|
28
28
|
dbName: string,
|
|
29
29
|
query: string,
|
|
30
|
-
params?:
|
|
31
|
-
): Promise<
|
|
32
|
-
executeBatch(
|
|
33
|
-
dbName: string,
|
|
34
|
-
commands: NativeBatchQueryCommand[],
|
|
35
|
-
): BatchQueryResult
|
|
30
|
+
params?: SQLiteQueryParams,
|
|
31
|
+
): Promise<NitroSQLiteQueryResult>
|
|
32
|
+
executeBatch(dbName: string, commands: BatchQueryCommand[]): BatchQueryResult
|
|
36
33
|
executeBatchAsync(
|
|
37
34
|
dbName: string,
|
|
38
|
-
commands:
|
|
35
|
+
commands: BatchQueryCommand[],
|
|
39
36
|
): Promise<BatchQueryResult>
|
|
40
37
|
loadFile(dbName: string, location: string): FileLoadResult
|
|
41
38
|
loadFileAsync(dbName: string, location: string): Promise<FileLoadResult>
|
|
@@ -9,36 +9,51 @@ import type { ColumnType, SQLiteValue } from '../types'
|
|
|
9
9
|
* rows: if status is undefined or 0 this object will contain the query results
|
|
10
10
|
* }
|
|
11
11
|
*
|
|
12
|
-
* @interface
|
|
12
|
+
* @interface QueryResult
|
|
13
13
|
*/
|
|
14
|
-
export interface
|
|
14
|
+
export interface NitroSQLiteQueryResult
|
|
15
15
|
extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
16
16
|
readonly rowsAffected: number
|
|
17
17
|
readonly insertId?: number
|
|
18
18
|
|
|
19
19
|
/** Query results */
|
|
20
|
-
readonly results:
|
|
20
|
+
readonly results: Record<string, SQLiteValue>[]
|
|
21
|
+
|
|
22
|
+
/** Query results in a row format for TypeORM compatibility */
|
|
23
|
+
readonly rows?: NitroSQLiteQueryResultRows
|
|
24
|
+
|
|
21
25
|
/** Table metadata */
|
|
22
|
-
readonly metadata?: Record<string,
|
|
26
|
+
readonly metadata?: Record<string, NitroSQLiteQueryColumnMetadata>
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
// TODO: Investigate why this cannot be represented in Nitro
|
|
30
|
+
// export type NitroQueryResultRow = {
|
|
31
|
+
// [key: string]: SQLiteValue
|
|
32
|
+
// }
|
|
33
|
+
|
|
34
|
+
// type NitroQueryResultRow = Record<string, SQLiteValue>
|
|
35
|
+
|
|
36
|
+
export type NitroSQLiteQueryResultRows<
|
|
37
|
+
Row extends Record<string, SQLiteValue> = Record<string, SQLiteValue>,
|
|
38
|
+
> = {
|
|
39
|
+
/** Raw array with all dataset */
|
|
40
|
+
_array: Row[]
|
|
41
|
+
/** The lengh of the dataset */
|
|
42
|
+
length: number
|
|
43
|
+
/** A convenience function to acess the index based the row object
|
|
44
|
+
* @param idx the row index
|
|
45
|
+
* @returns the row structure identified by column names
|
|
46
|
+
*/
|
|
47
|
+
item: (idx: number) => Row | undefined
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type NitroSQLiteQueryColumnMetadata = {
|
|
38
51
|
/** The name used for this column for this result set */
|
|
39
52
|
name: string
|
|
53
|
+
|
|
40
54
|
/** The declared column type for this column, when fetched directly from a table or a View resulting from a table column. "UNKNOWN" for dynamic values, like function returned ones. */
|
|
41
55
|
type: ColumnType
|
|
56
|
+
|
|
42
57
|
/** The index for this column for this result set */
|
|
43
58
|
index: number
|
|
44
59
|
}
|
package/src/typeORM.ts
CHANGED