NitroSQLite
React native nitro sqliteHybrid Objects

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:39

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:27

Close the named native database handle.

Parameters

dbName

string

Name of the open database.

Returns

void


detach()

detach(mainDbName, alias): void

Defined in: specs/NitroSQLite.nitro.ts:49

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?): void

Defined in: specs/NitroSQLite.nitro.ts:32

Remove the named database file and close its native handle if open.

Parameters

dbName

string

Database file name.

location?

string

Directory relative to the platform database directory.

Returns

void


execute()

execute(dbName, query, params?): NitroSQLiteQueryResult

Defined in: specs/NitroSQLite.nitro.ts:56

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?

SQLiteQueryParams

Positional values bound to SQL placeholders.

Returns

NitroSQLiteQueryResult

Native query rows, affected row count, insert ID, and metadata.


executeAsync()

executeAsync(dbName, query, params?): Promise<NitroSQLiteQueryResult>

Defined in: specs/NitroSQLite.nitro.ts:67

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?

SQLiteQueryParams

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:78

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

BatchQueryCommand[]

SQL commands and optional parameter sets.

Returns

BatchQueryResult

Total affected row count.


executeBatchAsync()

executeBatchAsync(dbName, commands): Promise<BatchQueryResult>

Defined in: specs/NitroSQLite.nitro.ts:85

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

BatchQueryCommand[]

SQL commands and optional parameter sets.

Returns

Promise<BatchQueryResult>

A promise of the total affected row count.


loadFile()

loadFile(dbName, location): FileLoadResult

Defined in: specs/NitroSQLite.nitro.ts:95

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

FileLoadResult

Number of executed commands and affected rows.


loadFileAsync()

loadFileAsync(dbName, location): Promise<FileLoadResult>

Defined in: specs/NitroSQLite.nitro.ts:101

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?): void

Defined in: specs/NitroSQLite.nitro.ts:23

Open or create a database synchronously.

Parameters

dbName

string

Database file name.

location?

string

Directory relative to the platform database directory.

Returns

void