Skip to content

Latest commit

 

History

History
621 lines (376 loc) · 16.8 KB

APIDBConnection.md

File metadata and controls

621 lines (376 loc) · 16.8 KB


API DB CONNECTION DOCUMENTATION

@capacitor-community/sqlite

SQLite DB Connection Wrapper

Methods Index

API DB Connection Wrapper

SQLiteDBConnection Interface

getConnectionDBName()

getConnectionDBName() => string

Get SQLite DB Connection DB name

Returns: string

Since: 2.9.0 refactor


getConnectionReadOnly()

getConnectionReadOnly() => boolean

Get SQLite DB Connection read-only mode

Returns: boolean

Since: 4.1.0


open()

open() => Promise<void>

Open a SQLite DB Connection

Since: 2.9.0 refactor


close()

close() => Promise<void>

Close a SQLite DB Connection

Since: 2.9.0 refactor


beginTransaction()

beginTransaction() => Promise<capSQLiteChanges>

Begin Database Transaction

Returns: Promise<capSQLiteChanges>

Since: 5.0.7


commitTransaction()

commitTransaction() => Promise<capSQLiteChanges>

Commit Database Transaction

Returns: Promise<capSQLiteChanges>

Since: 5.0.7


rollbackTransaction()

rollbackTransaction() => Promise<capSQLiteChanges>

Rollback Database Transaction

Returns: Promise<capSQLiteChanges>

Since: 5.0.7


isTransactionActive()

isTransactionActive() => Promise<capSQLiteResult>

Is Database Transaction Active

Returns: Promise<capSQLiteResult>

Since: 5.0.7


getUrl()

getUrl() => Promise<capSQLiteUrl>

Get Database Url

Returns: Promise<capSQLiteUrl>

Since: 3.3.3-4


getVersion()

getVersion() => Promise<capVersionResult>

Get the a SQLite DB Version

Returns: Promise<capVersionResult>

Since: 3.2.0


loadExtension(...)

loadExtension(path: string) => Promise<void>

Load a SQlite extension

Param Type Description
path string :SQlite extension path

Since: 5.0.6


enableLoadExtension(...)

enableLoadExtension(toggle: boolean) => Promise<void>

Enable Or Disable Extension Loading

Param Type Description
toggle boolean true:on false:off

Since: 5.0.6


execute(...)

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

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

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

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

isExists() => Promise<capSQLiteResult>

Check if a SQLite DB Connection exists

Returns: Promise<capSQLiteResult>

Since: 2.9.0 refactor


isDBOpen()

isDBOpen() => Promise<capSQLiteResult>

Check if a SQLite database is opened

Returns: Promise<capSQLiteResult>

Since: 3.0.0-beta.5


isTable(...)

isTable(table: string) => Promise<capSQLiteResult>

Check if a table exists

Param Type
table string

Returns: Promise<capSQLiteResult>

Since: 3.0.0-beta.5


getTableList()

getTableList() => Promise<DBSQLiteValues>

Get database's table list

Returns: Promise<DBSQLiteValues>

Since: 3.4.2-3


delete()

delete() => Promise<void>

Delete a SQLite DB Connection

Since: 2.9.0 refactor


createSyncTable()

createSyncTable() => Promise<capSQLiteChanges>

Create a synchronization table

Returns: Promise<capSQLiteChanges>

Since: 2.9.0 refactor


setSyncDate(...)

setSyncDate(syncdate: string) => Promise<void>

Set the synchronization date

Param Type
syncdate string

Since: 2.9.0 refactor


getSyncDate()

getSyncDate() => Promise<string>

Get the synchronization date

Returns: Promise<string>

Since: 2.9.0 refactor


exportToJson(...)

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

deleteExportedRows() => Promise<void>

Remove rows with sql_deleted = 1 after an export

Since: 3.4.3-2


executeTransaction(...)

executeTransaction(txn: capTask[], isSQL92: boolean) => Promise<capSQLiteChanges>
Param Type
txn capTask[]
isSQL92 boolean

Returns: Promise<capSQLiteChanges>

Since: 3.4.0


Interfaces

capSQLiteChanges

Prop Type Description
changes Changes a returned Changes

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

capSQLiteResult

Prop Type Description
result boolean result set to true when successful else false

capSQLiteUrl

Prop Type Description
url string a returned url

capVersionResult

Prop Type Description
version number Number returned

DBSQLiteValues

Prop Type Description
values any[] the data values list as an Array

capSQLiteSet

Prop Type Description
statement string A statement
values any[] the data values list as an Array

capSQLiteJson

Prop Type Description
export JsonSQLite an export JSON object

JsonSQLite

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)

JsonTable

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

JsonColumn

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

JsonIndex

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

JsonTrigger

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

JsonView

Prop Type Description
name string The view name
value string The view create statement

capTask

Prop Type Description
statement string A SQLite statement
values any[] A set of values to bind to the statement (optional)