API Reference / react-native-nitro-sqlite / NitroSQLiteNative
Interface: NitroSQLiteNative
TypeScriptC++Source files: TypeScript · C++
Native database operations exposed through NitroSQLite.native.
These calls bypass the managed connection queue. Coordinate them with any
transaction or pending operation on the same database yourself.
Extends
HybridObject<{android:"c++";ios:"c++"; }>
Methods
attach()
attach(
mainDbName,dbNameToAttach,alias,location?):void
Defined in: specs/NitroSQLite.nitro.ts:54
Attach a database file to an open main database under an SQL schema alias.
Parameters
mainDbName
string
Name of the open main database.
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(
dbName):void
Defined in: specs/NitroSQLite.nitro.ts:39
Close a default connection by name or an independent connection by ID.
Parameters
dbName
string
Returns
void
detach()
detach(
mainDbName,alias):void
Defined in: specs/NitroSQLite.nitro.ts:64
Detach an attached database by its alias.
Parameters
mainDbName
string
Name of the open main database.
alias
string
SQL schema name used when attaching.
Returns
void
drop()
drop(
dbName,location?,connectionId?):void
Defined in: specs/NitroSQLite.nitro.ts:46
Delete a database and close the indicated connection if open. Deletion fails while another connection or attachment uses the database file.
Parameters
dbName
string
Database file name.
location?
string
Directory relative to the platform database directory.
connectionId?
string
Optional ID of the independent connection to close.
Returns
void
execute()
execute(
dbName,query,params?):NitroSQLiteQueryResult
Defined in: specs/NitroSQLite.nitro.ts:71
Execute one SQL statement synchronously on the calling thread.
Parameters
dbName
string
Name of an open database.
query
string
SQL statement with optional positional placeholders.
params?
Positional values bound to SQL placeholders.
Returns
Native query rows, affected row count, insert ID, and metadata.
executeAsync()
executeAsync(
dbName,query,params?):Promise<NitroSQLiteQueryResult>
Defined in: specs/NitroSQLite.nitro.ts:82
Execute one SQL statement on a background thread.
Parameters
dbName
string
Name of an open database.
query
string
SQL statement with optional positional placeholders.
params?
Positional values bound to SQL placeholders.
Returns
Promise<NitroSQLiteQueryResult>
A promise of the native query result.
executeBatch()
executeBatch(
dbName,commands):BatchQueryResult
Defined in: specs/NitroSQLite.nitro.ts:100
Execute commands in one exclusive transaction on the calling thread. An empty batch throws; a failed command rolls back the batch.
Parameters
dbName
string
Name of an open database.
commands
SQL commands and optional parameter sets.
Returns
Total affected row count.
executeBatchAsync()
executeBatchAsync(
dbName,commands):Promise<BatchQueryResult>
Defined in: specs/NitroSQLite.nitro.ts:107
Execute commands in one exclusive transaction on a background thread. An empty batch rejects; a failed command rolls back the batch.
Parameters
dbName
string
Name of an open database.
commands
SQL commands and optional parameter sets.
Returns
Promise<BatchQueryResult>
A promise of the total affected row count.
isConnectionOpen()
isConnectionOpen(
connectionId):boolean
Defined in: specs/NitroSQLite.nitro.ts:37
Check whether a native connection ID is still open.
Parameters
connectionId
string
ID returned by openConnection.
Returns
boolean
loadFile()
loadFile(
dbName,location):FileLoadResult
Defined in: specs/NitroSQLite.nitro.ts:117
Import a SQL file in one exclusive transaction on the calling thread. Each non-empty line is treated as one statement.
Parameters
dbName
string
Name of an open database.
location
string
Path to the SQL file.
Returns
Number of executed commands and affected rows.
loadFileAsync()
loadFileAsync(
dbName,location):Promise<FileLoadResult>
Defined in: specs/NitroSQLite.nitro.ts:123
Import a SQL file on a background thread.
Parameters
dbName
string
Name of an open database.
location
string
Path to the SQL file.
Returns
Promise<FileLoadResult>
A promise of the command and affected row counts.
open()
open(
dbName,location?,readOnly?):void
Defined in: specs/NitroSQLite.nitro.ts:25
Open a name-based default connection, creating the database unless readOnly is true.
Parameters
dbName
string
Database file name and default connection key.
location?
string
Directory relative to the platform database directory.
readOnly?
boolean
Open an existing database without write access.
Returns
void
openConnection()
openConnection(
dbName,location?,readOnly?):string
Defined in: specs/NitroSQLite.nitro.ts:33
Open a separate native handle, even when the database file is already open. Independent connections require a thread-safe SQLite build.
Parameters
dbName
string
Database file name.
location?
string
Directory relative to the platform database directory.
readOnly?
boolean
Open an existing database without write access.
Returns
string
An opaque ID to pass to native connection operations.
prepare()
prepare(
dbName,query):NitroSQLitePreparedStatement
Defined in: specs/NitroSQLite.nitro.ts:93
Prepare one SQL statement on an open native connection for repeated execution. Finalize the returned statement before closing its connection.
Parameters
dbName
string
Name or ID of an open database connection.
query
string
SQL statement with optional positional placeholders.
Returns
A native statement with synchronous and asynchronous execution methods.