Create and initialize a database from a full configuration object, or connection string
Optional
callback: ErrorCallbackOptional
mode: numberOptional
callback: ErrorCallbackRuns the SQL query with the specified parameters and calls the callback with all result rows afterwards. The function returns the Database object to allow for function chaining. The parameters are the same as the Database#run function, with the following differences: The signature of the callback is function(err, rows) {}. rows is an array. If the result set is empty, it will be an empty array, otherwise it will have an object for each result row which in turn contains the values of that row, like the Database#get function. Note that it first retrieves all result rows and stores them in memory. For queries that have potentially large result sets, use the Database#each function to retrieve all rows or Database#prepare followed by multiple Statement#get calls to retrieve a previously unknown amount of rows.
Optional
callback: RowsCallback<T>Optional
callback: RowsCallback<T>If the optional callback is provided, this function will be called when the database was closed successfully or when an error occurred. The first argument is an error object. When it is null, closing succeeded. If no callback is provided and an error occurred, an error event with the error object as the only parameter will be emitted on the database object. If closing succeeded, a close event with no parameters is emitted, regardless of whether a callback was provided or not.
Optional
callback: ErrorCallbackRuns the SQL query with the specified parameters and calls the callback once for each result row. The function returns the Database object to allow for function chaining. The parameters are the same as the Database#run function, with the following differences: The signature of the callback is function(err, row) {}. If the result set succeeds but is empty, the callback is never called. In all other cases, the callback is called once for every retrieved row. The order of calls correspond exactly to the order of rows in the result set. After all row callbacks were called, the completion callback will be called if present. The first argument is an error object, and the second argument is the number of retrieved rows. If you specify only one function, it will be treated as row callback, if you specify two, the first (== second to last) function will be the row callback, the last function will be the completion callback. If you know that a query only returns a very limited number of rows, it might be more convenient to use Database#all to retrieve all rows at once. There is currently no way to abort execution.
Optional
callback: RowCallback<T>Optional
complete: RowCountCallbackOptional
callback: RowCallback<T>Optional
complete: RowCountCallbackRuns all SQL queries in the supplied string. No result rows are retrieved. The function returns the Database object to allow for function chaining. If a query fails, no subsequent statements will be executed (wrap it in a transaction if you want all or none to be executed). When all statements have been executed successfully, or when an error occurs, the callback function is called, with the first parameter being either null or an error object. When no callback is provided and an error occurs, an error event will be emitted on the database object.
Optional
callback: ErrorCallbackRuns the SQL query with the specified parameters and calls the callback with
a subsequent result row. The function returns the Database object to allow for
function chaining. The parameters are the same as the Database#run function,
with the following differences: The signature of the callback is function(err, row) {}
.
If the result set is empty, the second parameter is undefined, otherwise it is an
object containing the values for the first row. The property names correspond to
the column names of the result set. It is impossible to access them by column index;
the only supported way is by column name.
Optional
callback: RowCallback<T>Optional
callback: RowCallback<T>Returns the configuration with which this database was opened. The configuration is readonly and cannot be changed as there may be multiple connections using the same configuration.
A configuration object
PubSub class provides a Pub/Sub real-time updates and notifications system to allow multiple applications to communicate with each other asynchronously. It allows applications to subscribe to tables and receive notifications whenever data changes in the database table. It also enables sending messages to anyone subscribed to a specific channel.
A PubSub object
Loads a compiled SQLite extension into the database connection object.
Optional
callback: ErrorCallbackIf provided, this function will be called when the extension was loaded successfully or when an error occurred. The first argument is an error object. When it is null, loading succeeded. If no callback is provided and an error occurred, an error event with the error object as the only parameter will be emitted on the database object.
Prepares the SQL statement and optionally binds the specified parameters and calls the callback when done. The function returns a Statement object. When preparing was successful, the first and only argument to the callback is null, otherwise it is the error object. When bind parameters are supplied, they are bound to the prepared statement before calling the callback.
Rest
...params: any[]Runs the SQL query with the specified parameters and calls the callback afterwards. The callback will contain the results passed back from the server, for example in the case of an update or insert, these would contain the number of rows modified, etc. It does not retrieve any result data. The function returns the Database object for which it was called to allow for function chaining.
Optional
callback: ResultsCallback<T>Optional
callback: ResultsCallback<T>Sql is a promise based API for executing SQL statements. You can pass a simple string with a SQL statement or a template string using backticks and parameters in ${parameter} format. These parameters will be properly escaped and quoted like when using a prepared statement.
A sql string or a template string in backticks
format
Rest
...values: any[]An array of rows in case of selections or an object with metadata in case of insert, update, delete.
Creating a Database object automatically opens a connection to the SQLite database. When the connection is established the Database object emits an open event and calls the optional provided callback. If the connection cannot be established an error event will be emitted and the optional callback is called with the error information.