API Reference / react-native-nitro-sqlite / NitroSQLiteConnection
Interface: NitroSQLiteConnection
TypeScriptSource files: TypeScript
A managed connection bound to one database name. Do not use it after closing or deleting it.
Properties
execute
execute:
ExecuteQuery
Defined in: types.ts:40
Execute one SQL statement synchronously. Throws while the connection is busy.
executeAsync
executeAsync:
ExecuteAsyncQuery
Defined in: types.ts:42
Queue one SQL statement and resolve with its result.
transaction
transaction: <
Result>(transactionCallback) =>Promise<Result>
Defined in: types.ts:36
Run a callback in a queued transaction. The callback must use tx for database work.
It commits on success and rolls back on error unless explicitly finalized.
Awaiting another queued operation for this database inside the callback deadlocks.
Synchronous connection methods throw while this transaction is active.
Type Parameters
Result
Result = void
Parameters
transactionCallback
(tx) => Promise<Result>
Async callback receiving the transaction handle.
Returns
Promise<Result>
The callback's result after the transaction finishes.
Methods
attach()
attach(
dbNameToAttach,alias,location?):void
Defined in: types.ts:24
Attach another database under alias for queries against this connection.
Parameters
dbNameToAttach
string
File name of the database to attach.
alias
string
SQL schema name for the attached database.
location?
string
Directory relative to the platform database directory.
Returns
void
close()
close():
void
Defined in: types.ts:14
Close the connection. Throws if a queued operation is running or pending.
Returns
void
delete()
delete():
void
Defined in: types.ts:18
Delete the database file and end this connection. Throws if the connection is busy. This also closes the native handle if it is open.
Returns
void
detach()
detach(
alias):void
Defined in: types.ts:28
Detach the database identified by alias.
Parameters
alias
string
SQL schema name used when attaching the database.
Returns
void
executeBatch()
executeBatch(
commands):BatchQueryResult
Defined in: types.ts:47
Execute commands in one exclusive transaction. Throws while the connection is busy.
Parameters
commands
SQL commands and optional parameter sets.
Returns
Total affected row count.
executeBatchAsync()
executeBatchAsync(
commands):Promise<BatchQueryResult>
Defined in: types.ts:52
Queue commands in one exclusive transaction.
Parameters
commands
SQL commands and optional parameter sets.
Returns
Promise<BatchQueryResult>
A promise of the total affected row count.
loadFile()
loadFile(
location):FileLoadResult
Defined in: types.ts:58
Execute one non-empty SQL command per file line in an exclusive transaction.
location is a path to the SQL file; multi-line statements are unsupported.
Parameters
location
string
Path to the SQL file.
Returns
Number of executed commands and affected rows.
loadFileAsync()
loadFileAsync(
location):Promise<FileLoadResult>
Defined in: types.ts:62
Queue the file import and resolve with its command and row counts.
Parameters
location
string
Path to the SQL file.
Returns
Promise<FileLoadResult>