react-native-nitro-sqlite 9.8.2 → 10.0.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/RNNitroSQLite.podspec +7 -3
- package/android/CMakeLists.txt +2 -2
- package/cpp/NitroSQLiteDatabaseConnections.cpp +306 -0
- package/cpp/NitroSQLiteDatabaseConnections.hpp +86 -0
- package/cpp/{databaseMigration.cpp → NitroSQLiteDatabaseMigration.cpp} +2 -2
- package/cpp/{sqliteExecuteBatch.cpp → NitroSQLiteExecuteBatch.cpp} +4 -4
- package/cpp/{sqliteExecuteBatch.hpp → NitroSQLiteExecuteBatch.hpp} +3 -6
- package/cpp/{importSqlFile.cpp → NitroSQLiteImportSqlFile.cpp} +4 -4
- package/cpp/{importSqlFile.hpp → NitroSQLiteImportSqlFile.hpp} +3 -3
- package/cpp/{macros.hpp → NitroSQLiteMacros.hpp} +3 -3
- package/cpp/NitroSQLiteOperations.cpp +396 -0
- package/cpp/NitroSQLiteOperations.hpp +72 -0
- package/cpp/{types.hpp → NitroSQLiteTypes.hpp} +3 -6
- package/cpp/{utils.hpp → NitroSQLiteUtils.hpp} +2 -2
- package/cpp/hybridObjects/HybridNitroSQLite.cpp +108 -22
- package/cpp/hybridObjects/HybridNitroSQLite.hpp +49 -5
- package/cpp/hybridObjects/HybridNitroSQLitePreparedStatement.cpp +59 -0
- package/cpp/hybridObjects/HybridNitroSQLitePreparedStatement.hpp +33 -0
- package/cpp/hybridObjects/HybridNitroSQLiteQueryResult.hpp +6 -4
- package/ios/OnLoad.mm +38 -2
- package/lib/commonjs/DatabaseQueue.js +52 -16
- package/lib/commonjs/DatabaseQueue.js.map +1 -1
- package/lib/commonjs/NitroSQLiteError.js +6 -7
- package/lib/commonjs/NitroSQLiteError.js.map +1 -1
- package/lib/commonjs/OnLoad.js +1 -1
- package/lib/commonjs/index.js +8 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/operations/execute.js +19 -4
- package/lib/commonjs/operations/execute.js.map +1 -1
- package/lib/commonjs/operations/executeBatch.js +19 -6
- package/lib/commonjs/operations/executeBatch.js.map +1 -1
- package/lib/commonjs/operations/prepare.js +54 -0
- package/lib/commonjs/operations/prepare.js.map +1 -0
- package/lib/commonjs/operations/session.js +106 -30
- package/lib/commonjs/operations/session.js.map +1 -1
- package/lib/commonjs/operations/transaction.js +30 -5
- package/lib/commonjs/operations/transaction.js.map +1 -1
- package/lib/commonjs/specs/NitroSQLitePreparedStatement.nitro.js +6 -0
- package/lib/commonjs/specs/NitroSQLitePreparedStatement.nitro.js.map +1 -0
- package/lib/commonjs/typeORM.js +10 -3
- package/lib/commonjs/typeORM.js.map +1 -1
- package/lib/commonjs/types.js +35 -9
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/DatabaseQueue.js +52 -16
- package/lib/module/DatabaseQueue.js.map +1 -1
- package/lib/module/NitroSQLiteError.js +6 -7
- package/lib/module/NitroSQLiteError.js.map +1 -1
- package/lib/module/OnLoad.js +1 -1
- package/lib/module/index.js +8 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/operations/execute.js +20 -5
- package/lib/module/operations/execute.js.map +1 -1
- package/lib/module/operations/executeBatch.js +20 -7
- package/lib/module/operations/executeBatch.js.map +1 -1
- package/lib/module/operations/prepare.js +49 -0
- package/lib/module/operations/prepare.js.map +1 -0
- package/lib/module/operations/session.js +107 -31
- package/lib/module/operations/session.js.map +1 -1
- package/lib/module/operations/transaction.js +30 -5
- package/lib/module/operations/transaction.js.map +1 -1
- package/lib/module/specs/NitroSQLitePreparedStatement.nitro.js +4 -0
- package/lib/module/specs/NitroSQLitePreparedStatement.nitro.js.map +1 -0
- package/lib/module/typeORM.js +11 -3
- package/lib/module/typeORM.js.map +1 -1
- package/lib/module/types.js +48 -9
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/DatabaseQueue.d.ts +15 -7
- package/lib/typescript/commonjs/DatabaseQueue.d.ts.map +1 -1
- package/lib/typescript/commonjs/NitroSQLiteError.d.ts +6 -7
- package/lib/typescript/commonjs/NitroSQLiteError.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +9 -2
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/operations/execute.d.ts +17 -2
- package/lib/typescript/commonjs/operations/execute.d.ts.map +1 -1
- package/lib/typescript/commonjs/operations/executeBatch.d.ts +15 -2
- package/lib/typescript/commonjs/operations/executeBatch.d.ts.map +1 -1
- package/lib/typescript/commonjs/operations/prepare.d.ts +13 -0
- package/lib/typescript/commonjs/operations/prepare.d.ts.map +1 -0
- package/lib/typescript/commonjs/operations/session.d.ts +8 -0
- package/lib/typescript/commonjs/operations/session.d.ts.map +1 -1
- package/lib/typescript/commonjs/operations/transaction.d.ts +11 -1
- package/lib/typescript/commonjs/operations/transaction.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/NitroSQLite.nitro.d.ts +83 -2
- package/lib/typescript/commonjs/specs/NitroSQLite.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/NitroSQLitePreparedStatement.nitro.d.ts +26 -0
- package/lib/typescript/commonjs/specs/NitroSQLitePreparedStatement.nitro.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/NitroSQLiteQueryResult.nitro.d.ts +9 -15
- package/lib/typescript/commonjs/specs/NitroSQLiteQueryResult.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/typeORM.d.ts +14 -3
- package/lib/typescript/commonjs/typeORM.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +124 -21
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/module/DatabaseQueue.d.ts +15 -7
- package/lib/typescript/module/DatabaseQueue.d.ts.map +1 -1
- package/lib/typescript/module/NitroSQLiteError.d.ts +6 -7
- package/lib/typescript/module/NitroSQLiteError.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +9 -2
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/operations/execute.d.ts +17 -2
- package/lib/typescript/module/operations/execute.d.ts.map +1 -1
- package/lib/typescript/module/operations/executeBatch.d.ts +15 -2
- package/lib/typescript/module/operations/executeBatch.d.ts.map +1 -1
- package/lib/typescript/module/operations/prepare.d.ts +13 -0
- package/lib/typescript/module/operations/prepare.d.ts.map +1 -0
- package/lib/typescript/module/operations/session.d.ts +8 -0
- package/lib/typescript/module/operations/session.d.ts.map +1 -1
- package/lib/typescript/module/operations/transaction.d.ts +11 -1
- package/lib/typescript/module/operations/transaction.d.ts.map +1 -1
- package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts +83 -2
- package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts.map +1 -1
- package/lib/typescript/module/specs/NitroSQLitePreparedStatement.nitro.d.ts +26 -0
- package/lib/typescript/module/specs/NitroSQLitePreparedStatement.nitro.d.ts.map +1 -0
- package/lib/typescript/module/specs/NitroSQLiteQueryResult.nitro.d.ts +9 -15
- package/lib/typescript/module/specs/NitroSQLiteQueryResult.nitro.d.ts.map +1 -1
- package/lib/typescript/module/typeORM.d.ts +14 -3
- package/lib/typescript/module/typeORM.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +124 -21
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/nitrogen/generated/android/RNNitroSQLite+autolinking.cmake +1 -0
- package/nitrogen/generated/shared/c++/HybridNitroSQLitePreparedStatementSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridNitroSQLitePreparedStatementSpec.hpp +73 -0
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.cpp +3 -0
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.hpp +8 -2
- package/package.json +4 -2
- package/src/DatabaseQueue.ts +81 -25
- package/src/NitroSQLiteError.ts +6 -7
- package/src/OnLoad.ts +1 -1
- package/src/index.ts +7 -3
- package/src/operations/execute.ts +22 -3
- package/src/operations/executeBatch.ts +20 -5
- package/src/operations/prepare.ts +69 -0
- package/src/operations/session.ts +136 -45
- package/src/operations/transaction.ts +37 -4
- package/src/specs/NitroSQLite.nitro.ts +84 -2
- package/src/specs/NitroSQLitePreparedStatement.nitro.ts +28 -0
- package/src/specs/NitroSQLiteQueryResult.nitro.ts +9 -15
- package/src/typeORM.ts +14 -3
- package/src/types.ts +135 -21
- package/cpp/operations.cpp +0 -358
- package/cpp/operations.hpp +0 -56
- /package/android/{cpp-adapter.cpp → RNNitroSQLiteAdapter.cpp} +0 -0
- /package/cpp/{databaseMigration.hpp → NitroSQLiteDatabaseMigration.hpp} +0 -0
- /package/cpp/{logs.hpp → NitroSQLiteLogs.hpp} +0 -0
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { NitroSQLiteConnection, NitroSQLiteConnectionOptions } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Open a database and return a managed connection. The default connection is
|
|
4
|
+
* addressed by its name, and opening it twice throws. Set `connection` to
|
|
5
|
+
* `'independent'` to open another native handle to the same file. Async calls
|
|
6
|
+
* on each connection run in call order.
|
|
7
|
+
* @param options Database name, optional directory, connection mode, and read-only setting.
|
|
8
|
+
* @returns A connection bound to the opened native handle.
|
|
9
|
+
*/
|
|
2
10
|
export declare function open(options: NitroSQLiteConnectionOptions): NitroSQLiteConnection;
|
|
3
11
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/operations/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,qBAAqB,EACrB,4BAA4B,EAK7B,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/operations/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,qBAAqB,EACrB,4BAA4B,EAK7B,MAAM,UAAU,CAAA;AAejB;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAClB,OAAO,EAAE,4BAA4B,GACpC,qBAAqB,CAgIvB"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import type { Transaction } from '../types';
|
|
2
|
-
|
|
2
|
+
import type { DatabaseQueueKey } from '../DatabaseQueue';
|
|
3
|
+
/** Queue a transaction for an open managed connection.
|
|
4
|
+
* Use only the supplied `tx` for work on this database inside the callback.
|
|
5
|
+
* A successful callback commits unless it explicitly committed or rolled back;
|
|
6
|
+
* a thrown error rolls back unless the transaction was already finalized.
|
|
7
|
+
* @param dbName Name of the open database.
|
|
8
|
+
* @param transactionCallback Async callback receiving the transaction handle.
|
|
9
|
+
* @param isExclusive Begin an exclusive transaction when true.
|
|
10
|
+
* @returns The callback's result after the transaction finishes.
|
|
11
|
+
*/
|
|
12
|
+
export declare const transaction: <Result = void>(dbName: string, transactionCallback: (tx: Transaction) => Promise<Result>, isExclusive?: boolean, queueKey?: DatabaseQueueKey) => Promise<Result>;
|
|
3
13
|
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../../src/operations/transaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EAIZ,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../../src/operations/transaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EAIZ,MAAM,UAAU,CAAA;AAGjB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExD;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAU,MAAM,GAAG,IAAI,EAC7C,QAAQ,MAAM,EACd,qBAAqB,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,EACzD,qBAAmB,EACnB,WAAU,gBAAyB,oBAqGpC,CAAA"}
|
|
@@ -1,20 +1,101 @@
|
|
|
1
1
|
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
2
|
import type { BatchQueryCommand, BatchQueryResult, FileLoadResult, SQLiteQueryParams } from '../types';
|
|
3
3
|
import type { NitroSQLiteQueryResult } from './NitroSQLiteQueryResult.nitro';
|
|
4
|
+
import type { NitroSQLitePreparedStatement } from './NitroSQLitePreparedStatement.nitro';
|
|
5
|
+
/** Native database operations exposed through `NitroSQLite.native`.
|
|
6
|
+
* These calls bypass the managed connection queue. Coordinate them with any
|
|
7
|
+
* transaction or pending operation on the same database yourself.
|
|
8
|
+
*/
|
|
4
9
|
export interface NitroSQLite extends HybridObject<{
|
|
5
10
|
ios: 'c++';
|
|
6
11
|
android: 'c++';
|
|
7
12
|
}> {
|
|
8
|
-
|
|
13
|
+
/** Open a name-based default connection, creating the database unless `readOnly` is true.
|
|
14
|
+
* @param dbName Database file name and default connection key.
|
|
15
|
+
* @param location Directory relative to the platform database directory.
|
|
16
|
+
* @param readOnly Open an existing database without write access.
|
|
17
|
+
*/
|
|
18
|
+
open(dbName: string, location?: string, readOnly?: boolean): void;
|
|
19
|
+
/** Open a separate native handle, even when the database file is already open.
|
|
20
|
+
* Independent connections require a thread-safe SQLite build.
|
|
21
|
+
* @param dbName Database file name.
|
|
22
|
+
* @param location Directory relative to the platform database directory.
|
|
23
|
+
* @param readOnly Open an existing database without write access.
|
|
24
|
+
* @returns An opaque ID to pass to native connection operations.
|
|
25
|
+
*/
|
|
26
|
+
openConnection(dbName: string, location?: string, readOnly?: boolean): string;
|
|
27
|
+
/** Check whether a native connection ID is still open.
|
|
28
|
+
* @param connectionId ID returned by `openConnection`.
|
|
29
|
+
*/
|
|
30
|
+
isConnectionOpen(connectionId: string): boolean;
|
|
31
|
+
/** Close a default connection by name or an independent connection by ID. */
|
|
9
32
|
close(dbName: string): void;
|
|
10
|
-
|
|
33
|
+
/** Delete a database and close the indicated connection if open.
|
|
34
|
+
* Deletion fails while another connection or attachment uses the database file.
|
|
35
|
+
* @param dbName Database file name.
|
|
36
|
+
* @param location Directory relative to the platform database directory.
|
|
37
|
+
* @param connectionId Optional ID of the independent connection to close.
|
|
38
|
+
*/
|
|
39
|
+
drop(dbName: string, location?: string, connectionId?: string): void;
|
|
40
|
+
/** Attach a database file to an open main database under an SQL schema alias.
|
|
41
|
+
* @param mainDbName Name of the open main database.
|
|
42
|
+
* @param dbNameToAttach File name of the database to attach.
|
|
43
|
+
* @param alias SQL schema name for the attached database.
|
|
44
|
+
* @param location Directory relative to the platform database directory.
|
|
45
|
+
*/
|
|
11
46
|
attach(mainDbName: string, dbNameToAttach: string, alias: string, location?: string): void;
|
|
47
|
+
/** Detach an attached database by its alias.
|
|
48
|
+
* @param mainDbName Name of the open main database.
|
|
49
|
+
* @param alias SQL schema name used when attaching.
|
|
50
|
+
*/
|
|
12
51
|
detach(mainDbName: string, alias: string): void;
|
|
52
|
+
/** Execute one SQL statement synchronously on the calling thread.
|
|
53
|
+
* @param dbName Name of an open database.
|
|
54
|
+
* @param query SQL statement with optional positional placeholders.
|
|
55
|
+
* @param params Positional values bound to SQL placeholders.
|
|
56
|
+
* @returns Native query rows, affected row count, insert ID, and metadata.
|
|
57
|
+
*/
|
|
13
58
|
execute(dbName: string, query: string, params?: SQLiteQueryParams): NitroSQLiteQueryResult;
|
|
59
|
+
/** Execute one SQL statement on a background thread.
|
|
60
|
+
* @param dbName Name of an open database.
|
|
61
|
+
* @param query SQL statement with optional positional placeholders.
|
|
62
|
+
* @param params Positional values bound to SQL placeholders.
|
|
63
|
+
* @returns A promise of the native query result.
|
|
64
|
+
*/
|
|
14
65
|
executeAsync(dbName: string, query: string, params?: SQLiteQueryParams): Promise<NitroSQLiteQueryResult>;
|
|
66
|
+
/** Prepare one SQL statement on an open native connection for repeated execution.
|
|
67
|
+
* Finalize the returned statement before closing its connection.
|
|
68
|
+
* @param dbName Name or ID of an open database connection.
|
|
69
|
+
* @param query SQL statement with optional positional placeholders.
|
|
70
|
+
* @returns A native statement with synchronous and asynchronous execution methods.
|
|
71
|
+
*/
|
|
72
|
+
prepare(dbName: string, query: string): NitroSQLitePreparedStatement;
|
|
73
|
+
/** Execute commands in one exclusive transaction on the calling thread.
|
|
74
|
+
* An empty batch throws; a failed command rolls back the batch.
|
|
75
|
+
* @param dbName Name of an open database.
|
|
76
|
+
* @param commands SQL commands and optional parameter sets.
|
|
77
|
+
* @returns Total affected row count.
|
|
78
|
+
*/
|
|
15
79
|
executeBatch(dbName: string, commands: BatchQueryCommand[]): BatchQueryResult;
|
|
80
|
+
/** Execute commands in one exclusive transaction on a background thread.
|
|
81
|
+
* An empty batch rejects; a failed command rolls back the batch.
|
|
82
|
+
* @param dbName Name of an open database.
|
|
83
|
+
* @param commands SQL commands and optional parameter sets.
|
|
84
|
+
* @returns A promise of the total affected row count.
|
|
85
|
+
*/
|
|
16
86
|
executeBatchAsync(dbName: string, commands: BatchQueryCommand[]): Promise<BatchQueryResult>;
|
|
87
|
+
/** Import a SQL file in one exclusive transaction on the calling thread.
|
|
88
|
+
* Each non-empty line is treated as one statement.
|
|
89
|
+
* @param dbName Name of an open database.
|
|
90
|
+
* @param location Path to the SQL file.
|
|
91
|
+
* @returns Number of executed commands and affected rows.
|
|
92
|
+
*/
|
|
17
93
|
loadFile(dbName: string, location: string): FileLoadResult;
|
|
94
|
+
/** Import a SQL file on a background thread.
|
|
95
|
+
* @param dbName Name of an open database.
|
|
96
|
+
* @param location Path to the SQL file.
|
|
97
|
+
* @returns A promise of the command and affected row counts.
|
|
98
|
+
*/
|
|
18
99
|
loadFileAsync(dbName: string, location: string): Promise<FileLoadResult>;
|
|
19
100
|
}
|
|
20
101
|
//# sourceMappingURL=NitroSQLite.nitro.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroSQLite.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLite.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,iB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,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CAAA;IACP;;;OAGG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/C;;;;;OAKG;IACH,OAAO,CACL,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,iBAAiB,GACzB,sBAAsB,CAAA;IACzB;;;;;OAKG;IACH,YAAY,CACV,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAClC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,4BAA4B,CAAA;IACpE;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,gBAAgB,CAAA;IAC7E;;;;;OAKG;IACH,iBAAiB,CACf,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,iBAAiB,EAAE,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAAA;IAC1D;;;;OAIG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CACzE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
import type { SQLiteQueryParams } from '../types';
|
|
3
|
+
import type { NitroSQLiteQueryResult } from './NitroSQLiteQueryResult.nitro';
|
|
4
|
+
/** Native prepared statement returned by `NitroSQLite.native.prepare()`. */
|
|
5
|
+
export interface NitroSQLitePreparedStatement extends HybridObject<{
|
|
6
|
+
ios: 'c++';
|
|
7
|
+
android: 'c++';
|
|
8
|
+
}> {
|
|
9
|
+
/** Whether the native statement has been finalized. */
|
|
10
|
+
readonly isFinalized: boolean;
|
|
11
|
+
/** Execute on the calling thread, replacing the previous parameter bindings.
|
|
12
|
+
* Throws after finalization or connection closure.
|
|
13
|
+
* @param params Values bound to positional placeholders.
|
|
14
|
+
* @returns Native query rows, affected row count, insert ID, and metadata.
|
|
15
|
+
*/
|
|
16
|
+
execute(params?: SQLiteQueryParams): NitroSQLiteQueryResult;
|
|
17
|
+
/** Execute on a background thread, replacing the previous parameter bindings.
|
|
18
|
+
* Rejects after finalization or connection closure.
|
|
19
|
+
* @param params Values bound to positional placeholders.
|
|
20
|
+
* @returns A promise of the native query result.
|
|
21
|
+
*/
|
|
22
|
+
executeAsync(params?: SQLiteQueryParams): Promise<NitroSQLiteQueryResult>;
|
|
23
|
+
/** Release the native statement. Repeated calls are safe. */
|
|
24
|
+
finalize(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=NitroSQLitePreparedStatement.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NitroSQLitePreparedStatement.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLitePreparedStatement.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAE5E,4EAA4E;AAC5E,MAAM,WAAW,4BACf,SAAQ,YAAY,CAAC;IACnB,GAAG,EAAE,KAAK,CAAA;IACV,OAAO,EAAE,KAAK,CAAA;CACf,CAAC;IACF,uDAAuD;IACvD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;IAE7B;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,sBAAsB,CAAA;IAC3D;;;;OAIG;IACH,YAAY,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;IACzE,6DAA6D;IAC7D,QAAQ,IAAI,IAAI,CAAA;CACjB"}
|
|
@@ -1,32 +1,26 @@
|
|
|
1
1
|
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
2
|
import type { ColumnType, SQLiteValue } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Object returned by SQL Query executions {
|
|
5
|
-
* insertId: Represent the auto-generated row id if applicable
|
|
6
|
-
* rowsAffected: Number of affected rows if result of a update query
|
|
7
|
-
* message: if status === 1, here you will find error description
|
|
8
|
-
* rows: if status is undefined or 0 this object will contain the query results
|
|
9
|
-
* }
|
|
10
|
-
*
|
|
11
|
-
* @interface QueryResult
|
|
12
|
-
*/
|
|
3
|
+
/** Native result of one SQL statement. The managed API also adds a `rows` adapter. */
|
|
13
4
|
export interface NitroSQLiteQueryResult extends HybridObject<{
|
|
14
5
|
ios: 'c++';
|
|
15
6
|
android: 'c++';
|
|
16
7
|
}> {
|
|
8
|
+
/** SQLite's latest row change count. For a read-only query it may reflect an earlier write. */
|
|
17
9
|
readonly rowsAffected: number;
|
|
10
|
+
/** Last insert row ID for this connection. It may refer to an earlier statement. */
|
|
18
11
|
readonly insertId?: number;
|
|
19
|
-
/**
|
|
12
|
+
/** Rows keyed by result column names. */
|
|
20
13
|
readonly results: Record<string, SQLiteValue>[];
|
|
21
|
-
/**
|
|
14
|
+
/** Column metadata keyed by result column name, when available. */
|
|
22
15
|
readonly metadata?: Record<string, NitroSQLiteQueryColumnMetadata>;
|
|
23
16
|
}
|
|
17
|
+
/** Name, declared type, and position of a result column. */
|
|
24
18
|
export type NitroSQLiteQueryColumnMetadata = {
|
|
25
|
-
/**
|
|
19
|
+
/** Name used for this column in the result set. */
|
|
26
20
|
name: string;
|
|
27
|
-
/**
|
|
21
|
+
/** Native type category derived from the column declaration. */
|
|
28
22
|
type: ColumnType;
|
|
29
|
-
/**
|
|
23
|
+
/** Zero-based position in the result set. */
|
|
30
24
|
index: number;
|
|
31
25
|
};
|
|
32
26
|
//# sourceMappingURL=NitroSQLiteQueryResult.nitro.d.ts.map
|
|
@@ -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
|
|
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,sFAAsF;AACtF,MAAM,WAAW,sBACf,SAAQ,YAAY,CAAC;IACnB,GAAG,EAAE,KAAK,CAAA;IACV,OAAO,EAAE,KAAK,CAAA;CACf,CAAC;IACF,+FAA+F;IAC/F,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAE1B,yCAAyC;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAA;IAE/C,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAA;CACnE;AASD,4DAA4D;AAC5D,MAAM,MAAM,8BAA8B,GAAG;IAC3C,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IAEZ,gEAAgE;IAChE,IAAI,EAAE,UAAU,CAAA;IAEhB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAA;CACd,CAAA"}
|
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
import type { Transaction, SQLiteQueryParams, QueryResultRow, QueryResult } from './types';
|
|
2
|
+
/** Callback-oriented connection returned to TypeORM. */
|
|
2
3
|
interface TypeOrmNitroSQLiteConnection {
|
|
4
|
+
/** Execute SQL asynchronously and report the result through a callback. */
|
|
3
5
|
executeSql: <RowData extends QueryResultRow = never>(sql: string, params: SQLiteQueryParams | undefined, okExecute: (res: QueryResult<RowData>) => void, failExecute: (msg: string) => void) => Promise<void>;
|
|
6
|
+
/** Run TypeORM work in a managed transaction. */
|
|
4
7
|
transaction: (fn: (tx: Transaction) => Promise<void>) => Promise<void>;
|
|
8
|
+
/** Close the connection and report completion through callbacks. */
|
|
5
9
|
close: (okClose: () => void, failClose: (e: unknown) => void) => void;
|
|
10
|
+
/** Attach another database and invoke `callback` after it succeeds. */
|
|
6
11
|
attach: (dbNameToAttach: string, alias: string, location: string | undefined, callback: () => void) => void;
|
|
12
|
+
/** Detach an attached database and invoke `callback` after it succeeds. */
|
|
7
13
|
detach: (alias: string, callback: () => void) => void;
|
|
8
14
|
}
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
15
|
+
/** Adapter for TypeORM's React Native driver. Application code should use `open()`.
|
|
16
|
+
* `openDatabase` reports success or failure through callbacks and returns the
|
|
17
|
+
* connection on success, or `null` when opening fails.
|
|
12
18
|
*/
|
|
13
19
|
export declare const typeORMDriver: {
|
|
20
|
+
/** Open a database for TypeORM.
|
|
21
|
+
* @param options Database name and optional relative directory.
|
|
22
|
+
* @param ok Receives the adapter connection on success.
|
|
23
|
+
* @param fail Receives the opening error on failure.
|
|
24
|
+
*/
|
|
14
25
|
openDatabase: (options: {
|
|
15
26
|
name: string;
|
|
16
27
|
location?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeORM.d.ts","sourceRoot":"","sources":["../../../src/typeORM.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,WAAW,EACZ,MAAM,SAAS,CAAA;AAGhB,UAAU,4BAA4B;IACpC,UAAU,EAAE,CAAC,OAAO,SAAS,cAAc,GAAG,KAAK,EACjD,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,iBAAiB,GAAG,SAAS,EACrC,SAAS,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,IAAI,EAC9C,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,KAC/B,OAAO,CAAC,IAAI,CAAC,CAAA;IAClB,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACtE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAA;IACrE,MAAM,EAAE,CACN,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,QAAQ,EAAE,MAAM,IAAI,KACjB,IAAI,CAAA;IACT,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;CACtD;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa;
|
|
1
|
+
{"version":3,"file":"typeORM.d.ts","sourceRoot":"","sources":["../../../src/typeORM.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,WAAW,EACZ,MAAM,SAAS,CAAA;AAGhB,wDAAwD;AACxD,UAAU,4BAA4B;IACpC,2EAA2E;IAC3E,UAAU,EAAE,CAAC,OAAO,SAAS,cAAc,GAAG,KAAK,EACjD,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,iBAAiB,GAAG,SAAS,EACrC,SAAS,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,IAAI,EAC9C,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,KAC/B,OAAO,CAAC,IAAI,CAAC,CAAA;IAClB,iDAAiD;IACjD,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACtE,oEAAoE;IACpE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAA;IACrE,uEAAuE;IACvE,MAAM,EAAE,CACN,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,QAAQ,EAAE,MAAM,IAAI,KACjB,IAAI,CAAA;IACT,2EAA2E;IAC3E,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;CACtD;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa;IACxB;;;;OAIG;4BAEQ;QACP,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,MACG,CAAC,EAAE,EAAE,4BAA4B,KAAK,IAAI,QACxC,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,KAC1B,4BAA4B,GAAG,IAAI;CAuDvC,CAAA"}
|
|
@@ -1,78 +1,181 @@
|
|
|
1
1
|
import type { NitroSQLiteQueryResult } from './specs/NitroSQLiteQueryResult.nitro';
|
|
2
|
+
/** Options for `open()` and `NitroSQLite.open()`. */
|
|
2
3
|
export interface NitroSQLiteConnectionOptions {
|
|
4
|
+
/** Database file name. Only one managed connection may use a name at a time. */
|
|
3
5
|
name: string;
|
|
6
|
+
/** Directory relative to the platform's database directory. */
|
|
4
7
|
location?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Choose a connection to the database file. The default connection is addressed
|
|
10
|
+
* by `name`, so opening it twice throws. Each `independent` connection has its
|
|
11
|
+
* own native handle and operation queue and can share a file with other connections.
|
|
12
|
+
* Defaults to `'default'`.
|
|
13
|
+
*/
|
|
14
|
+
connection?: 'default' | 'independent';
|
|
15
|
+
/**
|
|
16
|
+
* Open an existing database without write access. Opening fails if the file does
|
|
17
|
+
* not exist. A read-only connection cannot write, attach, or delete a database.
|
|
18
|
+
* Defaults to `false`.
|
|
19
|
+
*/
|
|
20
|
+
readOnly?: boolean;
|
|
5
21
|
}
|
|
22
|
+
/** A managed connection bound to one database name. Do not use it after closing or deleting it. */
|
|
6
23
|
export interface NitroSQLiteConnection {
|
|
24
|
+
/** Close the connection. Throws if a queued operation is running or pending. */
|
|
7
25
|
close(): void;
|
|
26
|
+
/** Delete the database file and end this connection. Throws if the connection is busy.
|
|
27
|
+
* This also closes the native handle if it is open.
|
|
28
|
+
*/
|
|
8
29
|
delete(): void;
|
|
30
|
+
/** Attach another database under `alias` for queries against this connection.
|
|
31
|
+
* @param dbNameToAttach File name of the database to attach.
|
|
32
|
+
* @param alias SQL schema name for the attached database.
|
|
33
|
+
* @param location Directory relative to the platform database directory.
|
|
34
|
+
*/
|
|
9
35
|
attach(dbNameToAttach: string, alias: string, location?: string): void;
|
|
36
|
+
/** Detach the database identified by `alias`.
|
|
37
|
+
* @param alias SQL schema name used when attaching the database.
|
|
38
|
+
*/
|
|
10
39
|
detach(alias: string): void;
|
|
40
|
+
/** Run a callback in a queued transaction. The callback must use `tx` for database work.
|
|
41
|
+
* It commits on success and rolls back on error unless explicitly finalized.
|
|
42
|
+
* Awaiting another queued operation for this database inside the callback deadlocks.
|
|
43
|
+
* Synchronous connection methods throw while this transaction is active.
|
|
44
|
+
* @param transactionCallback Async callback receiving the transaction handle.
|
|
45
|
+
* @returns The callback's result after the transaction finishes.
|
|
46
|
+
*/
|
|
11
47
|
transaction: <Result = void>(transactionCallback: (tx: Transaction) => Promise<Result>) => Promise<Result>;
|
|
48
|
+
/** Execute one SQL statement synchronously. Throws while the connection is busy. */
|
|
12
49
|
execute: ExecuteQuery;
|
|
50
|
+
/** Queue one SQL statement and resolve with its result. */
|
|
13
51
|
executeAsync: ExecuteAsyncQuery;
|
|
52
|
+
/**
|
|
53
|
+
* Prepare one SQL statement on this connection for repeated execution.
|
|
54
|
+
* Finalize the returned statement before closing the connection.
|
|
55
|
+
* @param query SQL statement with optional positional placeholders.
|
|
56
|
+
*/
|
|
57
|
+
prepare(query: string): PreparedStatement;
|
|
58
|
+
/** Execute commands in one exclusive transaction. Throws while the connection is busy.
|
|
59
|
+
* @param commands SQL commands and optional parameter sets.
|
|
60
|
+
* @returns Total affected row count.
|
|
61
|
+
*/
|
|
14
62
|
executeBatch(commands: BatchQueryCommand[]): BatchQueryResult;
|
|
63
|
+
/** Queue commands in one exclusive transaction.
|
|
64
|
+
* @param commands SQL commands and optional parameter sets.
|
|
65
|
+
* @returns A promise of the total affected row count.
|
|
66
|
+
*/
|
|
15
67
|
executeBatchAsync(commands: BatchQueryCommand[]): Promise<BatchQueryResult>;
|
|
68
|
+
/** Execute one non-empty SQL command per file line in an exclusive transaction.
|
|
69
|
+
* `location` is a path to the SQL file; multi-line statements are unsupported.
|
|
70
|
+
* @param location Path to the SQL file.
|
|
71
|
+
* @returns Number of executed commands and affected rows.
|
|
72
|
+
*/
|
|
16
73
|
loadFile(location: string): FileLoadResult;
|
|
74
|
+
/** Queue the file import and resolve with its command and row counts.
|
|
75
|
+
* @param location Path to the SQL file.
|
|
76
|
+
*/
|
|
17
77
|
loadFileAsync(location: string): Promise<FileLoadResult>;
|
|
18
78
|
}
|
|
79
|
+
/** SQLite value categories reported in query column metadata. */
|
|
19
80
|
export declare enum ColumnType {
|
|
81
|
+
/** Boolean declaration. */
|
|
20
82
|
BOOLEAN = 0,
|
|
83
|
+
/** Floating point declaration. */
|
|
21
84
|
NUMBER = 1,
|
|
85
|
+
/** Integer declaration. */
|
|
22
86
|
INT64 = 2,
|
|
87
|
+
/** Text declaration. */
|
|
23
88
|
TEXT = 3,
|
|
89
|
+
/** Blob declaration. */
|
|
24
90
|
ARRAY_BUFFER = 4,
|
|
91
|
+
/** Missing or unrecognized declaration. */
|
|
25
92
|
NULL_VALUE = 5
|
|
26
93
|
}
|
|
94
|
+
/** Values accepted by bound SQL parameters and returned in result rows. */
|
|
27
95
|
export type SQLiteValue = boolean | number | string | ArrayBuffer | null;
|
|
96
|
+
/** Positional values for SQL placeholders. */
|
|
28
97
|
export type SQLiteQueryParams = SQLiteValue[];
|
|
98
|
+
/** A row keyed by result column names. */
|
|
29
99
|
export type QueryResultRow = Record<string, SQLiteValue>;
|
|
100
|
+
/** Query result with a row adapter for TypeORM-style consumers. */
|
|
30
101
|
export type QueryResult<Row extends QueryResultRow = QueryResultRow> = NitroSQLiteQueryResult & {
|
|
31
|
-
/** Query
|
|
102
|
+
/** Query rows in a TypeORM-compatible collection. */
|
|
32
103
|
rows: NitroSQLiteQueryResultRows<Row>;
|
|
33
104
|
};
|
|
105
|
+
/** Indexable view of query rows. */
|
|
34
106
|
export type NitroSQLiteQueryResultRows<Row extends Record<string, SQLiteValue> = Record<string, SQLiteValue>> = {
|
|
35
|
-
/**
|
|
107
|
+
/** All returned rows. */
|
|
36
108
|
_array: Row[];
|
|
37
|
-
/**
|
|
109
|
+
/** Number of returned rows. */
|
|
38
110
|
length: number;
|
|
39
|
-
/**
|
|
40
|
-
* @param idx
|
|
41
|
-
* @returns the row structure identified by column names
|
|
111
|
+
/** Get a row by zero-based index; returns `undefined` when out of range.
|
|
112
|
+
* @param idx Row index.
|
|
42
113
|
*/
|
|
43
114
|
item: (idx: number) => Row | undefined;
|
|
44
115
|
};
|
|
116
|
+
/** Execute one SQL statement synchronously and return its typed rows.
|
|
117
|
+
* @param query SQL statement with optional positional placeholders.
|
|
118
|
+
* @param params Values bound to the placeholders.
|
|
119
|
+
*/
|
|
45
120
|
export type ExecuteQuery = <Row extends QueryResultRow = QueryResultRow>(query: string, params?: SQLiteValue[]) => QueryResult<Row>;
|
|
121
|
+
/** Queue one SQL statement and resolve with its typed rows.
|
|
122
|
+
* @param query SQL statement with optional positional placeholders.
|
|
123
|
+
* @param params Values bound to the placeholders.
|
|
124
|
+
*/
|
|
46
125
|
export type ExecuteAsyncQuery = <Row extends QueryResultRow = QueryResultRow>(query: string, params?: SQLiteQueryParams) => Promise<QueryResult<Row>>;
|
|
126
|
+
/**
|
|
127
|
+
* A reusable SQL statement bound to the connection that prepared it. Each
|
|
128
|
+
* execution resets the statement and its bindings before applying new values.
|
|
129
|
+
* Finalize it before closing the connection.
|
|
130
|
+
*/
|
|
131
|
+
export interface PreparedStatement {
|
|
132
|
+
/** Whether `finalize()` has released the native statement. */
|
|
133
|
+
readonly isFinalized: boolean;
|
|
134
|
+
/** Execute on the calling thread. Throws if the statement is finalized, its connection is closed, or the managed connection is busy. */
|
|
135
|
+
execute: ExecutePreparedStatement;
|
|
136
|
+
/** Queue execution on a background thread and resolve with the query result. */
|
|
137
|
+
executeAsync: ExecutePreparedStatementAsync;
|
|
138
|
+
/** Release the native statement. Calling this more than once is safe. */
|
|
139
|
+
finalize(): void;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Execute a prepared statement with optional positional values and return typed rows.
|
|
143
|
+
* Each call replaces the previous parameter bindings.
|
|
144
|
+
* @param params Values bound to the statement's positional placeholders.
|
|
145
|
+
*/
|
|
146
|
+
export type ExecutePreparedStatement = <Row extends QueryResultRow = QueryResultRow>(params?: SQLiteQueryParams) => QueryResult<Row>;
|
|
147
|
+
/**
|
|
148
|
+
* Queue a prepared statement execution and resolve with typed rows. Calls on the
|
|
149
|
+
* same managed connection run in queue order.
|
|
150
|
+
* @param params Values bound to the statement's positional placeholders.
|
|
151
|
+
*/
|
|
152
|
+
export type ExecutePreparedStatementAsync = <Row extends QueryResultRow = QueryResultRow>(params?: SQLiteQueryParams) => Promise<QueryResult<Row>>;
|
|
153
|
+
/** Handle valid only while its transaction callback is active. */
|
|
47
154
|
export interface Transaction {
|
|
155
|
+
/** Commit now. Further operations on this transaction throw. */
|
|
48
156
|
commit(): NitroSQLiteQueryResult;
|
|
157
|
+
/** Roll back now. Further operations on this transaction throw. */
|
|
49
158
|
rollback(): NitroSQLiteQueryResult;
|
|
159
|
+
/** Execute within this transaction on the calling thread. */
|
|
50
160
|
execute: ExecuteQuery;
|
|
161
|
+
/** Execute within this transaction on a background thread. */
|
|
51
162
|
executeAsync: ExecuteAsyncQuery;
|
|
52
163
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Allows the execution of bulk of sql commands
|
|
55
|
-
* inside a transaction
|
|
56
|
-
* If a single query must be executed many times with different arguments, its preferred
|
|
57
|
-
* to declare it a single time, and use an array of array parameters.
|
|
58
|
-
*/
|
|
164
|
+
/** One command in a batch. A nested `params` array repeats the query for each parameter set. */
|
|
59
165
|
export interface BatchQueryCommand {
|
|
166
|
+
/** SQL statement to execute. */
|
|
60
167
|
query: string;
|
|
168
|
+
/** One parameter set, or several sets for repeated execution. */
|
|
61
169
|
params?: SQLiteQueryParams | SQLiteQueryParams[];
|
|
62
170
|
}
|
|
63
|
-
/**
|
|
64
|
-
* status: 0 or undefined for correct execution, 1 for error
|
|
65
|
-
* message: if status === 1, here you will find error description
|
|
66
|
-
* rowsAffected: Number of affected rows if status == 0
|
|
67
|
-
*/
|
|
171
|
+
/** Result of a committed SQL batch. Errors are thrown rather than returned here. */
|
|
68
172
|
export interface BatchQueryResult {
|
|
173
|
+
/** Total number of rows changed by the batch. */
|
|
69
174
|
rowsAffected?: number;
|
|
70
175
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Result of loading a file and executing every line as a SQL command
|
|
73
|
-
* Similar to BatchQueryResult
|
|
74
|
-
*/
|
|
176
|
+
/** Result of importing a SQL file in one transaction. */
|
|
75
177
|
export interface FileLoadResult extends BatchQueryResult {
|
|
178
|
+
/** Number of non-empty lines executed as SQL commands. */
|
|
76
179
|
commands?: number;
|
|
77
180
|
}
|
|
78
181
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAA;AAElF,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAA;AAElF,qDAAqD;AACrD,MAAM,WAAW,4BAA4B;IAC3C,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAA;IACZ,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,SAAS,GAAG,aAAa,CAAA;IACtC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,mGAAmG;AACnG,MAAM,WAAW,qBAAqB;IACpC,gFAAgF;IAChF,KAAK,IAAI,IAAI,CAAA;IACb;;OAEG;IACH,MAAM,IAAI,IAAI,CAAA;IACd;;;;OAIG;IACH,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtE;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B;;;;;;OAMG;IACH,WAAW,EAAE,CAAC,MAAM,GAAG,IAAI,EACzB,mBAAmB,EAAE,CAAC,EAAE,EAAE,WAAW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B,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;AAE9B,kEAAkE;AAClE,MAAM,WAAW,WAAW;IAC1B,gEAAgE;IAChE,MAAM,IAAI,sBAAsB,CAAA;IAChC,mEAAmE;IACnE,QAAQ,IAAI,sBAAsB,CAAA;IAClC,6DAA6D;IAC7D,OAAO,EAAE,YAAY,CAAA;IACrB,8DAA8D;IAC9D,YAAY,EAAE,iBAAiB,CAAA;CAChC;AAED,gGAAgG;AAChG,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,iEAAiE;IACjE,MAAM,CAAC,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,CAAA;CACjD;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,yDAAyD;AACzD,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export interface QueuedOperation {
|
|
2
|
+
kind: 'statement' | 'exclusive';
|
|
2
3
|
/**
|
|
3
4
|
* Starts the operation
|
|
4
5
|
*/
|
|
@@ -7,12 +8,19 @@ export interface QueuedOperation {
|
|
|
7
8
|
export type DatabaseQueue = {
|
|
8
9
|
queue: QueuedOperation[];
|
|
9
10
|
inProgress: boolean;
|
|
11
|
+
activeStatements: number;
|
|
12
|
+
draining: boolean;
|
|
10
13
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
14
|
+
/** Identity of a managed connection's operation queue. Application code should
|
|
15
|
+
* omit the optional queue key on package helpers; connections choose it for you.
|
|
16
|
+
*/
|
|
17
|
+
export type DatabaseQueueKey = string | symbol;
|
|
18
|
+
export declare function openDatabaseQueue(dbName: DatabaseQueueKey): void;
|
|
19
|
+
export declare function closeDatabaseQueue(dbName: DatabaseQueueKey): void;
|
|
20
|
+
export declare function isDatabaseOpen(dbName: DatabaseQueueKey): boolean;
|
|
21
|
+
export declare function throwIfDatabaseIsNotOpen(dbName: DatabaseQueueKey): void;
|
|
22
|
+
export declare function getDatabaseQueue(dbName: DatabaseQueueKey): DatabaseQueue;
|
|
23
|
+
export declare function queueOperationAsync<Result>(dbName: DatabaseQueueKey, callback: () => Promise<Result>): Promise<Result>;
|
|
24
|
+
export declare function queueStatementAsync<Result>(dbName: DatabaseQueueKey, callback: () => Promise<Result>): Promise<Result>;
|
|
25
|
+
export declare function startOperationSync<Result>(dbName: DatabaseQueueKey, callback: () => Result): Result;
|
|
18
26
|
//# sourceMappingURL=DatabaseQueue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseQueue.d.ts","sourceRoot":"","sources":["../../../src/DatabaseQueue.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,eAAe,EAAE,CAAA;IACxB,UAAU,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"DatabaseQueue.d.ts","sourceRoot":"","sources":["../../../src/DatabaseQueue.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,GAAG,WAAW,CAAA;IAC/B;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,eAAe,EAAE,CAAA;IACxB,UAAU,EAAE,OAAO,CAAA;IACnB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAA;AAI9C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,QAazD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,QAU1D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,WAEtD;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,QAKhE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,iBAKxD;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EACxC,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EACxC,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,CAEjB;AAwED,wBAAgB,kBAAkB,CAAC,MAAM,EACvC,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,MAAM,MAAM,GACrB,MAAM,CAkBR"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom error class for NitroSQLite operations
|
|
3
|
-
* Extends the native Error class with proper prototype chain and error handling
|
|
4
|
-
*/
|
|
1
|
+
/** Error thrown by managed NitroSQLite operations. Native errors are wrapped with this class. */
|
|
5
2
|
export default class NitroSQLiteError extends Error {
|
|
3
|
+
/** Create an error with a message and optional cause. */
|
|
6
4
|
constructor(message: string, options?: ErrorOptions);
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
/** Convert an unknown thrown value to `NitroSQLiteError`.
|
|
6
|
+
* Existing instances pass through; `Error` values keep their stack and cause.
|
|
7
|
+
* @param error Value to normalize.
|
|
8
|
+
* @returns A NitroSQLiteError instance.
|
|
10
9
|
*/
|
|
11
10
|
static fromError(error: unknown): NitroSQLiteError;
|
|
12
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroSQLiteError.d.ts","sourceRoot":"","sources":["../../../src/NitroSQLiteError.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"NitroSQLiteError.d.ts","sourceRoot":"","sources":["../../../src/NitroSQLiteError.ts"],"names":[],"mappings":"AAEA,iGAAiG;AACjG,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,KAAK;IACjD,yDAAyD;gBAC7C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;IAQnD;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB;CAyBnD"}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { open } from './operations/session';
|
|
2
2
|
import { execute, executeAsync } from './operations/execute';
|
|
3
|
+
import { prepare } from './operations/prepare';
|
|
3
4
|
import { executeBatch, executeBatchAsync } from './operations/executeBatch';
|
|
5
|
+
/** Database entry point. Prefer {@link open} for a managed connection.
|
|
6
|
+
* `native` exposes the Nitro object directly and bypasses the JavaScript queue.
|
|
7
|
+
*/
|
|
4
8
|
export declare const NitroSQLite: {
|
|
5
9
|
native: import("./specs/NitroSQLite.nitro").NitroSQLite;
|
|
6
10
|
open: typeof open;
|
|
7
|
-
transaction: <Result = void>(dbName: string, transactionCallback: (tx: import("./types").Transaction) => Promise<Result>, isExclusive?: boolean) => Promise<Result>;
|
|
11
|
+
transaction: <Result = void>(dbName: string, transactionCallback: (tx: import("./types").Transaction) => Promise<Result>, isExclusive?: boolean, queueKey?: import("./DatabaseQueue").DatabaseQueueKey) => Promise<Result>;
|
|
8
12
|
execute: typeof execute;
|
|
9
13
|
executeAsync: typeof executeAsync;
|
|
14
|
+
prepare: typeof prepare;
|
|
10
15
|
executeBatch: typeof executeBatch;
|
|
11
16
|
executeBatchAsync: typeof executeBatchAsync;
|
|
17
|
+
openConnection(dbName: string, location?: string, readOnly?: boolean): string;
|
|
18
|
+
isConnectionOpen(connectionId: string): boolean;
|
|
12
19
|
close(dbName: string): void;
|
|
13
|
-
drop(dbName: string, location?: string): void;
|
|
20
|
+
drop(dbName: string, location?: string, connectionId?: string): void;
|
|
14
21
|
attach(mainDbName: string, dbNameToAttach: string, alias: string, location?: string): void;
|
|
15
22
|
detach(mainDbName: string, alias: string): void;
|
|
16
23
|
loadFile(dbName: string, location: string): import("./types").FileLoadResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAE9C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAI3E;;GAEG;AACH,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"}
|