@ionic-native/sqlite
Version:
Ionic Native - Native plugins for ionic apps
136 lines (135 loc) • 3.4 kB
TypeScript
export interface SQLiteDatabaseConfig {
/**
* Name of the database. Example: 'my.db'
*/
name: string;
/**
* Location of the database. Example: 'default'
*/
location?: string;
/**
* iOS Database Location. Example: 'Library'
*/
iosDatabaseLocation?: string;
}
/**
* @hidden
*/
export declare class SQLiteObject {
_objectInstance: any;
constructor(_objectInstance: any);
databaseFeatures: any;
addTransaction(transaction: any): void;
/**
* @param fn {any}
* @returns {Promise<any>}
*/
transaction(fn: any): Promise<any>;
/**
* @param fn {any}
* @returns {Promise<any>}
*/
readTransaction(fn: any): Promise<any>;
startNextTransaction(): void;
/**
* @returns {Promise<any>}
*/
close(): Promise<any>;
start(): void;
/**
* Execute SQL on the opened database. Note, you must call `openDatabase` first, and
* ensure it resolved and successfully opened the database.
*/
executeSql(statement: string, params: any): Promise<any>;
/**
* @param sql
* @param values
* @returns {Promise<any>}
*/
addStatement(sql: any, values: any): Promise<any>;
/**
* @param sqlStatements {any}
* @returns {Promise<any>}
*/
sqlBatch(sqlStatements: any): Promise<any>;
abortallPendingTransactions(): void;
/**
@param handler
@param response
*/
handleStatementSuccess(handler: any, response: any): void;
/**
* @param handler
* @param response
*/
handleStatementFailure(handler: any, response: any): void;
run(): void;
/**
* @param txFailure
*/
abort(txFailure: any): void;
finish(): void;
/**
* @param sqlerror
*/
abortFromQ(sqlerror: any): void;
}
/**
* @name SQLite
*
* @description
* Access SQLite databases on the device.
*
* @usage
*
* ```typescript
* import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
*
* constructor(private sqlite: SQLite) { }
*
* ...
*
* this.sqlite.create({
* name: 'data.db',
* location: 'default'
* })
* .then((db: SQLiteObject) => {
*
*
* db.executeSql('create table danceMoves(name VARCHAR(32))', {})
* .then(() => console.log('Executed SQL'))
* .catch(e => console.log(e));
*
*
* })
* .catch(e => console.log(e));
*
* ```
*
* @classes
* SQLiteObject
* @interfaces
* SQLiteDatabaseConfig
*/
export declare class SQLite {
/**
* 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 config {SQLiteDatabaseConfig} database configuration
* @return Promise<SQLiteObject>
*/
create(config: SQLiteDatabaseConfig): Promise<SQLiteObject>;
/**
* Verify that both the Javascript and native part of this plugin are installed in your application
* @returns {Promise<any>}
*/
echoTest(): Promise<any>;
/**
* Deletes a database
* @param config {SQLiteDatabaseConfig} database configuration
* @returns {Promise<any>}
*/
deleteDatabase(config: SQLiteDatabaseConfig): Promise<any>;
}