The Database
class represents a connection that can prepare and execute SQL statements.
Creates a new database connection.
Param | Type | Description |
---|---|---|
path | string |
Path to the database file |
options | object |
Options. |
The path
parameter points to the SQLite database file to open. If the file pointed to by path
does not exists, it will be created.
To open an in-memory database, please pass :memory:
as the path
parameter.
You can use the options
parameter to specify various options. Options supported by the parameter are:
syncUrl
: open the database as embedded replica synchronizing from the provided URL.syncPeriod
: synchronize the database periodically everysyncPeriod
seconds.authToken
: authentication token for the provider URL (optional).
The function returns a Database
object.
Prepares a SQL statement for execution.
Param | Type | Description |
---|---|---|
sql | string |
The SQL statement string to prepare. |
The function returns a Statement
object.
Returns a function that runs the given function in a transaction.
Param | Type | Description |
---|---|---|
function | function |
The function to run in a transaction. |
This function is currently not supported.
This function is currently not supported.
This function is currently not supported.
This function is currently not supported.
This function is currently not supported.
This function is currently not supported.
Loads a SQLite3 extension
Executes a SQL statement.
Param | Type | Description |
---|---|---|
sql | string |
The SQL statement string to execute. |
Closes the database connection.
Executes the SQL statement and returns an info object.
Param | Type | Description |
---|---|---|
bindParameters | array of objects |
The bind parameters for executing the statement. |
The returned info object contains two properties: changes
that describes the number of modified rows and info.lastInsertRowid
that represents the rowid
of the last inserted row.
Executes the SQL statement and returns the first row.
Param | Type | Description |
---|---|---|
bindParameters | array of objects |
The bind parameters for executing the statement. |
Executes the SQL statement and returns an array of the resulting rows.
Param | Type | Description |
---|---|---|
bindParameters | array of objects |
The bind parameters for executing the statement. |
Executes the SQL statement and returns an iterator to the resulting rows.
Param | Type | Description |
---|---|---|
bindParameters | array of objects |
The bind parameters for executing the statement. |
This function is currently not supported.
This function is currently not supported.
Toggle raw mode.
Param | Type | Description |
---|---|---|
rawMode | boolean |
Enable or disable raw mode. If you don't pass the parameter, raw mode is enabled. |
This function enables or disables raw mode. Prepared statements return objects by default, but if raw mode is enabled, the functions return arrays instead.
Returns the columns in the result set returned by this prepared statement.
This function is currently not supported.