react-native-nitro-sqlite 9.3.0 → 9.4.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/android/CMakeLists.txt +1 -1
- package/cpp/NitroSQLiteException.hpp +1 -2
- package/cpp/{specs → hybridObjects}/HybridNitroSQLite.cpp +56 -9
- package/cpp/hybridObjects/HybridNitroSQLiteQueryResult.cpp +93 -0
- package/cpp/hybridObjects/HybridNitroSQLiteQueryResult.hpp +47 -0
- package/cpp/operations.cpp +13 -9
- package/cpp/operations.hpp +3 -1
- package/cpp/sqliteExecuteBatch.cpp +1 -1
- package/cpp/types.hpp +1 -10
- package/ios/NitroSQLite.xcodeproj/project.pbxproj +2 -2
- package/lib/commonjs/index.js +0 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/operations/execute.js +19 -15
- package/lib/commonjs/operations/execute.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/index.js +0 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/operations/execute.js +19 -15
- package/lib/module/operations/execute.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +0 -2
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/operations/execute.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/NitroSQLiteQueryResult.nitro.d.ts +0 -13
- package/lib/typescript/commonjs/specs/NitroSQLiteQueryResult.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +13 -8
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +0 -2
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/operations/execute.d.ts.map +1 -1
- package/lib/typescript/module/specs/NitroSQLiteQueryResult.nitro.d.ts +0 -13
- package/lib/typescript/module/specs/NitroSQLiteQueryResult.nitro.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +13 -8
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteQueryResultSpec.cpp +0 -1
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteQueryResultSpec.hpp +0 -4
- package/package.json +1 -1
- package/src/index.ts +0 -3
- package/src/operations/execute.ts +26 -17
- package/src/specs/NitroSQLiteQueryResult.nitro.ts +0 -17
- package/src/types.ts +17 -14
- package/cpp/specs/HybridNitroSQLiteQueryResult.cpp +0 -49
- package/cpp/specs/HybridNitroSQLiteQueryResult.hpp +0 -28
- package/nitrogen/generated/shared/c++/NitroSQLiteQueryResultRows.hpp +0 -99
- /package/cpp/{specs → hybridObjects}/HybridNitroSQLite.hpp +0 -0
package/android/CMakeLists.txt
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
#include <exception>
|
|
4
4
|
#include <iostream>
|
|
5
|
-
#include <string>
|
|
6
5
|
#include <optional>
|
|
6
|
+
#include <string>
|
|
7
7
|
|
|
8
8
|
const std::string NITRO_SQLITE_EXCEPTION_PREFIX = "[NativeNitroSQLiteException]";
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
enum NitroSQLiteExceptionType {
|
|
12
11
|
UnknownError,
|
|
13
12
|
DatabaseCannotBeOpened,
|
|
@@ -8,11 +8,54 @@
|
|
|
8
8
|
#include "sqliteExecuteBatch.hpp"
|
|
9
9
|
#include <iostream>
|
|
10
10
|
#include <map>
|
|
11
|
+
#include <optional>
|
|
11
12
|
#include <string>
|
|
13
|
+
#include <variant>
|
|
12
14
|
#include <vector>
|
|
13
15
|
|
|
14
16
|
namespace margelo::nitro::rnnitrosqlite {
|
|
15
17
|
|
|
18
|
+
// Copy any JS-backed ArrayBuffers on the JS thread so they can be safely
|
|
19
|
+
// accessed from the background thread used by Promise::async.
|
|
20
|
+
static std::optional<SQLiteQueryParams> copyArrayBufferParamsForBackground(const std::optional<SQLiteQueryParams>& params) {
|
|
21
|
+
if (!params) {
|
|
22
|
+
return std::nullopt;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
SQLiteQueryParams copiedParams;
|
|
26
|
+
copiedParams.reserve(params->size());
|
|
27
|
+
|
|
28
|
+
for (const auto& value : *params) {
|
|
29
|
+
if (std::holds_alternative<std::shared_ptr<ArrayBuffer>>(value)) {
|
|
30
|
+
const auto& buffer = std::get<std::shared_ptr<ArrayBuffer>>(value);
|
|
31
|
+
const auto copiedBuffer = ArrayBuffer::copy(buffer);
|
|
32
|
+
copiedParams.push_back(copiedBuffer);
|
|
33
|
+
} else {
|
|
34
|
+
copiedParams.push_back(value);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return copiedParams;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Overload for batch execution: copy ArrayBuffer params inside each BatchQuery.
|
|
42
|
+
static std::vector<BatchQuery> copyArrayBufferParamsForBackground(const std::vector<BatchQuery>& commands) {
|
|
43
|
+
std::vector<BatchQuery> copiedCommands;
|
|
44
|
+
copiedCommands.reserve(commands.size());
|
|
45
|
+
|
|
46
|
+
for (const auto& command : commands) {
|
|
47
|
+
BatchQuery copiedCommand = command;
|
|
48
|
+
|
|
49
|
+
if (command.params) {
|
|
50
|
+
copiedCommand.params = copyArrayBufferParamsForBackground(command.params);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
copiedCommands.push_back(std::move(copiedCommand));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return copiedCommands;
|
|
57
|
+
}
|
|
58
|
+
|
|
16
59
|
const std::string getDocPath(const std::optional<std::string>& location) {
|
|
17
60
|
std::string tempDocPath = std::string(HybridNitroSQLite::docPath);
|
|
18
61
|
if (location) {
|
|
@@ -50,19 +93,18 @@ void HybridNitroSQLite::detach(const std::string& mainDbName, const std::string&
|
|
|
50
93
|
sqliteDetachDb(mainDbName, alias);
|
|
51
94
|
};
|
|
52
95
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const std::optional<SQLiteQueryParams>& params) {
|
|
57
|
-
SQLiteExecuteQueryResult result = sqliteExecute(dbName, query, params);
|
|
58
|
-
return std::make_shared<HybridNitroSQLiteQueryResult>(std::move(result));
|
|
96
|
+
std::shared_ptr<HybridNitroSQLiteQueryResultSpec> HybridNitroSQLite::execute(const std::string& dbName, const std::string& query,
|
|
97
|
+
const std::optional<SQLiteQueryParams>& params) {
|
|
98
|
+
return sqliteExecute(dbName, query, params);
|
|
59
99
|
};
|
|
60
100
|
|
|
61
101
|
std::shared_ptr<Promise<std::shared_ptr<HybridNitroSQLiteQueryResultSpec>>>
|
|
62
102
|
HybridNitroSQLite::executeAsync(const std::string& dbName, const std::string& query, const std::optional<SQLiteQueryParams>& params) {
|
|
103
|
+
const auto copiedParams = copyArrayBufferParamsForBackground(params);
|
|
104
|
+
|
|
63
105
|
return Promise<std::shared_ptr<HybridNitroSQLiteQueryResultSpec>>::async(
|
|
64
106
|
[=, this]() -> std::shared_ptr<HybridNitroSQLiteQueryResultSpec> {
|
|
65
|
-
auto result =
|
|
107
|
+
auto result = sqliteExecute(dbName, query, copiedParams);
|
|
66
108
|
return result;
|
|
67
109
|
});
|
|
68
110
|
};
|
|
@@ -76,9 +118,14 @@ BatchQueryResult HybridNitroSQLite::executeBatch(const std::string& dbName, cons
|
|
|
76
118
|
|
|
77
119
|
std::shared_ptr<Promise<BatchQueryResult>> HybridNitroSQLite::executeBatchAsync(const std::string& dbName,
|
|
78
120
|
const std::vector<BatchQueryCommand>& batchParams) {
|
|
121
|
+
// Convert BatchQueryCommand objects on the JS thread and copy any JS-backed
|
|
122
|
+
// ArrayBuffers into native buffers before going off-thread.
|
|
123
|
+
const auto commands = batchParamsToCommands(batchParams);
|
|
124
|
+
const auto copiedCommands = copyArrayBufferParamsForBackground(commands);
|
|
125
|
+
|
|
79
126
|
return Promise<BatchQueryResult>::async([=, this]() -> BatchQueryResult {
|
|
80
|
-
auto result =
|
|
81
|
-
return result;
|
|
127
|
+
auto result = sqliteExecuteBatch(dbName, copiedCommands);
|
|
128
|
+
return BatchQueryResult(result.rowsAffected);
|
|
82
129
|
});
|
|
83
130
|
};
|
|
84
131
|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#include "HybridNitroSQLiteQueryResult.hpp"
|
|
2
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
3
|
+
#include <NitroModules/Null.hpp>
|
|
4
|
+
#include <NitroModules/Promise.hpp>
|
|
5
|
+
#include <unordered_map>
|
|
6
|
+
#include <variant>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
10
|
+
|
|
11
|
+
namespace {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Compute the approximate external memory size of a single result row.
|
|
15
|
+
* This includes:
|
|
16
|
+
* - Column name string capacities,
|
|
17
|
+
* - Heap usage for the actual SQLiteValue contents.
|
|
18
|
+
*/
|
|
19
|
+
size_t getRowExternalMemorySize(const SQLiteQueryResultRow& row) {
|
|
20
|
+
size_t bucketMemory = row.bucket_count() * sizeof(void*);
|
|
21
|
+
constexpr size_t nodePadding = 24;
|
|
22
|
+
size_t nodesMemory = row.size() * (sizeof(std::pair<std::string, SQLiteValue>) * nodePadding);
|
|
23
|
+
return bucketMemory + nodesMemory;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Compute the approximate external memory size of the full result set.
|
|
28
|
+
* We add:
|
|
29
|
+
* - The vector's backing storage,
|
|
30
|
+
* - All rows (column names + values).
|
|
31
|
+
*/
|
|
32
|
+
size_t getResultsExternalMemorySize(const SQLiteQueryResults& results) {
|
|
33
|
+
size_t size = sizeof(SQLiteQueryResults);
|
|
34
|
+
|
|
35
|
+
const auto resultCapacity = results.capacity();
|
|
36
|
+
size += resultCapacity * sizeof(SQLiteQueryResultRow);
|
|
37
|
+
|
|
38
|
+
for (const auto& row : results) {
|
|
39
|
+
size += getRowExternalMemorySize(row);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return size;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Compute the approximate external memory size of the table metadata.
|
|
47
|
+
* We include:
|
|
48
|
+
* - Column name string capacities (map keys),
|
|
49
|
+
* - Metadata contents, especially the `name` string on each metadata entry.
|
|
50
|
+
*/
|
|
51
|
+
size_t getMetadataExternalMemorySize(const SQLiteQueryTableMetadata& metadata) {
|
|
52
|
+
size_t size = 0;
|
|
53
|
+
|
|
54
|
+
for (const auto& [columnName, columnMeta] : metadata) {
|
|
55
|
+
|
|
56
|
+
size += columnName.capacity();
|
|
57
|
+
size += columnMeta.name.capacity();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return size;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
} // namespace
|
|
64
|
+
|
|
65
|
+
std::optional<double> HybridNitroSQLiteQueryResult::getInsertId() {
|
|
66
|
+
return _insertId;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
double HybridNitroSQLiteQueryResult::getRowsAffected() {
|
|
70
|
+
return _rowsAffected;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
SQLiteQueryResults HybridNitroSQLiteQueryResult::getResults() {
|
|
74
|
+
return _results;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
std::optional<SQLiteQueryTableMetadata> HybridNitroSQLiteQueryResult::getMetadata() {
|
|
78
|
+
return _metadata;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
size_t HybridNitroSQLiteQueryResult::getExternalMemorySize() noexcept {
|
|
82
|
+
size_t size = sizeof(*this);
|
|
83
|
+
|
|
84
|
+
size += getResultsExternalMemorySize(_results);
|
|
85
|
+
|
|
86
|
+
if (_metadata) {
|
|
87
|
+
size += getMetadataExternalMemorySize(*_metadata);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return size;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "HybridNitroSQLiteQueryResultSpec.hpp"
|
|
4
|
+
#include "types.hpp"
|
|
5
|
+
#include <map>
|
|
6
|
+
|
|
7
|
+
using namespace margelo::rnnitrosqlite;
|
|
8
|
+
|
|
9
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
10
|
+
|
|
11
|
+
class HybridNitroSQLiteQueryResult : public HybridNitroSQLiteQueryResultSpec {
|
|
12
|
+
public:
|
|
13
|
+
HybridNitroSQLiteQueryResult() : HybridObject(TAG) {}
|
|
14
|
+
HybridNitroSQLiteQueryResult(SQLiteQueryResults results, std::optional<double> insertId, double rowsAffected,
|
|
15
|
+
std::optional<SQLiteQueryTableMetadata> metadata)
|
|
16
|
+
: HybridObject(TAG), _insertId(insertId), _rowsAffected(rowsAffected), _results(std::move(results)), _metadata(metadata) {}
|
|
17
|
+
|
|
18
|
+
private:
|
|
19
|
+
std::optional<double> _insertId;
|
|
20
|
+
double _rowsAffected;
|
|
21
|
+
SQLiteQueryResults _results;
|
|
22
|
+
std::optional<SQLiteQueryTableMetadata> _metadata;
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
// Properties
|
|
26
|
+
std::optional<double> getInsertId() override;
|
|
27
|
+
double getRowsAffected() override;
|
|
28
|
+
SQLiteQueryResults getResults() override;
|
|
29
|
+
std::optional<SQLiteQueryTableMetadata> getMetadata() override;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Approximate the native memory used by this query result.
|
|
33
|
+
*
|
|
34
|
+
* We account for:
|
|
35
|
+
* - The size of this C++ object (`sizeof(*this)`),
|
|
36
|
+
* - All rows and columns (including column name strings),
|
|
37
|
+
* - String values stored in the result set,
|
|
38
|
+
* - ArrayBuffers used for BLOB columns (object overhead + raw byte size),
|
|
39
|
+
* - Column metadata strings.
|
|
40
|
+
*
|
|
41
|
+
* This is a best-effort estimate and intentionally focuses on external
|
|
42
|
+
* heap allocations that can put pressure on the JS GC.
|
|
43
|
+
*/
|
|
44
|
+
size_t getExternalMemorySize() noexcept override;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
package/cpp/operations.cpp
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#include "operations.hpp"
|
|
2
2
|
#include "NitroSQLiteException.hpp"
|
|
3
|
+
#include "hybridObjects/HybridNitroSQLiteQueryResult.hpp"
|
|
3
4
|
#include "logs.hpp"
|
|
4
5
|
#include "utils.hpp"
|
|
5
6
|
#include <NitroModules/ArrayBuffer.hpp>
|
|
@@ -121,8 +122,8 @@ void bindStatement(sqlite3_stmt* statement, const SQLiteQueryParams& values) {
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
std::shared_ptr<HybridNitroSQLiteQueryResult> sqliteExecute(const std::string& dbName, const std::string& query,
|
|
126
|
+
const std::optional<SQLiteQueryParams>& params) {
|
|
126
127
|
if (dbMap.count(dbName) == 0) {
|
|
127
128
|
throw NitroSQLiteException::DatabaseNotOpen(dbName);
|
|
128
129
|
}
|
|
@@ -183,9 +184,15 @@ SQLiteExecuteQueryResult sqliteExecute(const std::string& dbName, const std::str
|
|
|
183
184
|
case SQLITE_BLOB: {
|
|
184
185
|
int blob_size = sqlite3_column_bytes(statement, i);
|
|
185
186
|
const void* blob = sqlite3_column_blob(statement, i);
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
// Copy the SQLite BLOB into a new native ArrayBuffer.
|
|
188
|
+
// This avoids manual memory management and unsafe pointer handling.
|
|
189
|
+
if (blob_size > 0) {
|
|
190
|
+
const auto* blob_data = reinterpret_cast<const uint8_t*>(blob);
|
|
191
|
+
row[column_name] = ArrayBuffer::copy(blob_data, static_cast<size_t>(blob_size));
|
|
192
|
+
} else {
|
|
193
|
+
// Represent empty BLOBs as an empty, but valid, ArrayBuffer.
|
|
194
|
+
row[column_name] = ArrayBuffer::allocate(0);
|
|
195
|
+
}
|
|
189
196
|
break;
|
|
190
197
|
}
|
|
191
198
|
case SQLITE_NULL:
|
|
@@ -229,10 +236,7 @@ SQLiteExecuteQueryResult sqliteExecute(const std::string& dbName, const std::str
|
|
|
229
236
|
|
|
230
237
|
int rowsAffected = sqlite3_changes(db);
|
|
231
238
|
long long latestInsertRowId = sqlite3_last_insert_rowid(db);
|
|
232
|
-
return
|
|
233
|
-
.insertId = static_cast<double>(latestInsertRowId),
|
|
234
|
-
.results = std::move(results),
|
|
235
|
-
.metadata = std::move(metadata)};
|
|
239
|
+
return std::make_shared<HybridNitroSQLiteQueryResult>(results, static_cast<double>(latestInsertRowId), rowsAffected, metadata);
|
|
236
240
|
}
|
|
237
241
|
|
|
238
242
|
SQLiteOperationResult sqliteExecuteLiteral(const std::string& dbName, const std::string& query) {
|
package/cpp/operations.hpp
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include "hybridObjects/HybridNitroSQLiteQueryResult.hpp"
|
|
3
4
|
#include "types.hpp"
|
|
4
5
|
|
|
5
6
|
namespace margelo::rnnitrosqlite {
|
|
@@ -15,7 +16,8 @@ void sqliteAttachDb(const std::string& mainDBName, const std::string& docPath, c
|
|
|
15
16
|
|
|
16
17
|
void sqliteDetachDb(const std::string& mainDBName, const std::string& alias);
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
std::shared_ptr<HybridNitroSQLiteQueryResult> sqliteExecute(const std::string& dbName, const std::string& query,
|
|
20
|
+
const std::optional<SQLiteQueryParams>& params);
|
|
19
21
|
|
|
20
22
|
SQLiteOperationResult sqliteExecuteLiteral(const std::string& dbName, const std::string& query);
|
|
21
23
|
|
|
@@ -49,7 +49,7 @@ SQLiteOperationResult sqliteExecuteBatch(const std::string& dbName, const std::v
|
|
|
49
49
|
auto metadata = std::optional<SQLiteQueryTableMetadata>(std::nullopt);
|
|
50
50
|
try {
|
|
51
51
|
auto result = sqliteExecute(dbName, command.sql, command.params);
|
|
52
|
-
rowsAffected += result
|
|
52
|
+
rowsAffected += result->getRowsAffected();
|
|
53
53
|
} catch (NitroSQLiteException& e) {
|
|
54
54
|
sqliteExecuteLiteral(dbName, "ROLLBACK");
|
|
55
55
|
throw e;
|
package/cpp/types.hpp
CHANGED
|
@@ -18,16 +18,7 @@ using SQLiteQueryTableMetadata = std::unordered_map<std::string, NitroSQLiteQuer
|
|
|
18
18
|
|
|
19
19
|
struct SQLiteOperationResult {
|
|
20
20
|
int rowsAffected;
|
|
21
|
-
|
|
22
|
-
int commands;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
struct SQLiteExecuteQueryResult {
|
|
26
|
-
int rowsAffected;
|
|
27
|
-
double insertId;
|
|
28
|
-
|
|
29
|
-
SQLiteQueryResults results;
|
|
30
|
-
std::optional<SQLiteQueryTableMetadata> metadata;
|
|
21
|
+
int commands = 0;
|
|
31
22
|
};
|
|
32
23
|
|
|
33
24
|
// constexpr function that maps SQLiteColumnType to string literals
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
path = ../nitrogen;
|
|
174
174
|
sourceTree = "<group>";
|
|
175
175
|
};
|
|
176
|
-
83BC6E5F2C8F78A200B954D2 /*
|
|
176
|
+
83BC6E5F2C8F78A200B954D2 /* hybridObjects */ = {
|
|
177
177
|
isa = PBXGroup;
|
|
178
178
|
children = (
|
|
179
179
|
83BC6E5A2C8F78A200B954D2 /* HybridNitroSQLite.cpp */,
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
83BC6E702C8F78A200B954D2 /* cpp */ = {
|
|
189
189
|
isa = PBXGroup;
|
|
190
190
|
children = (
|
|
191
|
-
83BC6E5F2C8F78A200B954D2 /*
|
|
191
|
+
83BC6E5F2C8F78A200B954D2 /* hybridObjects */,
|
|
192
192
|
83BC6E602C8F78A200B954D2 /* JSIHelper.cpp */,
|
|
193
193
|
83BC6E612C8F78A200B954D2 /* JSIHelper.h */,
|
|
194
194
|
83BC6E622C8F78A200B954D2 /* logs.h */,
|
package/lib/commonjs/index.js
CHANGED
|
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "NitroSQLiteError", {
|
|
|
10
10
|
return _NitroSQLiteError.default;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
exports.enableSimpleNullHandling = enableSimpleNullHandling;
|
|
14
13
|
Object.defineProperty(exports, "open", {
|
|
15
14
|
enumerable: true,
|
|
16
15
|
get: function () {
|
|
@@ -46,7 +45,4 @@ const NitroSQLite = exports.NitroSQLite = {
|
|
|
46
45
|
executeBatch: _executeBatch.executeBatch,
|
|
47
46
|
executeBatchAsync: _executeBatch.executeBatchAsync
|
|
48
47
|
};
|
|
49
|
-
|
|
50
|
-
/** NOOP on NitroSQLite versions >= 9.3.0 */
|
|
51
|
-
function enableSimpleNullHandling() {}
|
|
52
48
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_transaction","require","_nitro","_session","_execute","_OnLoad","_executeBatch","_NitroSQLiteError","_interopRequireDefault","_typeORM","e","__esModule","default","init","NitroSQLite","exports","HybridNitroSQLite","native","open","transaction","execute","executeAsync","executeBatch","executeBatchAsync"
|
|
1
|
+
{"version":3,"names":["_transaction","require","_nitro","_session","_execute","_OnLoad","_executeBatch","_NitroSQLiteError","_interopRequireDefault","_typeORM","e","__esModule","default","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;AAmBA,IAAAM,iBAAA,GAAAC,sBAAA,CAAAP,OAAA;AAEA,IAAAQ,QAAA,GAAAR,OAAA;AAAyC,SAAAO,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAnBzC,IAAAG,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":[]}
|
|
@@ -10,31 +10,35 @@ var _NitroSQLiteError = _interopRequireDefault(require("../NitroSQLiteError.js")
|
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
function execute(dbName, query, params) {
|
|
12
12
|
try {
|
|
13
|
-
const
|
|
14
|
-
return
|
|
13
|
+
const nativeResult = _nitro.HybridNitroSQLite.execute(dbName, query, params);
|
|
14
|
+
return buildJSQueryResult(nativeResult);
|
|
15
15
|
} catch (error) {
|
|
16
16
|
throw _NitroSQLiteError.default.fromError(error);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
async function executeAsync(dbName, query, params) {
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
22
|
-
return
|
|
21
|
+
const nativeResult = await _nitro.HybridNitroSQLite.executeAsync(dbName, query, params);
|
|
22
|
+
return buildJSQueryResult(nativeResult);
|
|
23
23
|
} catch (error) {
|
|
24
24
|
throw _NitroSQLiteError.default.fromError(error);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
rows: {
|
|
34
|
-
_array: data,
|
|
35
|
-
length: data.length,
|
|
36
|
-
item: idx => data[idx]
|
|
37
|
-
}
|
|
27
|
+
function buildJSQueryResult(result) {
|
|
28
|
+
const resultWithRows = result;
|
|
29
|
+
resultWithRows.rows = {
|
|
30
|
+
_array: result.results,
|
|
31
|
+
length: result.results.length,
|
|
32
|
+
item: idx => result.results[idx]
|
|
38
33
|
};
|
|
34
|
+
return resultWithRows;
|
|
35
|
+
|
|
36
|
+
// return Object.assign(result, {
|
|
37
|
+
// rows: {
|
|
38
|
+
// _array: result.results,
|
|
39
|
+
// length: result.results.length,
|
|
40
|
+
// item: (idx: number) => result.results[idx],
|
|
41
|
+
// },
|
|
42
|
+
// })
|
|
39
43
|
}
|
|
40
44
|
//# sourceMappingURL=execute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_nitro","require","_NitroSQLiteError","_interopRequireDefault","e","__esModule","default","execute","dbName","query","params","
|
|
1
|
+
{"version":3,"names":["_nitro","require","_NitroSQLiteError","_interopRequireDefault","e","__esModule","default","execute","dbName","query","params","nativeResult","HybridNitroSQLite","buildJSQueryResult","error","NitroSQLiteError","fromError","executeAsync","result","resultWithRows","rows","_array","results","length","item","idx"],"sourceRoot":"../../../src","sources":["operations/execute.ts"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAkD,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG3C,SAASG,OAAOA,CACrBC,MAAc,EACdC,KAAa,EACbC,MAA0B,EACR;EAClB,IAAI;IACF,MAAMC,YAAY,GAAGC,wBAAiB,CAACL,OAAO,CAACC,MAAM,EAAEC,KAAK,EAAEC,MAAM,CAAC;IACrE,OAAOG,kBAAkB,CAAMF,YAAY,CAAC;EAC9C,CAAC,CAAC,OAAOG,KAAK,EAAE;IACd,MAAMC,yBAAgB,CAACC,SAAS,CAACF,KAAK,CAAC;EACzC;AACF;AAEO,eAAeG,YAAYA,CAChCT,MAAc,EACdC,KAAa,EACbC,MAA0B,EACC;EAC3B,IAAI;IACF,MAAMC,YAAY,GAAG,MAAMC,wBAAiB,CAACK,YAAY,CACvDT,MAAM,EACNC,KAAK,EACLC,MACF,CAAC;IACD,OAAOG,kBAAkB,CAAMF,YAAY,CAAC;EAC9C,CAAC,CAAC,OAAOG,KAAK,EAAE;IACd,MAAMC,yBAAgB,CAACC,SAAS,CAACF,KAAK,CAAC;EACzC;AACF;AAEA,SAASD,kBAAkBA,CACzBK,MAA8B,EACZ;EAClB,MAAMC,cAAc,GAAGD,MAA0B;EAEjDC,cAAc,CAACC,IAAI,GAAG;IACpBC,MAAM,EAAEH,MAAM,CAACI,OAAgB;IAC/BC,MAAM,EAAEL,MAAM,CAACI,OAAO,CAACC,MAAM;IAC7BC,IAAI,EAAGC,GAAW,IAAKP,MAAM,CAACI,OAAO,CAACG,GAAG;EAC3C,CAAC;EAED,OAAON,cAAc;;EAErB;EACA;EACA;EACA;EACA;EACA;EACA;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ColumnType","exports"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"names":["ColumnType","exports"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;;;;;IAuBYA,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;AAsDtB;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -20,9 +20,6 @@ export const NitroSQLite = {
|
|
|
20
20
|
executeBatch,
|
|
21
21
|
executeBatchAsync
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
/** NOOP on NitroSQLite versions >= 9.3.0 */
|
|
25
|
-
export function enableSimpleNullHandling() {}
|
|
26
23
|
export { open } from "./operations/session.js";
|
|
27
24
|
export { default as NitroSQLiteError } from "./NitroSQLiteError.js";
|
|
28
25
|
export { typeORMDriver } from "./typeORM.js";
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["transaction","HybridNitroSQLite","open","execute","executeAsync","init","executeBatch","executeBatchAsync","NitroSQLite","native","
|
|
1
|
+
{"version":3,"names":["transaction","HybridNitroSQLite","open","execute","executeAsync","init","executeBatch","executeBatchAsync","NitroSQLite","native","default","NitroSQLiteError","typeORMDriver"],"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;AAE3EF,IAAI,CAAC,CAAC;AAEN,OAAO,MAAMG,WAAW,GAAG;EACzB,GAAGP,iBAAiB;EACpBQ,MAAM,EAAER,iBAAiB;EACzB;EACA;EACAC,IAAI;EACJ;EACAF,WAAW;EACXG,OAAO;EACPC,YAAY;EACZE,YAAY;EACZC;AACF,CAAC;AAED,SAASL,IAAI,QAAQ,yBAAsB;AAC3C,SAASQ,OAAO,IAAIC,gBAAgB,QAAQ,uBAAoB;AAEhE,SAASC,aAAa,QAAQ,cAAW","ignoreList":[]}
|
|
@@ -4,31 +4,35 @@ import { HybridNitroSQLite } from "../nitro.js";
|
|
|
4
4
|
import NitroSQLiteError from "../NitroSQLiteError.js";
|
|
5
5
|
export function execute(dbName, query, params) {
|
|
6
6
|
try {
|
|
7
|
-
const
|
|
8
|
-
return
|
|
7
|
+
const nativeResult = HybridNitroSQLite.execute(dbName, query, params);
|
|
8
|
+
return buildJSQueryResult(nativeResult);
|
|
9
9
|
} catch (error) {
|
|
10
10
|
throw NitroSQLiteError.fromError(error);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
export async function executeAsync(dbName, query, params) {
|
|
14
14
|
try {
|
|
15
|
-
const
|
|
16
|
-
return
|
|
15
|
+
const nativeResult = await HybridNitroSQLite.executeAsync(dbName, query, params);
|
|
16
|
+
return buildJSQueryResult(nativeResult);
|
|
17
17
|
} catch (error) {
|
|
18
18
|
throw NitroSQLiteError.fromError(error);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
rows: {
|
|
28
|
-
_array: data,
|
|
29
|
-
length: data.length,
|
|
30
|
-
item: idx => data[idx]
|
|
31
|
-
}
|
|
21
|
+
function buildJSQueryResult(result) {
|
|
22
|
+
const resultWithRows = result;
|
|
23
|
+
resultWithRows.rows = {
|
|
24
|
+
_array: result.results,
|
|
25
|
+
length: result.results.length,
|
|
26
|
+
item: idx => result.results[idx]
|
|
32
27
|
};
|
|
28
|
+
return resultWithRows;
|
|
29
|
+
|
|
30
|
+
// return Object.assign(result, {
|
|
31
|
+
// rows: {
|
|
32
|
+
// _array: result.results,
|
|
33
|
+
// length: result.results.length,
|
|
34
|
+
// item: (idx: number) => result.results[idx],
|
|
35
|
+
// },
|
|
36
|
+
// })
|
|
33
37
|
}
|
|
34
38
|
//# sourceMappingURL=execute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HybridNitroSQLite","NitroSQLiteError","execute","dbName","query","params","
|
|
1
|
+
{"version":3,"names":["HybridNitroSQLite","NitroSQLiteError","execute","dbName","query","params","nativeResult","buildJSQueryResult","error","fromError","executeAsync","result","resultWithRows","rows","_array","results","length","item","idx"],"sourceRoot":"../../../src","sources":["operations/execute.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,aAAU;AAE5C,OAAOC,gBAAgB,MAAM,wBAAqB;AAGlD,OAAO,SAASC,OAAOA,CACrBC,MAAc,EACdC,KAAa,EACbC,MAA0B,EACR;EAClB,IAAI;IACF,MAAMC,YAAY,GAAGN,iBAAiB,CAACE,OAAO,CAACC,MAAM,EAAEC,KAAK,EAAEC,MAAM,CAAC;IACrE,OAAOE,kBAAkB,CAAMD,YAAY,CAAC;EAC9C,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,MAAMP,gBAAgB,CAACQ,SAAS,CAACD,KAAK,CAAC;EACzC;AACF;AAEA,OAAO,eAAeE,YAAYA,CAChCP,MAAc,EACdC,KAAa,EACbC,MAA0B,EACC;EAC3B,IAAI;IACF,MAAMC,YAAY,GAAG,MAAMN,iBAAiB,CAACU,YAAY,CACvDP,MAAM,EACNC,KAAK,EACLC,MACF,CAAC;IACD,OAAOE,kBAAkB,CAAMD,YAAY,CAAC;EAC9C,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,MAAMP,gBAAgB,CAACQ,SAAS,CAACD,KAAK,CAAC;EACzC;AACF;AAEA,SAASD,kBAAkBA,CACzBI,MAA8B,EACZ;EAClB,MAAMC,cAAc,GAAGD,MAA0B;EAEjDC,cAAc,CAACC,IAAI,GAAG;IACpBC,MAAM,EAAEH,MAAM,CAACI,OAAgB;IAC/BC,MAAM,EAAEL,MAAM,CAACI,OAAO,CAACC,MAAM;IAC7BC,IAAI,EAAGC,GAAW,IAAKP,MAAM,CAACI,OAAO,CAACG,GAAG;EAC3C,CAAC;EAED,OAAON,cAAc;;EAErB;EACA;EACA;EACA;EACA;EACA;EACA;AACF","ignoreList":[]}
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ColumnType"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"names":["ColumnType"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;AAuBA,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;;AAsDtB;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -24,8 +24,6 @@ export declare const NitroSQLite: {
|
|
|
24
24
|
}>): boolean;
|
|
25
25
|
dispose(): void;
|
|
26
26
|
};
|
|
27
|
-
/** NOOP on NitroSQLite versions >= 9.3.0 */
|
|
28
|
-
export declare function enableSimpleNullHandling(): void;
|
|
29
27
|
export { open } from './operations/session';
|
|
30
28
|
export { default as NitroSQLiteError } from './NitroSQLiteError';
|
|
31
29
|
export type * from './types';
|
|
@@ -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;AAE5D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAI3E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;CAYvB,CAAA;AAED,
|
|
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;AAI3E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;CAYvB,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAChE,mBAAmB,SAAS,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -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":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAI9E,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,CAOlB;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,CAW3B"}
|
|
@@ -18,22 +18,9 @@ export interface NitroSQLiteQueryResult extends HybridObject<{
|
|
|
18
18
|
readonly insertId?: number;
|
|
19
19
|
/** Query results */
|
|
20
20
|
readonly results: Record<string, SQLiteValue>[];
|
|
21
|
-
/** Query results in a row format for TypeORM compatibility */
|
|
22
|
-
readonly rows?: NitroSQLiteQueryResultRows;
|
|
23
21
|
/** Table metadata */
|
|
24
22
|
readonly metadata?: Record<string, NitroSQLiteQueryColumnMetadata>;
|
|
25
23
|
}
|
|
26
|
-
export type NitroSQLiteQueryResultRows<Row extends Record<string, SQLiteValue> = Record<string, SQLiteValue>> = {
|
|
27
|
-
/** Raw array with all dataset */
|
|
28
|
-
_array: Row[];
|
|
29
|
-
/** The lengh of the dataset */
|
|
30
|
-
length: number;
|
|
31
|
-
/** A convenience function to acess the index based the row object
|
|
32
|
-
* @param idx the row index
|
|
33
|
-
* @returns the row structure identified by column names
|
|
34
|
-
*/
|
|
35
|
-
item: (idx: number) => Row | undefined;
|
|
36
|
-
};
|
|
37
24
|
export type NitroSQLiteQueryColumnMetadata = {
|
|
38
25
|
/** The name used for this column for this result set */
|
|
39
26
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroSQLiteQueryResult.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLiteQueryResult.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEvD;;;;;;;;;GASG;AACH,MAAM,WAAW,sBACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAE1B,oBAAoB;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAA;IAE/C,
|
|
1
|
+
{"version":3,"file":"NitroSQLiteQueryResult.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLiteQueryResult.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEvD;;;;;;;;;GASG;AACH,MAAM,WAAW,sBACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAE1B,oBAAoB;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAA;IAE/C,qBAAqB;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAA;CACnE;AASD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAA;IAEZ,uLAAuL;IACvL,IAAI,EAAE,UAAU,CAAA;IAEhB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAA;CACd,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NitroSQLiteQueryResult } from './specs/NitroSQLiteQueryResult.nitro';
|
|
2
2
|
export interface NitroSQLiteConnectionOptions {
|
|
3
3
|
name: string;
|
|
4
4
|
location?: string;
|
|
@@ -28,14 +28,19 @@ export type SQLiteValue = boolean | number | string | ArrayBuffer | null;
|
|
|
28
28
|
export type SQLiteQueryParams = SQLiteValue[];
|
|
29
29
|
export type QueryResultRow = Record<string, SQLiteValue>;
|
|
30
30
|
export type QueryResult<Row extends QueryResultRow = QueryResultRow> = NitroSQLiteQueryResult & {
|
|
31
|
-
readonly rowsAffected: number;
|
|
32
|
-
readonly insertId?: number;
|
|
33
|
-
/** Query results */
|
|
34
|
-
readonly results: Row[];
|
|
35
31
|
/** Query results in a row format for TypeORM compatibility */
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
rows: NitroSQLiteQueryResultRows<Row>;
|
|
33
|
+
};
|
|
34
|
+
export type NitroSQLiteQueryResultRows<Row extends Record<string, SQLiteValue> = Record<string, SQLiteValue>> = {
|
|
35
|
+
/** Raw array with all dataset */
|
|
36
|
+
_array: Row[];
|
|
37
|
+
/** The lengh of the dataset */
|
|
38
|
+
length: number;
|
|
39
|
+
/** A convenience function to acess the index based the row object
|
|
40
|
+
* @param idx the row index
|
|
41
|
+
* @returns the row structure identified by column names
|
|
42
|
+
*/
|
|
43
|
+
item: (idx: number) => Row | undefined;
|
|
39
44
|
};
|
|
40
45
|
export type ExecuteQuery = <Row extends QueryResultRow = QueryResultRow>(query: string, params?: SQLiteValue[]) => QueryResult<Row>;
|
|
41
46
|
export type ExecuteAsyncQuery = <Row extends QueryResultRow = QueryResultRow>(query: string, params?: SQLiteQueryParams) => Promise<QueryResult<Row>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -24,8 +24,6 @@ export declare const NitroSQLite: {
|
|
|
24
24
|
}>): boolean;
|
|
25
25
|
dispose(): void;
|
|
26
26
|
};
|
|
27
|
-
/** NOOP on NitroSQLite versions >= 9.3.0 */
|
|
28
|
-
export declare function enableSimpleNullHandling(): void;
|
|
29
27
|
export { open } from './operations/session';
|
|
30
28
|
export { default as NitroSQLiteError } from './NitroSQLiteError';
|
|
31
29
|
export type * from './types';
|
|
@@ -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;AAE5D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAI3E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;CAYvB,CAAA;AAED,
|
|
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;AAI3E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;CAYvB,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAChE,mBAAmB,SAAS,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -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":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAI9E,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,CAOlB;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,CAW3B"}
|
|
@@ -18,22 +18,9 @@ export interface NitroSQLiteQueryResult extends HybridObject<{
|
|
|
18
18
|
readonly insertId?: number;
|
|
19
19
|
/** Query results */
|
|
20
20
|
readonly results: Record<string, SQLiteValue>[];
|
|
21
|
-
/** Query results in a row format for TypeORM compatibility */
|
|
22
|
-
readonly rows?: NitroSQLiteQueryResultRows;
|
|
23
21
|
/** Table metadata */
|
|
24
22
|
readonly metadata?: Record<string, NitroSQLiteQueryColumnMetadata>;
|
|
25
23
|
}
|
|
26
|
-
export type NitroSQLiteQueryResultRows<Row extends Record<string, SQLiteValue> = Record<string, SQLiteValue>> = {
|
|
27
|
-
/** Raw array with all dataset */
|
|
28
|
-
_array: Row[];
|
|
29
|
-
/** The lengh of the dataset */
|
|
30
|
-
length: number;
|
|
31
|
-
/** A convenience function to acess the index based the row object
|
|
32
|
-
* @param idx the row index
|
|
33
|
-
* @returns the row structure identified by column names
|
|
34
|
-
*/
|
|
35
|
-
item: (idx: number) => Row | undefined;
|
|
36
|
-
};
|
|
37
24
|
export type NitroSQLiteQueryColumnMetadata = {
|
|
38
25
|
/** The name used for this column for this result set */
|
|
39
26
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroSQLiteQueryResult.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLiteQueryResult.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEvD;;;;;;;;;GASG;AACH,MAAM,WAAW,sBACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAE1B,oBAAoB;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAA;IAE/C,
|
|
1
|
+
{"version":3,"file":"NitroSQLiteQueryResult.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLiteQueryResult.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEvD;;;;;;;;;GASG;AACH,MAAM,WAAW,sBACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAE1B,oBAAoB;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAA;IAE/C,qBAAqB;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAA;CACnE;AASD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAA;IAEZ,uLAAuL;IACvL,IAAI,EAAE,UAAU,CAAA;IAEhB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAA;CACd,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NitroSQLiteQueryResult } from './specs/NitroSQLiteQueryResult.nitro';
|
|
2
2
|
export interface NitroSQLiteConnectionOptions {
|
|
3
3
|
name: string;
|
|
4
4
|
location?: string;
|
|
@@ -28,14 +28,19 @@ export type SQLiteValue = boolean | number | string | ArrayBuffer | null;
|
|
|
28
28
|
export type SQLiteQueryParams = SQLiteValue[];
|
|
29
29
|
export type QueryResultRow = Record<string, SQLiteValue>;
|
|
30
30
|
export type QueryResult<Row extends QueryResultRow = QueryResultRow> = NitroSQLiteQueryResult & {
|
|
31
|
-
readonly rowsAffected: number;
|
|
32
|
-
readonly insertId?: number;
|
|
33
|
-
/** Query results */
|
|
34
|
-
readonly results: Row[];
|
|
35
31
|
/** Query results in a row format for TypeORM compatibility */
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
rows: NitroSQLiteQueryResultRows<Row>;
|
|
33
|
+
};
|
|
34
|
+
export type NitroSQLiteQueryResultRows<Row extends Record<string, SQLiteValue> = Record<string, SQLiteValue>> = {
|
|
35
|
+
/** Raw array with all dataset */
|
|
36
|
+
_array: Row[];
|
|
37
|
+
/** The lengh of the dataset */
|
|
38
|
+
length: number;
|
|
39
|
+
/** A convenience function to acess the index based the row object
|
|
40
|
+
* @param idx the row index
|
|
41
|
+
* @returns the row structure identified by column names
|
|
42
|
+
*/
|
|
43
|
+
item: (idx: number) => Row | undefined;
|
|
39
44
|
};
|
|
40
45
|
export type ExecuteQuery = <Row extends QueryResultRow = QueryResultRow>(query: string, params?: SQLiteValue[]) => QueryResult<Row>;
|
|
41
46
|
export type ExecuteAsyncQuery = <Row extends QueryResultRow = QueryResultRow>(query: string, params?: SQLiteQueryParams) => Promise<QueryResult<Row>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -17,7 +17,6 @@ namespace margelo::nitro::rnnitrosqlite {
|
|
|
17
17
|
prototype.registerHybridGetter("rowsAffected", &HybridNitroSQLiteQueryResultSpec::getRowsAffected);
|
|
18
18
|
prototype.registerHybridGetter("insertId", &HybridNitroSQLiteQueryResultSpec::getInsertId);
|
|
19
19
|
prototype.registerHybridGetter("results", &HybridNitroSQLiteQueryResultSpec::getResults);
|
|
20
|
-
prototype.registerHybridGetter("rows", &HybridNitroSQLiteQueryResultSpec::getRows);
|
|
21
20
|
prototype.registerHybridGetter("metadata", &HybridNitroSQLiteQueryResultSpec::getMetadata);
|
|
22
21
|
});
|
|
23
22
|
}
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
14
|
#endif
|
|
15
15
|
|
|
16
|
-
// Forward declaration of `NitroSQLiteQueryResultRows` to properly resolve imports.
|
|
17
|
-
namespace margelo::nitro::rnnitrosqlite { struct NitroSQLiteQueryResultRows; }
|
|
18
16
|
// Forward declaration of `NitroSQLiteQueryColumnMetadata` to properly resolve imports.
|
|
19
17
|
namespace margelo::nitro::rnnitrosqlite { struct NitroSQLiteQueryColumnMetadata; }
|
|
20
18
|
|
|
@@ -25,7 +23,6 @@ namespace margelo::nitro::rnnitrosqlite { struct NitroSQLiteQueryColumnMetadata;
|
|
|
25
23
|
#include <variant>
|
|
26
24
|
#include <unordered_map>
|
|
27
25
|
#include <vector>
|
|
28
|
-
#include "NitroSQLiteQueryResultRows.hpp"
|
|
29
26
|
#include "NitroSQLiteQueryColumnMetadata.hpp"
|
|
30
27
|
|
|
31
28
|
namespace margelo::nitro::rnnitrosqlite {
|
|
@@ -58,7 +55,6 @@ namespace margelo::nitro::rnnitrosqlite {
|
|
|
58
55
|
virtual double getRowsAffected() = 0;
|
|
59
56
|
virtual std::optional<double> getInsertId() = 0;
|
|
60
57
|
virtual std::vector<std::unordered_map<std::string, std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>>> getResults() = 0;
|
|
61
|
-
virtual std::optional<NitroSQLiteQueryResultRows> getRows() = 0;
|
|
62
58
|
virtual std::optional<std::unordered_map<std::string, NitroSQLiteQueryColumnMetadata>> getMetadata() = 0;
|
|
63
59
|
|
|
64
60
|
public:
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -21,9 +21,6 @@ export const NitroSQLite = {
|
|
|
21
21
|
executeBatchAsync,
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
/** NOOP on NitroSQLite versions >= 9.3.0 */
|
|
25
|
-
export function enableSimpleNullHandling() {}
|
|
26
|
-
|
|
27
24
|
export { open } from './operations/session'
|
|
28
25
|
export { default as NitroSQLiteError } from './NitroSQLiteError'
|
|
29
26
|
export type * from './types'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HybridNitroSQLite } from '../nitro'
|
|
2
|
-
import type { NitroSQLiteQueryResult } from '../specs/NitroSQLiteQueryResult.nitro'
|
|
3
2
|
import type { QueryResult, QueryResultRow, SQLiteQueryParams } from '../types'
|
|
4
3
|
import NitroSQLiteError from '../NitroSQLiteError'
|
|
4
|
+
import type { NitroSQLiteQueryResult } from '../specs/NitroSQLiteQueryResult.nitro'
|
|
5
5
|
|
|
6
6
|
export function execute<Row extends QueryResultRow = never>(
|
|
7
7
|
dbName: string,
|
|
@@ -9,8 +9,8 @@ export function execute<Row extends QueryResultRow = never>(
|
|
|
9
9
|
params?: SQLiteQueryParams,
|
|
10
10
|
): QueryResult<Row> {
|
|
11
11
|
try {
|
|
12
|
-
const
|
|
13
|
-
return
|
|
12
|
+
const nativeResult = HybridNitroSQLite.execute(dbName, query, params)
|
|
13
|
+
return buildJSQueryResult<Row>(nativeResult)
|
|
14
14
|
} catch (error) {
|
|
15
15
|
throw NitroSQLiteError.fromError(error)
|
|
16
16
|
}
|
|
@@ -22,26 +22,35 @@ export async function executeAsync<Row extends QueryResultRow = never>(
|
|
|
22
22
|
params?: SQLiteQueryParams,
|
|
23
23
|
): Promise<QueryResult<Row>> {
|
|
24
24
|
try {
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
const nativeResult = await HybridNitroSQLite.executeAsync(
|
|
26
|
+
dbName,
|
|
27
|
+
query,
|
|
28
|
+
params,
|
|
29
|
+
)
|
|
30
|
+
return buildJSQueryResult<Row>(nativeResult)
|
|
27
31
|
} catch (error) {
|
|
28
32
|
throw NitroSQLiteError.fromError(error)
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
function
|
|
36
|
+
function buildJSQueryResult<Row extends QueryResultRow = never>(
|
|
33
37
|
result: NitroSQLiteQueryResult,
|
|
34
38
|
): QueryResult<Row> {
|
|
35
|
-
const
|
|
39
|
+
const resultWithRows = result as QueryResult<Row>
|
|
40
|
+
|
|
41
|
+
resultWithRows.rows = {
|
|
42
|
+
_array: result.results as Row[],
|
|
43
|
+
length: result.results.length,
|
|
44
|
+
item: (idx: number) => result.results[idx] as Row | undefined,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return resultWithRows
|
|
36
48
|
|
|
37
|
-
return {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
item: (idx: number) => data[idx],
|
|
45
|
-
},
|
|
46
|
-
} as QueryResult<Row>
|
|
49
|
+
// return Object.assign(result, {
|
|
50
|
+
// rows: {
|
|
51
|
+
// _array: result.results,
|
|
52
|
+
// length: result.results.length,
|
|
53
|
+
// item: (idx: number) => result.results[idx],
|
|
54
|
+
// },
|
|
55
|
+
// })
|
|
47
56
|
}
|
|
@@ -19,9 +19,6 @@ export interface NitroSQLiteQueryResult
|
|
|
19
19
|
/** Query results */
|
|
20
20
|
readonly results: Record<string, SQLiteValue>[]
|
|
21
21
|
|
|
22
|
-
/** Query results in a row format for TypeORM compatibility */
|
|
23
|
-
readonly rows?: NitroSQLiteQueryResultRows
|
|
24
|
-
|
|
25
22
|
/** Table metadata */
|
|
26
23
|
readonly metadata?: Record<string, NitroSQLiteQueryColumnMetadata>
|
|
27
24
|
}
|
|
@@ -33,20 +30,6 @@ export interface NitroSQLiteQueryResult
|
|
|
33
30
|
|
|
34
31
|
// type NitroQueryResultRow = Record<string, SQLiteValue>
|
|
35
32
|
|
|
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
33
|
export type NitroSQLiteQueryColumnMetadata = {
|
|
51
34
|
/** The name used for this column for this result set */
|
|
52
35
|
name: string
|
package/src/types.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
NitroSQLiteQueryColumnMetadata,
|
|
3
|
-
NitroSQLiteQueryResult,
|
|
4
|
-
NitroSQLiteQueryResultRows,
|
|
5
|
-
} from './specs/NitroSQLiteQueryResult.nitro'
|
|
1
|
+
import type { NitroSQLiteQueryResult } from './specs/NitroSQLiteQueryResult.nitro'
|
|
6
2
|
|
|
7
3
|
export interface NitroSQLiteConnectionOptions {
|
|
8
4
|
name: string
|
|
@@ -42,18 +38,25 @@ export type QueryResultRow = Record<string, SQLiteValue>
|
|
|
42
38
|
|
|
43
39
|
export type QueryResult<Row extends QueryResultRow = QueryResultRow> =
|
|
44
40
|
NitroSQLiteQueryResult & {
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
/** Query results in a row format for TypeORM compatibility */
|
|
42
|
+
rows: NitroSQLiteQueryResultRows<Row>
|
|
43
|
+
}
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
export type NitroSQLiteQueryResultRows<
|
|
46
|
+
Row extends Record<string, SQLiteValue> = Record<string, SQLiteValue>,
|
|
47
|
+
> = {
|
|
48
|
+
/** Raw array with all dataset */
|
|
49
|
+
_array: Row[]
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
/** The lengh of the dataset */
|
|
52
|
+
length: number
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
/** A convenience function to acess the index based the row object
|
|
55
|
+
* @param idx the row index
|
|
56
|
+
* @returns the row structure identified by column names
|
|
57
|
+
*/
|
|
58
|
+
item: (idx: number) => Row | undefined
|
|
59
|
+
}
|
|
57
60
|
|
|
58
61
|
export type ExecuteQuery = <Row extends QueryResultRow = QueryResultRow>(
|
|
59
62
|
query: string,
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
#include "HybridNitroSQLiteQueryResult.hpp"
|
|
2
|
-
#include <NitroModules/ArrayBuffer.hpp>
|
|
3
|
-
#include <NitroModules/Null.hpp>
|
|
4
|
-
#include <NitroModules/Promise.hpp>
|
|
5
|
-
#include <unordered_map>
|
|
6
|
-
#include <variant>
|
|
7
|
-
#include <vector>
|
|
8
|
-
|
|
9
|
-
namespace margelo::nitro::rnnitrosqlite {
|
|
10
|
-
|
|
11
|
-
std::optional<double> HybridNitroSQLiteQueryResult::getInsertId() {
|
|
12
|
-
return _result.insertId;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
double HybridNitroSQLiteQueryResult::getRowsAffected() {
|
|
16
|
-
return _result.rowsAffected;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
SQLiteQueryResults HybridNitroSQLiteQueryResult::getResults() {
|
|
20
|
-
return _result.results;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
std::optional<NitroSQLiteQueryResultRows> HybridNitroSQLiteQueryResult::getRows() {
|
|
24
|
-
if (_result.results.empty()) {
|
|
25
|
-
return std::nullopt;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
auto rows = _result.results;
|
|
29
|
-
|
|
30
|
-
// Create the item function that returns a Promise
|
|
31
|
-
auto itemFunction = [rows](double idx) -> std::shared_ptr<Promise<std::optional<SQLiteQueryResultRow>>> {
|
|
32
|
-
return Promise<std::optional<SQLiteQueryResultRow>>::async([rows, idx]() -> std::optional<SQLiteQueryResultRow> {
|
|
33
|
-
const auto index = static_cast<size_t>(idx);
|
|
34
|
-
if (index >= rows.size()) {
|
|
35
|
-
return std::nullopt;
|
|
36
|
-
}
|
|
37
|
-
return rows[index];
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const auto length = static_cast<double>(rows.size());
|
|
42
|
-
return NitroSQLiteQueryResultRows(std::move(rows), length, itemFunction);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
std::optional<SQLiteQueryTableMetadata> HybridNitroSQLiteQueryResult::getMetadata() {
|
|
46
|
-
return _result.metadata;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
} // namespace margelo::nitro::rnnitrosqlite
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "HybridNitroSQLiteQueryResultSpec.hpp"
|
|
4
|
-
#include "types.hpp"
|
|
5
|
-
#include <map>
|
|
6
|
-
|
|
7
|
-
using namespace margelo::rnnitrosqlite;
|
|
8
|
-
|
|
9
|
-
namespace margelo::nitro::rnnitrosqlite {
|
|
10
|
-
|
|
11
|
-
class HybridNitroSQLiteQueryResult : public HybridNitroSQLiteQueryResultSpec {
|
|
12
|
-
public:
|
|
13
|
-
HybridNitroSQLiteQueryResult() : HybridObject(TAG) {}
|
|
14
|
-
HybridNitroSQLiteQueryResult(SQLiteExecuteQueryResult&& result) : HybridObject(TAG), _result(std::move(result)) {}
|
|
15
|
-
|
|
16
|
-
private:
|
|
17
|
-
SQLiteExecuteQueryResult _result;
|
|
18
|
-
|
|
19
|
-
public:
|
|
20
|
-
// Properties
|
|
21
|
-
std::optional<double> getInsertId() override;
|
|
22
|
-
double getRowsAffected() override;
|
|
23
|
-
SQLiteQueryResults getResults() override;
|
|
24
|
-
std::optional<NitroSQLiteQueryResultRows> getRows() override;
|
|
25
|
-
std::optional<SQLiteQueryTableMetadata> getMetadata() override;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
} // namespace margelo::nitro::rnnitrosqlite
|
|
@@ -1,99 +0,0 @@
|
|
|
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
|
|
File without changes
|