ReadonlykindIdentifier for logging/diagnostics (e.g., 'better-sqlite3', 'postgres').
ReadonlycapabilitiesCapability flags indicating supported features.
Opens the database. A second call while the first is still opening waits for it, and a call on an open adapter returns at once.
Optionaloptions: StorageOpenOptionsExecutes a mutation statement (INSERT, UPDATE, DELETE).
SQL statement to execute
Optionalparameters: StorageParametersOptional parameters for the statement
Metadata about affected rows
Retrieves a single row (or null if none found).
SQL SELECT statement
Optionalparameters: StorageParametersOptional parameters for the statement
First row or null if no results
Retrieves all rows returned by the statement.
WARNING: For large result sets, this loads everything into memory. Consider using streaming (if supported) for large queries.
SQL SELECT statement
Optionalparameters: StorageParametersOptional parameters for the statement
Array of all matching rows (empty array if none)
Executes a script containing multiple SQL statements.
Statements are typically delimited by semicolons. This is useful for running migrations or initialization scripts. No results are returned.
SQL script with multiple statements
Executes a callback within a database transaction.
Callbacks run one at a time, since every transaction shares the one connection. The callback's statements go through the handle it receives; a statement issued through the adapter itself while the callback runs waits until the transaction ends, so a callback must not await one.
Closes the database and the plugin's connection to it, so the database can be opened again, by this adapter or another one. A call made while a close is running waits for that close, so a caller that awaited either call can open the database again at once.
Adapter using @capacitor-community/sqlite for native mobile targets.
It opens its database through the plugin's SQLiteConnection, one for every adapter in the page, and close() closes the plugin's connection too, so the database can be opened again. One adapter at a time holds a database: a second open() of the same database fails while the first adapter has it, and so does an open() of a database whose connection the plugin holds for anything else; the adapter closes no connection it did not open. The plugin drops a trailing ".db" from a name, so
notes.dbandnotesare one database.Transactions use the plugin's beginTransaction, commitTransaction and rollbackTransaction (plugin 5.0.7 and later). The plugin runs every other execute and run call in a transaction of its own, which cannot nest in an open one, so the statements of a transaction's callback go to the plugin with
transactionfalse. A PRAGMA statement goes through the plugin's query(), outside that transaction of the plugin's own: in a run() call, or at the start or the end of an exec() script.The plugin turns foreign keys on when it opens a database, on Android, iOS and Electron.
foreignKeys: falsein the open options turns them off.