SQLite

$ ionic plugin add cordova-sqlite-storage

Repo:https://github.com/litehelpers/Cordova-sqlite-storage

Access SQLite databases on the device.

Usage

import { SQLite } from 'ionic-native';

// OPTION A: Use static constructor
SQLite.openDatabase({
  name: 'data.db',
  location: 'default'
})
  .then((db: SQLite) => {

    db.executeSql('create table danceMoves(name VARCHAR(32))', []).then(() => {}).catch(() => {});

  })
  .catch(error => console.error('Error opening database', error));


// OPTION B: Create a new instance of SQLite
let db = new SQLite();
db.openDatabase({
  name: 'data.db',
  location: 'default' // the location field is required
}).then(() => {
  db.executeSql('create table danceMoves(name VARCHAR(32))', []).then(() => {

  }, (err) => {
    console.error('Unable to execute sql: ', err);
  });
}, (err) => {
  console.error('Unable to open database: ', err);
});

Static Members

openDatabase()

echoTest()

Returns:Promise<any>

deleteDatabase(first)

Param Type Details
first

Returns:Promise<any>

Instance Members

databaseFeatures

openDatabase(config)

Open or create a SQLite database file.

See the plugin docs for an explanation of all options: https://github.com/litehelpers/Cordova-sqlite-storage#opening-a-database

Param Type Details
config the config for opening the database.

addTransaction()

transaction(fn)

Param Type Details
fn any

Returns:Promise<any>

readTransaction(fn)

Param Type Details
fn any

Returns:Promise<any>

startNextTransaction()

close()

Returns:Promise<any>

start()

executeSql()

Execute SQL on the opened database. Note, you must callopenDatabasefirst, and ensure it resolved and successfully opened the database.

addStatement(sql, values)

Param Type Details
sql
values

Returns:Promise<any>

sqlBatch(sqlStatements)

Param Type Details
sqlStatements any

Returns:Promise<any>

abortallPendingTransactions()

handleStatementSuccess(handler, response)

Param Type Details
handler
response

handleStatementFailure(handler, response)

Param Type Details
handler
response

run()

abort(txFailure)

Param Type Details
txFailure

finish()

abortFromQ(sqlerror)

Param Type Details
sqlerror

results matching ""

    No results matching ""