react-native-nitro-sqlite 9.2.2 → 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.
Files changed (114) hide show
  1. package/cpp/operations.cpp +3 -3
  2. package/cpp/specs/HybridNitroSQLite.cpp +11 -10
  3. package/cpp/specs/HybridNitroSQLite.hpp +6 -6
  4. package/cpp/specs/HybridNitroSQLiteQueryResult.cpp +49 -0
  5. package/cpp/specs/{HybridNativeQueryResult.hpp → HybridNitroSQLiteQueryResult.hpp} +5 -4
  6. package/cpp/sqliteExecuteBatch.cpp +1 -1
  7. package/cpp/sqliteExecuteBatch.hpp +2 -2
  8. package/cpp/types.hpp +3 -4
  9. package/lib/commonjs/index.js +4 -25
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/operations/execute.js +9 -26
  12. package/lib/commonjs/operations/execute.js.map +1 -1
  13. package/lib/commonjs/operations/executeBatch.js +2 -19
  14. package/lib/commonjs/operations/executeBatch.js.map +1 -1
  15. package/lib/commonjs/specs/{NativeQueryResult.nitro.js → NitroSQLiteQueryResult.nitro.js} +1 -1
  16. package/lib/commonjs/specs/NitroSQLiteQueryResult.nitro.js.map +1 -0
  17. package/lib/commonjs/types.js +1 -8
  18. package/lib/commonjs/types.js.map +1 -1
  19. package/lib/module/index.js +3 -1
  20. package/lib/module/index.js.map +1 -1
  21. package/lib/module/operations/execute.js +9 -27
  22. package/lib/module/operations/execute.js.map +1 -1
  23. package/lib/module/operations/executeBatch.js +2 -19
  24. package/lib/module/operations/executeBatch.js.map +1 -1
  25. package/lib/module/specs/NitroSQLiteQueryResult.nitro.js +4 -0
  26. package/lib/module/specs/NitroSQLiteQueryResult.nitro.js.map +1 -0
  27. package/lib/module/types.js +0 -12
  28. package/lib/module/types.js.map +1 -1
  29. package/lib/typescript/commonjs/index.d.ts +2 -1
  30. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  31. package/lib/typescript/commonjs/operations/execute.d.ts +1 -1
  32. package/lib/typescript/commonjs/operations/execute.d.ts.map +1 -1
  33. package/lib/typescript/commonjs/operations/executeBatch.d.ts +1 -1
  34. package/lib/typescript/commonjs/operations/executeBatch.d.ts.map +1 -1
  35. package/lib/typescript/commonjs/operations/transaction.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/specs/NitroSQLite.nitro.d.ts +6 -6
  37. package/lib/typescript/commonjs/specs/NitroSQLite.nitro.d.ts.map +1 -1
  38. package/lib/typescript/commonjs/specs/{NativeQueryResult.nitro.d.ts → NitroSQLiteQueryResult.nitro.d.ts} +20 -13
  39. package/lib/typescript/commonjs/specs/NitroSQLiteQueryResult.nitro.d.ts.map +1 -0
  40. package/lib/typescript/commonjs/typeORM.d.ts +1 -1
  41. package/lib/typescript/commonjs/typeORM.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/types.d.ts +16 -37
  43. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  44. package/lib/typescript/module/index.d.ts +2 -1
  45. package/lib/typescript/module/index.d.ts.map +1 -1
  46. package/lib/typescript/module/operations/execute.d.ts +1 -1
  47. package/lib/typescript/module/operations/execute.d.ts.map +1 -1
  48. package/lib/typescript/module/operations/executeBatch.d.ts +1 -1
  49. package/lib/typescript/module/operations/executeBatch.d.ts.map +1 -1
  50. package/lib/typescript/module/operations/transaction.d.ts.map +1 -1
  51. package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts +6 -6
  52. package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts.map +1 -1
  53. package/lib/typescript/module/specs/{NativeQueryResult.nitro.d.ts → NitroSQLiteQueryResult.nitro.d.ts} +20 -13
  54. package/lib/typescript/module/specs/NitroSQLiteQueryResult.nitro.d.ts.map +1 -0
  55. package/lib/typescript/module/typeORM.d.ts +1 -1
  56. package/lib/typescript/module/typeORM.d.ts.map +1 -1
  57. package/lib/typescript/module/types.d.ts +16 -37
  58. package/lib/typescript/module/types.d.ts.map +1 -1
  59. package/nitrogen/generated/android/RNNitroSQLite+autolinking.cmake +9 -6
  60. package/nitrogen/generated/android/RNNitroSQLite+autolinking.gradle +1 -1
  61. package/nitrogen/generated/android/RNNitroSQLiteOnLoad.cpp +2 -4
  62. package/nitrogen/generated/android/RNNitroSQLiteOnLoad.hpp +1 -1
  63. package/nitrogen/generated/android/c++/JHybridNitroSQLiteOnLoadSpec.cpp +14 -1
  64. package/nitrogen/generated/android/c++/JHybridNitroSQLiteOnLoadSpec.hpp +4 -1
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnnitrosqlite/HybridNitroSQLiteOnLoadSpec.kt +8 -3
  66. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnnitrosqlite/RNNitroSQLiteOnLoad.kt +1 -1
  67. package/nitrogen/generated/ios/RNNitroSQLite+autolinking.rb +2 -2
  68. package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Bridge.cpp +1 -1
  69. package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Bridge.hpp +1 -1
  70. package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Umbrella.hpp +1 -1
  71. package/nitrogen/generated/ios/RNNitroSQLiteAutolinking.mm +1 -1
  72. package/nitrogen/generated/ios/RNNitroSQLiteAutolinking.swift +5 -1
  73. package/nitrogen/generated/shared/c++/BatchQueryCommand.hpp +92 -0
  74. package/nitrogen/generated/shared/c++/BatchQueryResult.hpp +25 -11
  75. package/nitrogen/generated/shared/c++/ColumnType.hpp +5 -7
  76. package/nitrogen/generated/shared/c++/FileLoadResult.hpp +28 -14
  77. package/nitrogen/generated/shared/c++/HybridNitroSQLiteOnLoadSpec.cpp +1 -1
  78. package/nitrogen/generated/shared/c++/HybridNitroSQLiteOnLoadSpec.hpp +1 -1
  79. package/nitrogen/generated/shared/c++/HybridNitroSQLiteQueryResultSpec.cpp +25 -0
  80. package/nitrogen/generated/shared/c++/HybridNitroSQLiteQueryResultSpec.hpp +77 -0
  81. package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.cpp +1 -1
  82. package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.hpp +12 -16
  83. package/nitrogen/generated/shared/c++/NitroSQLiteQueryColumnMetadata.hpp +93 -0
  84. package/nitrogen/generated/shared/c++/NitroSQLiteQueryResultRows.hpp +99 -0
  85. package/package.json +5 -5
  86. package/src/index.ts +3 -6
  87. package/src/operations/execute.ts +14 -58
  88. package/src/operations/executeBatch.ts +3 -41
  89. package/src/operations/session.ts +1 -1
  90. package/src/operations/transaction.ts +1 -1
  91. package/src/specs/NitroSQLite.nitro.ts +9 -12
  92. package/src/specs/{NativeQueryResult.nitro.ts → NitroSQLiteQueryResult.nitro.ts} +32 -17
  93. package/src/typeORM.ts +1 -1
  94. package/src/types.ts +26 -46
  95. package/cpp/specs/HybridNativeQueryResult.cpp +0 -21
  96. package/lib/commonjs/nullHandling.js +0 -33
  97. package/lib/commonjs/nullHandling.js.map +0 -1
  98. package/lib/commonjs/specs/NativeQueryResult.nitro.js.map +0 -1
  99. package/lib/module/nullHandling.js +0 -25
  100. package/lib/module/nullHandling.js.map +0 -1
  101. package/lib/module/specs/NativeQueryResult.nitro.js +0 -4
  102. package/lib/module/specs/NativeQueryResult.nitro.js.map +0 -1
  103. package/lib/typescript/commonjs/nullHandling.d.ts +0 -8
  104. package/lib/typescript/commonjs/nullHandling.d.ts.map +0 -1
  105. package/lib/typescript/commonjs/specs/NativeQueryResult.nitro.d.ts.map +0 -1
  106. package/lib/typescript/module/nullHandling.d.ts +0 -8
  107. package/lib/typescript/module/nullHandling.d.ts.map +0 -1
  108. package/lib/typescript/module/specs/NativeQueryResult.nitro.d.ts.map +0 -1
  109. package/nitrogen/generated/shared/c++/HybridNativeQueryResultSpec.cpp +0 -24
  110. package/nitrogen/generated/shared/c++/HybridNativeQueryResultSpec.hpp +0 -77
  111. package/nitrogen/generated/shared/c++/NativeBatchQueryCommand.hpp +0 -81
  112. package/nitrogen/generated/shared/c++/SQLiteNullValue.hpp +0 -69
  113. package/nitrogen/generated/shared/c++/SQLiteQueryColumnMetadata.hpp +0 -79
  114. 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 © 2025 Marc Rousavy @ Margelo
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 `HybridNativeQueryResultSpec` to properly resolve imports.
17
- namespace margelo::nitro::rnnitrosqlite { class HybridNativeQueryResultSpec; }
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 `NativeBatchQueryCommand` to properly resolve imports.
25
- namespace margelo::nitro::rnnitrosqlite { struct NativeBatchQueryCommand; }
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 "HybridNativeQueryResultSpec.hpp"
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 "NativeBatchQueryCommand.hpp"
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<margelo::nitro::rnnitrosqlite::HybridNativeQueryResultSpec> execute(const std::string& dbName, const std::string& query, const std::optional<std::vector<std::variant<std::string, double, bool, std::shared_ptr<ArrayBuffer>, SQLiteNullValue>>>& params) = 0;
79
- virtual std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::rnnitrosqlite::HybridNativeQueryResultSpec>>> executeAsync(const std::string& dbName, const std::string& query, const std::optional<std::vector<std::variant<std::string, double, bool, std::shared_ptr<ArrayBuffer>, SQLiteNullValue>>>& params) = 0;
80
- virtual BatchQueryResult executeBatch(const std::string& dbName, const std::vector<NativeBatchQueryCommand>& commands) = 0;
81
- virtual std::shared_ptr<Promise<BatchQueryResult>> executeBatchAsync(const std::string& dbName, const std::vector<NativeBatchQueryCommand>& commands) = 0;
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.2.2",
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 nitro-codegen --logLevel=\"debug\"",
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",
@@ -70,16 +70,16 @@
70
70
  },
71
71
  "devDependencies": {
72
72
  "jest": "^30.2.0",
73
- "nitro-codegen": "0.27.2",
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.27.2"
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.27.2"
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 { replaceWithNativeNullValue } from '../nullHandling'
4
- import type { NativeQueryResult } from '../specs/NativeQueryResult.nitro'
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 nativeResult = HybridNitroSQLite.execute(
24
- dbName,
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 nativeResult = await HybridNitroSQLite.executeAsync(
46
- dbName,
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 toNativeQueryParams(
57
- params: SQLiteQueryParams | undefined,
58
- ): NativeSQLiteQueryParams | undefined {
59
- return params?.map((param) => replaceWithNativeNullValue(param))
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
- insertId,
84
- rowsAffected,
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, transformedCommands),
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,8 +1,8 @@
1
1
  import { queueOperationAsync, throwIfDatabaseIsNotOpen } from '../DatabaseQueue'
2
2
  import type {
3
- QueryResult,
4
3
  Transaction,
5
4
  SQLiteQueryParams,
5
+ QueryResult,
6
6
  QueryResultRow,
7
7
  } from '../types'
8
8
  import { execute, executeAsync } from './execute'
@@ -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
- NativeSQLiteQueryParams,
6
- NativeBatchQueryCommand,
6
+ SQLiteQueryParams,
7
7
  } from '../types'
8
- import type { NativeQueryResult } from './NativeQueryResult.nitro'
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?: NativeSQLiteQueryParams,
26
- ): NativeQueryResult
25
+ params?: SQLiteQueryParams,
26
+ ): NitroSQLiteQueryResult
27
27
  executeAsync(
28
28
  dbName: string,
29
29
  query: string,
30
- params?: NativeSQLiteQueryParams,
31
- ): Promise<NativeQueryResult>
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: NativeBatchQueryCommand[],
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 NativeQueryResult
12
+ * @interface QueryResult
13
13
  */
14
- export interface NativeQueryResult
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: NativeSQLiteQueryResults
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, SQLiteQueryColumnMetadata>
26
+ readonly metadata?: Record<string, NitroSQLiteQueryColumnMetadata>
23
27
  }
24
28
 
25
- /**
26
- * Table metadata
27
- * Describes some information about the table and it's columns fetched by the query
28
- * The index is the name of the column
29
- */
30
- // TODO: Investigate why this doesn't work with nitrogen
31
- // export type SQLiteQueryResultRow = Record<string, SQLiteValue>
32
- // export type SQLiteQueryResults = SQLiteQueryResultRow[]
33
- export type NativeSQLiteQueryResults = Record<string, SQLiteValue>[]
34
-
35
- // TODO: Investigate why this doesn't work with nitrogen
36
- // export type SQLiteQueryTableMetadata = Record<string, SQLiteQueryColumnMetadata>
37
- export interface SQLiteQueryColumnMetadata {
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
@@ -6,10 +6,10 @@
6
6
  // |_| |_| |_| |______\____/|_| \_\_| |_| /_/ \_\_| |_____|
7
7
 
8
8
  import type {
9
- QueryResult,
10
9
  Transaction,
11
10
  SQLiteQueryParams,
12
11
  QueryResultRow,
12
+ QueryResult,
13
13
  } from './types'
14
14
  import * as Operations from './operations/session'
15
15