@capacitor-community/sqlite
SQLite DB Connection Wrapper
getConnectionDBName()
getConnectionReadOnly()
open()
close()
beginTransaction()
commitTransaction()
rollbackTransaction()
isTransactionActive()
getUrl()
getVersion()
loadExtension(...)
enableLoadExtension(...)
execute(...)
query(...)
run(...)
executeSet(...)
isExists()
isDBOpen()
isTable(...)
getTableList()
delete()
createSyncTable()
setSyncDate(...)
getSyncDate()
exportToJson(...)
deleteExportedRows()
executeTransaction(...)
- Interfaces
SQLiteDBConnection Interface
getConnectionDBName() => string
Get SQLite DB Connection DB name
Returns: string
Since: 2.9.0 refactor
getConnectionReadOnly() => boolean
Get SQLite DB Connection read-only mode
Returns: boolean
Since: 4.1.0
open() => Promise<void>
Open a SQLite DB Connection
Since: 2.9.0 refactor
close() => Promise<void>
Close a SQLite DB Connection
Since: 2.9.0 refactor
beginTransaction() => Promise<capSQLiteChanges>
Begin Database Transaction
Returns: Promise<capSQLiteChanges>
Since: 5.0.7
commitTransaction() => Promise<capSQLiteChanges>
Commit Database Transaction
Returns: Promise<capSQLiteChanges>
Since: 5.0.7
rollbackTransaction() => Promise<capSQLiteChanges>
Rollback Database Transaction
Returns: Promise<capSQLiteChanges>
Since: 5.0.7
isTransactionActive() => Promise<capSQLiteResult>
Is Database Transaction Active
Returns: Promise<capSQLiteResult>
Since: 5.0.7
getUrl() => Promise<capSQLiteUrl>
Get Database Url
Returns: Promise<capSQLiteUrl>
Since: 3.3.3-4
getVersion() => Promise<capVersionResult>
Get the a SQLite DB Version
Returns: Promise<capVersionResult>
Since: 3.2.0
loadExtension(path: string) => Promise<void>
Load a SQlite extension
Param | Type | Description |
---|---|---|
path |
string |
:SQlite extension path |
Since: 5.0.6
enableLoadExtension(toggle: boolean) => Promise<void>
Enable Or Disable Extension Loading
Param | Type | Description |
---|---|---|
toggle |
boolean |
true:on false:off |
Since: 5.0.6
execute(statements: string, transaction?: boolean | undefined, isSQL92?: boolean | undefined) => Promise<capSQLiteChanges>
Execute SQLite DB Connection Statements
Param | Type | Description |
---|---|---|
statements |
string |
|
transaction |
boolean |
(optional) |
isSQL92 |
boolean |
(optional) |
Returns: Promise<capSQLiteChanges>
Since: 2.9.0 refactor
query(statement: string, values?: any[] | undefined, isSQL92?: boolean | undefined) => Promise<DBSQLiteValues>
Execute SQLite DB Connection Query
Param | Type | Description |
---|---|---|
statement |
string |
|
values |
any[] |
(optional) |
isSQL92 |
boolean |
(optional) |
Returns: Promise<DBSQLiteValues>
Since: 2.9.0 refactor
run(statement: string, values?: any[] | undefined, transaction?: boolean | undefined, returnMode?: string | undefined, isSQL92?: boolean | undefined) => Promise<capSQLiteChanges>
Execute SQLite DB Connection Raw Statement
Param | Type | Description |
---|---|---|
statement |
string |
|
values |
any[] |
(optional) |
transaction |
boolean |
(optional) |
returnMode |
string |
(optional) |
isSQL92 |
boolean |
(optional) |
Returns: Promise<capSQLiteChanges>
Since: 2.9.0 refactor
executeSet(set: capSQLiteSet[], transaction?: boolean | undefined, returnMode?: string | undefined, isSQL92?: boolean | undefined) => Promise<capSQLiteChanges>
Execute SQLite DB Connection Set
Param | Type | Description |
---|---|---|
set |
capSQLiteSet[] |
|
transaction |
boolean |
(optional) |
returnMode |
string |
(optional) |
isSQL92 |
boolean |
(optional) |
Returns: Promise<capSQLiteChanges>
Since: 2.9.0 refactor
isExists() => Promise<capSQLiteResult>
Check if a SQLite DB Connection exists
Returns: Promise<capSQLiteResult>
Since: 2.9.0 refactor
isDBOpen() => Promise<capSQLiteResult>
Check if a SQLite database is opened
Returns: Promise<capSQLiteResult>
Since: 3.0.0-beta.5
isTable(table: string) => Promise<capSQLiteResult>
Check if a table exists
Param | Type |
---|---|
table |
string |
Returns: Promise<capSQLiteResult>
Since: 3.0.0-beta.5
getTableList() => Promise<DBSQLiteValues>
Get database's table list
Returns: Promise<DBSQLiteValues>
Since: 3.4.2-3
delete() => Promise<void>
Delete a SQLite DB Connection
Since: 2.9.0 refactor
createSyncTable() => Promise<capSQLiteChanges>
Create a synchronization table
Returns: Promise<capSQLiteChanges>
Since: 2.9.0 refactor
setSyncDate(syncdate: string) => Promise<void>
Set the synchronization date
Param | Type |
---|---|
syncdate |
string |
Since: 2.9.0 refactor
getSyncDate() => Promise<string>
Get the synchronization date
Returns: Promise<string>
Since: 2.9.0 refactor
exportToJson(mode: string, encrypted?: boolean | undefined) => Promise<capSQLiteJson>
Export the given database to a JSON Object
Param | Type | Description |
---|---|---|
mode |
string |
|
encrypted |
boolean |
(optional) since 5.0.8 not for Web platform |
Returns: Promise<capSQLiteJson>
Since: 2.9.0 refactor
deleteExportedRows() => Promise<void>
Remove rows with sql_deleted = 1 after an export
Since: 3.4.3-2
executeTransaction(txn: capTask[], isSQL92: boolean) => Promise<capSQLiteChanges>
Param | Type |
---|---|
txn |
capTask[] |
isSQL92 |
boolean |
Returns: Promise<capSQLiteChanges>
Since: 3.4.0
Prop | Type | Description |
---|---|---|
changes |
Changes |
a returned Changes |
Prop | Type | Description |
---|---|---|
changes |
number |
the number of changes from an execute or run command |
lastId |
number |
the lastId created from a run command |
values |
any[] |
values when RETURNING |
Prop | Type | Description |
---|---|---|
result |
boolean |
result set to true when successful else false |
Prop | Type | Description |
---|---|---|
url |
string |
a returned url |
Prop | Type | Description |
---|---|---|
version |
number |
Number returned |
Prop | Type | Description |
---|---|---|
values |
any[] |
the data values list as an Array |
Prop | Type | Description |
---|---|---|
statement |
string |
A statement |
values |
any[] |
the data values list as an Array |
Prop | Type | Description |
---|---|---|
export |
JsonSQLite |
an export JSON object |
Prop | Type | Description |
---|---|---|
database |
string |
The database name |
version |
number |
The database version |
overwrite |
boolean |
Delete the database prior to import (default false) |
encrypted |
boolean |
Set to true (database encryption) / false |
mode |
string |
* Set the mode ["full", "partial"] |
tables |
JsonTable[] |
* Array of Table (JsonTable) |
views |
JsonView[] |
* Array of View (JsonView) |
Prop | Type | Description |
---|---|---|
name |
string |
The database name |
schema |
JsonColumn[] |
* Array of Schema (JsonColumn) |
indexes |
JsonIndex[] |
* Array of Index (JsonIndex) |
triggers |
JsonTrigger[] |
* Array of Trigger (JsonTrigger) |
values |
any[][] |
* Array of Table data |
Prop | Type | Description |
---|---|---|
column |
string |
The column name |
value |
string |
The column data (type, unique, ...) |
foreignkey |
string |
The column foreign key constraints |
constraint |
string |
the column constraint |
Prop | Type | Description |
---|---|---|
name |
string |
The index name |
value |
string |
The value of the index can have the following formats: email email ASC email, MobileNumber email ASC, MobileNumber DESC |
mode |
string |
the mode (Optional) UNIQUE |
Prop | Type | Description |
---|---|---|
name |
string |
The trigger name |
timeevent |
string |
The trigger time event fired |
condition |
string |
The trigger condition |
logic |
string |
The logic of the trigger |
Prop | Type | Description |
---|---|---|
name |
string |
The view name |
value |
string |
The view create statement |
Prop | Type | Description |
---|---|---|
statement |
string |
A SQLite statement |
values |
any[] |
A set of values to bind to the statement (optional) |