@capacitor-community/sqlite
SQLite Connection Wrapper
initWebStore()saveToStore(...)getFromLocalDiskToStore(...)saveToLocalDisk(...)echo(...)isSecretStored()setEncryptionSecret(...)changeEncryptionSecret(...)clearEncryptionSecret()checkEncryptionSecret(...)addUpgradeStatement(...)createConnection(...)isConnection(...)retrieveConnection(...)retrieveAllConnections()closeConnection(...)closeAllConnections()checkConnectionsConsistency()getNCDatabasePath(...)createNCConnection(...)closeNCConnection(...)isNCConnection(...)retrieveNCConnection(...)importFromJson(...)isJsonValid(...)copyFromAssets(...)getFromHTTPRequest(...)isDatabaseEncrypted(...)isInConfigEncryption()isInConfigBiometricAuth()isDatabase(...)isNCDatabase(...)getDatabaseList()getMigratableDbList(...)addSQLiteSuffix(...)deleteOldDatabases(...)moveDatabasesAndAddSuffix(...)- Interfaces
SQLiteConnection Interface
initWebStore() => Promise<void>Init the web store
Since: 3.2.3-1
saveToStore(database: string) => Promise<void>Save the datbase to the web store
| Param | Type |
|---|---|
database |
string |
Since: 3.2.3-1
getFromLocalDiskToStore(overwrite: boolean) => Promise<void>Get database from local disk and save it to store
| Param | Type | Description |
|---|---|---|
overwrite |
boolean |
: boolean |
Since: 4.6.3
saveToLocalDisk(database: string) => Promise<void>Save database to local disk
| Param | Type | Description |
|---|---|---|
database |
string |
: string |
Since: 4.6.3
echo(value: string) => Promise<capEchoResult>Echo a value
| Param | Type |
|---|---|
value |
string |
Returns: Promise<capEchoResult>
Since: 2.9.0 refactor
isSecretStored() => Promise<capSQLiteResult>Check if a secret is stored
Returns: Promise<capSQLiteResult>
Since: 3.0.0-beta.13
setEncryptionSecret(passphrase: string) => Promise<void>Set a passphrase in a secure store
| Param | Type |
|---|---|
passphrase |
string |
Since: 3.0.0-beta.13
changeEncryptionSecret(passphrase: string, oldpassphrase: string) => Promise<void>Change the passphrase in a secure store
| Param | Type |
|---|---|
passphrase |
string |
oldpassphrase |
string |
Since: 3.0.0-beta.13
clearEncryptionSecret() => Promise<void>Clear the passphrase in a secure store
Since: 3.5.1
checkEncryptionSecret(passphrase: string) => Promise<capSQLiteResult>Check the passphrase stored in a secure store
| Param | Type |
|---|---|
passphrase |
string |
Returns: Promise<capSQLiteResult>
Since: 4.6.1
addUpgradeStatement(database: string, upgrade: capSQLiteVersionUpgrade[]) => Promise<void>Add the upgrade Statement for database version upgrading
| Param | Type |
|---|---|
database |
string |
upgrade |
capSQLiteVersionUpgrade[] |
Since: 5.6.4
createConnection(database: string, encrypted: boolean, mode: string, version: number, readonly: boolean) => Promise<SQLiteDBConnection>Create a connection to a database
| Param | Type |
|---|---|
database |
string |
encrypted |
boolean |
mode |
string |
version |
number |
readonly |
boolean |
Returns: Promise<SQLiteDBConnection>
Since: 2.9.0 refactor
isConnection(database: string, readonly: boolean) => Promise<capSQLiteResult>Check if a connection exists
| Param | Type |
|---|---|
database |
string |
readonly |
boolean |
Returns: Promise<capSQLiteResult>
Since: 3.0.0-beta.5
retrieveConnection(database: string, readonly: boolean) => Promise<SQLiteDBConnection>Retrieve an existing database connection
| Param | Type |
|---|---|
database |
string |
readonly |
boolean |
Returns: Promise<SQLiteDBConnection>
Since: 2.9.0 refactor
retrieveAllConnections() => Promise<Map<string, SQLiteDBConnection>>Retrieve all database connections
Returns: Promise<Map<string, SQLiteDBConnection>>
Since: 2.9.0 refactor
closeConnection(database: string, readonly: boolean) => Promise<void>Close a database connection
| Param | Type |
|---|---|
database |
string |
readonly |
boolean |
Since: 2.9.0 refactor
closeAllConnections() => Promise<void>Close all database connections
Since: 2.9.0 refactor
checkConnectionsConsistency() => Promise<capSQLiteResult>Check the consistency between Js Connections and Native Connections if inconsistency all connections are removed
Returns: Promise<capSQLiteResult>
Since: 3.0.0-beta.10
getNCDatabasePath(path: string, database: string) => Promise<capNCDatabasePathResult>get a non-conformed database path
| Param | Type |
|---|---|
path |
string |
database |
string |
Returns: Promise<capNCDatabasePathResult>
Since: 3.3.3-1
createNCConnection(databasePath: string, version: number) => Promise<SQLiteDBConnection>Create a non-conformed database connection
| Param | Type |
|---|---|
databasePath |
string |
version |
number |
Returns: Promise<SQLiteDBConnection>
Since: 3.3.3-1
closeNCConnection(databasePath: string) => Promise<void>Close a non-conformed database connection
| Param | Type |
|---|---|
databasePath |
string |
Since: 3.3.3-1
isNCConnection(databasePath: string) => Promise<capSQLiteResult>Check if a non-conformed databaseconnection exists
| Param | Type |
|---|---|
databasePath |
string |
Returns: Promise<capSQLiteResult>
Since: 3.3.3-1
retrieveNCConnection(databasePath: string) => Promise<SQLiteDBConnection>Retrieve an existing non-conformed database connection
| Param | Type |
|---|---|
databasePath |
string |
Returns: Promise<SQLiteDBConnection>
Since: 3.3.3-1
importFromJson(jsonstring: string) => Promise<capSQLiteChanges>Import a database From a JSON
| Param | Type | Description |
|---|---|---|
jsonstring |
string |
string |
Returns: Promise<capSQLiteChanges>
Since: 2.9.0 refactor
isJsonValid(jsonstring: string) => Promise<capSQLiteResult>Check the validity of a JSON Object
| Param | Type | Description |
|---|---|---|
jsonstring |
string |
string |
Returns: Promise<capSQLiteResult>
Since: 2.9.0 refactor
copyFromAssets(overwrite?: boolean | undefined) => Promise<void>Copy databases from public/assets/databases folder to application databases folder
| Param | Type | Description |
|---|---|---|
overwrite |
boolean |
since 3.2.5-2 |
Since: 2.9.0 refactor
getFromHTTPRequest(url?: string | undefined, overwrite?: boolean | undefined) => Promise<void>| Param | Type |
|---|---|
url |
string |
overwrite |
boolean |
Since: 4.1.1
isDatabaseEncrypted(database: string) => Promise<capSQLiteResult>Check if a SQLite database is encrypted
| Param | Type |
|---|---|
database |
string |
Returns: Promise<capSQLiteResult>
Since: 4.6.2-2
isInConfigEncryption() => Promise<capSQLiteResult>Check encryption value in capacitor.config
Returns: Promise<capSQLiteResult>
Since: 4.6.2-2
isInConfigBiometricAuth() => Promise<capSQLiteResult>Check encryption value in capacitor.config
Returns: Promise<capSQLiteResult>
Since: 4.6.2-2
isDatabase(database: string) => Promise<capSQLiteResult>Check if a database exists
| Param | Type |
|---|---|
database |
string |
Returns: Promise<capSQLiteResult>
Since: 3.0.0-beta.5
isNCDatabase(databasePath: string) => Promise<capSQLiteResult>Check if a non conformed database exists
| Param | Type |
|---|---|
databasePath |
string |
Returns: Promise<capSQLiteResult>
Since: 3.3.3-1
getDatabaseList() => Promise<capSQLiteValues>Get the database list
Returns: Promise<capSQLiteValues>
Since: 3.0.0-beta.5
getMigratableDbList(folderPath?: string | undefined) => Promise<capSQLiteValues>Get the Migratable database list
| Param | Type | Description |
|---|---|---|
folderPath |
string |
: string // only iOS & Android since 3.2.4-2 |
Returns: Promise<capSQLiteValues>
Since: 3.0.0-beta.5
addSQLiteSuffix(folderPath?: string | undefined, dbNameList?: string[] | undefined) => Promise<void>Add SQLIte Suffix to existing databases
| Param | Type | Description |
|---|---|---|
folderPath |
string |
|
dbNameList |
string[] |
since 3.2.4-1 |
Since: 3.0.0-beta.5
deleteOldDatabases(folderPath?: string | undefined, dbNameList?: string[] | undefined) => Promise<void>Delete Old Cordova databases
| Param | Type | Description |
|---|---|---|
folderPath |
string |
|
dbNameList |
string[] |
since 3.2.4-1 |
Since: 3.0.0-beta.5
moveDatabasesAndAddSuffix(folderPath?: string | undefined, dbNameList?: string[] | undefined) => Promise<void>Moves databases to the location the plugin can read them, and adds sqlite suffix This resembles calling addSQLiteSuffix and deleteOldDatabases, but it is more performant as it doesn't copy but moves the files
| Param | Type | Description |
|---|---|---|
folderPath |
string |
the origin from where to move the databases |
dbNameList |
string[] |
the names of the databases to move, check out the getMigratableDbList to get a list, an empty list will result in copying all the databases with '.db' extension. |
| Prop | Type | Description |
|---|---|---|
value |
string |
String returned |
| Prop | Type | Description |
|---|---|---|
result |
boolean |
result set to true when successful else false |
| Prop | Type |
|---|---|
toVersion |
number |
statements |
string[] |
| Prop | Type |
|---|---|
size |
number |
| Method | Signature |
|---|---|
| clear | () => void |
| delete | (key: K) => boolean |
| forEach | (callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any) => void |
| get | (key: K) => V | undefined |
| has | (key: K) => boolean |
| set | (key: K, value: V) => this |
| Prop | Type | Description |
|---|---|---|
path |
string |
String returned |
| 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 |
|---|---|---|
values |
any[] |
the data values list as an Array iOS the first row is the returned ios_columns name list |
