APIConnection.md

March 27, 2024 ยท View on GitHub


API CONNECTION DOCUMENTATION

@capacitor-community/sqlite

SQLite Connection Wrapper

Methods Index

API Connection Wrapper

SQLiteConnection Interface

initWebStore()

initWebStore() => Promise<void>

Init the web store

Since: 3.2.3-1


saveToStore(...)

saveToStore(database: string) => Promise<void>

Save the datbase to the web store

ParamType
databasestring

Since: 3.2.3-1


getFromLocalDiskToStore(...)

getFromLocalDiskToStore(overwrite: boolean) => Promise<void>

Get database from local disk and save it to store

ParamTypeDescription
overwriteboolean: boolean

Since: 4.6.3


saveToLocalDisk(...)

saveToLocalDisk(database: string) => Promise<void>

Save database to local disk

ParamTypeDescription
databasestring: string

Since: 4.6.3


echo(...)

echo(value: string) => Promise<capEchoResult>

Echo a value

ParamType
valuestring

Returns: Promise<capEchoResult>

Since: 2.9.0 refactor


isSecretStored()

isSecretStored() => Promise<capSQLiteResult>

Check if a secret is stored

Returns: Promise<capSQLiteResult>

Since: 3.0.0-beta.13


setEncryptionSecret(...)

setEncryptionSecret(passphrase: string) => Promise<void>

Set a passphrase in a secure store

ParamType
passphrasestring

Since: 3.0.0-beta.13


changeEncryptionSecret(...)

changeEncryptionSecret(passphrase: string, oldpassphrase: string) => Promise<void>

Change the passphrase in a secure store

ParamType
passphrasestring
oldpassphrasestring

Since: 3.0.0-beta.13


clearEncryptionSecret()

clearEncryptionSecret() => Promise<void>

Clear the passphrase in a secure store

Since: 3.5.1


checkEncryptionSecret(...)

checkEncryptionSecret(passphrase: string) => Promise<capSQLiteResult>

Check the passphrase stored in a secure store

ParamType
passphrasestring

Returns: Promise<capSQLiteResult>

Since: 4.6.1


addUpgradeStatement(...)

addUpgradeStatement(database: string, upgrade: capSQLiteVersionUpgrade[]) => Promise<void>

Add the upgrade Statement for database version upgrading

ParamType
databasestring
upgradecapSQLiteVersionUpgrade[]

Since: 5.6.4


createConnection(...)

createConnection(database: string, encrypted: boolean, mode: string, version: number, readonly: boolean) => Promise<SQLiteDBConnection>

Create a connection to a database

ParamType
databasestring
encryptedboolean
modestring
versionnumber
readonlyboolean

Returns: Promise<SQLiteDBConnection>

Since: 2.9.0 refactor


isConnection(...)

isConnection(database: string, readonly: boolean) => Promise<capSQLiteResult>

Check if a connection exists

ParamType
databasestring
readonlyboolean

Returns: Promise<capSQLiteResult>

Since: 3.0.0-beta.5


retrieveConnection(...)

retrieveConnection(database: string, readonly: boolean) => Promise<SQLiteDBConnection>

Retrieve an existing database connection

ParamType
databasestring
readonlyboolean

Returns: Promise<SQLiteDBConnection>

Since: 2.9.0 refactor


retrieveAllConnections()

retrieveAllConnections() => Promise<Map<string, SQLiteDBConnection>>

Retrieve all database connections

Returns: Promise<Map<string, SQLiteDBConnection>>

Since: 2.9.0 refactor


closeConnection(...)

closeConnection(database: string, readonly: boolean) => Promise<void>

Close a database connection

ParamType
databasestring
readonlyboolean

Since: 2.9.0 refactor


closeAllConnections()

closeAllConnections() => Promise<void>

Close all database connections

Since: 2.9.0 refactor


checkConnectionsConsistency()

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(...)

getNCDatabasePath(path: string, database: string) => Promise<capNCDatabasePathResult>

get a non-conformed database path

ParamType
pathstring
databasestring

Returns: Promise<capNCDatabasePathResult>

Since: 3.3.3-1


createNCConnection(...)

createNCConnection(databasePath: string, version: number) => Promise<SQLiteDBConnection>

Create a non-conformed database connection

ParamType
databasePathstring
versionnumber

Returns: Promise<SQLiteDBConnection>

Since: 3.3.3-1


closeNCConnection(...)

closeNCConnection(databasePath: string) => Promise<void>

Close a non-conformed database connection

ParamType
databasePathstring

Since: 3.3.3-1


isNCConnection(...)

isNCConnection(databasePath: string) => Promise<capSQLiteResult>

Check if a non-conformed databaseconnection exists

ParamType
databasePathstring

Returns: Promise<capSQLiteResult>

Since: 3.3.3-1


retrieveNCConnection(...)

retrieveNCConnection(databasePath: string) => Promise<SQLiteDBConnection>

Retrieve an existing non-conformed database connection

ParamType
databasePathstring

Returns: Promise<SQLiteDBConnection>

Since: 3.3.3-1


importFromJson(...)

importFromJson(jsonstring: string) => Promise<capSQLiteChanges>

Import a database From a JSON

ParamTypeDescription
jsonstringstringstring

Returns: Promise<capSQLiteChanges>

Since: 2.9.0 refactor


isJsonValid(...)

isJsonValid(jsonstring: string) => Promise<capSQLiteResult>

Check the validity of a JSON Object

ParamTypeDescription
jsonstringstringstring

Returns: Promise<capSQLiteResult>

Since: 2.9.0 refactor


copyFromAssets(...)

copyFromAssets(overwrite?: boolean | undefined) => Promise<void>

Copy databases from public/assets/databases folder to application databases folder

ParamTypeDescription
overwritebooleansince 3.2.5-2

Since: 2.9.0 refactor


getFromHTTPRequest(...)

getFromHTTPRequest(url?: string | undefined, overwrite?: boolean | undefined) => Promise<void>
ParamType
urlstring
overwriteboolean

Since: 4.1.1


isDatabaseEncrypted(...)

isDatabaseEncrypted(database: string) => Promise<capSQLiteResult>

Check if a SQLite database is encrypted

ParamType
databasestring

Returns: Promise<capSQLiteResult>

Since: 4.6.2-2


isInConfigEncryption()

isInConfigEncryption() => Promise<capSQLiteResult>

Check encryption value in capacitor.config

Returns: Promise<capSQLiteResult>

Since: 4.6.2-2


isInConfigBiometricAuth()

isInConfigBiometricAuth() => Promise<capSQLiteResult>

Check encryption value in capacitor.config

Returns: Promise<capSQLiteResult>

Since: 4.6.2-2


isDatabase(...)

isDatabase(database: string) => Promise<capSQLiteResult>

Check if a database exists

ParamType
databasestring

Returns: Promise<capSQLiteResult>

Since: 3.0.0-beta.5


isNCDatabase(...)

isNCDatabase(databasePath: string) => Promise<capSQLiteResult>

Check if a non conformed database exists

ParamType
databasePathstring

Returns: Promise<capSQLiteResult>

Since: 3.3.3-1


getDatabaseList()

getDatabaseList() => Promise<capSQLiteValues>

Get the database list

Returns: Promise<capSQLiteValues>

Since: 3.0.0-beta.5


getMigratableDbList(...)

getMigratableDbList(folderPath?: string | undefined) => Promise<capSQLiteValues>

Get the Migratable database list

ParamTypeDescription
folderPathstring: string // only iOS & Android since 3.2.4-2

Returns: Promise<capSQLiteValues>

Since: 3.0.0-beta.5


addSQLiteSuffix(...)

addSQLiteSuffix(folderPath?: string | undefined, dbNameList?: string[] | undefined) => Promise<void>

Add SQLIte Suffix to existing databases

ParamTypeDescription
folderPathstring
dbNameListstring[]since 3.2.4-1

Since: 3.0.0-beta.5


deleteOldDatabases(...)

deleteOldDatabases(folderPath?: string | undefined, dbNameList?: string[] | undefined) => Promise<void>

Delete Old Cordova databases

ParamTypeDescription
folderPathstring
dbNameListstring[]since 3.2.4-1

Since: 3.0.0-beta.5


moveDatabasesAndAddSuffix(...)

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

ParamTypeDescription
folderPathstringthe origin from where to move the databases
dbNameListstring[]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.

Interfaces

capEchoResult

PropTypeDescription
valuestringString returned

capSQLiteResult

PropTypeDescription
resultbooleanresult set to true when successful else false

capSQLiteVersionUpgrade

PropType
toVersionnumber
statementsstring[]

Map

PropType
sizenumber
MethodSignature
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

capNCDatabasePathResult

PropTypeDescription
pathstringString returned

capSQLiteChanges

PropTypeDescription
changesChangesa returned Changes

Changes

PropTypeDescription
changesnumberthe number of changes from an execute or run command
lastIdnumberthe lastId created from a run command
valuesany[]values when RETURNING

capSQLiteValues

PropTypeDescription
valuesany[]the data values list as an Array iOS the first row is the returned ios_columns name list