refactor(SQLite):
This commit is contained in:
parent
499e89e254
commit
9c25244bc6
@ -1,5 +1,8 @@
|
|||||||
import {CordovaInstance, Plugin, Cordova} from './plugin';
|
import { Cordova, CordovaInstance, Plugin } from './plugin';
|
||||||
|
|
||||||
|
|
||||||
declare var sqlitePlugin;
|
declare var sqlitePlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name SQLite
|
* @name SQLite
|
||||||
*
|
*
|
||||||
@ -34,142 +37,142 @@ declare var sqlitePlugin;
|
|||||||
})
|
})
|
||||||
export class SQLite {
|
export class SQLite {
|
||||||
|
|
||||||
private _objectInstance: any;
|
private _objectInstance: any;
|
||||||
get databaseFeatures(): any {
|
get databaseFeatures(): any {
|
||||||
return this._objectInstance.databaseFeatures;
|
return this._objectInstance.databaseFeatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor () {}
|
constructor() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open or create a SQLite database file.
|
* 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
|
* See the plugin docs for an explanation of all options: https://github.com/litehelpers/Cordova-sqlite-storage#opening-a-database
|
||||||
*
|
*
|
||||||
* @param config the config for opening the database.
|
* @param config the config for opening the database.
|
||||||
* @usage
|
* @usage
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* import { SQLite } from 'ionic-native';
|
* import { SQLite } from 'ionic-native';
|
||||||
*
|
*
|
||||||
* let db = new SQLite();
|
* let db = new SQLite();
|
||||||
* db.openDatabase({
|
* db.openDatabase({
|
||||||
* name: 'data.db',
|
* name: 'data.db',
|
||||||
* location: 'default' // the location field is required
|
* location: 'default' // the location field is required
|
||||||
* }).then(() => {
|
* }).then(() => {
|
||||||
* db.executeSql('create table danceMoves(name VARCHAR(32))', {}).then(() => {
|
* db.executeSql('create table danceMoves(name VARCHAR(32))', {}).then(() => {
|
||||||
*
|
*
|
||||||
* }, (err) => {
|
* }, (err) => {
|
||||||
* console.error('Unable to execute sql', err);
|
* console.error('Unable to execute sql', err);
|
||||||
* })
|
* })
|
||||||
* }, (err) => {
|
* }, (err) => {
|
||||||
* console.error('Unable to open database', err);
|
* console.error('Unable to open database', err);
|
||||||
* });
|
* });
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
openDatabase (config: any): Promise<any> {
|
openDatabase(config: any): Promise<any> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
sqlitePlugin.openDatabase(config, db => {
|
sqlitePlugin.openDatabase(config, db => {
|
||||||
this._objectInstance = db;
|
this._objectInstance = db;
|
||||||
resolve(db);
|
resolve(db);
|
||||||
}, error => {
|
}, error => {
|
||||||
console.warn(error);
|
console.warn(error);
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@CordovaInstance({
|
@CordovaInstance({
|
||||||
sync: true
|
sync: true
|
||||||
})
|
})
|
||||||
addTransaction (transaction: any): void {}
|
addTransaction(transaction: any): void { }
|
||||||
|
|
||||||
@CordovaInstance()
|
@CordovaInstance()
|
||||||
transaction (fn: any): Promise<any> {return; }
|
transaction(fn: any): Promise<any> { return; }
|
||||||
|
|
||||||
@CordovaInstance()
|
@CordovaInstance()
|
||||||
readTransaction (fn: any): Promise<any> {return; }
|
readTransaction(fn: any): Promise<any> { return; }
|
||||||
|
|
||||||
@CordovaInstance({
|
@CordovaInstance({
|
||||||
sync: true
|
sync: true
|
||||||
})
|
})
|
||||||
startNextTransaction (): void {}
|
startNextTransaction(): void { }
|
||||||
|
|
||||||
@CordovaInstance()
|
@CordovaInstance()
|
||||||
close (): Promise<any> {return; }
|
close(): Promise<any> { return; }
|
||||||
|
|
||||||
@CordovaInstance({
|
@CordovaInstance({
|
||||||
sync: true
|
sync: true
|
||||||
})
|
})
|
||||||
start (): void {}
|
start(): void { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute SQL on the opened database. Note, you must call `openDatabase` first, and
|
* Execute SQL on the opened database. Note, you must call `openDatabase` first, and
|
||||||
* ensure it resolved and successfully opened the database.
|
* ensure it resolved and successfully opened the database.
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* db.executeSql('SELECT FROM puppies WHERE type = ?', ['cavalier']).then((resultSet) => {
|
* db.executeSql('SELECT FROM puppies WHERE type = ?', ['cavalier']).then((resultSet) => {
|
||||||
* // Access the items through resultSet.rows
|
* // Access the items through resultSet.rows
|
||||||
* // resultSet.rows.item(i)
|
* // resultSet.rows.item(i)
|
||||||
* }, (err) => {})
|
* }, (err) => {})
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@CordovaInstance()
|
@CordovaInstance()
|
||||||
executeSql (statement: string, params: any): Promise<any> {return; }
|
executeSql(statement: string, params: any): Promise<any> { return; }
|
||||||
|
|
||||||
@CordovaInstance()
|
@CordovaInstance()
|
||||||
addSatement (sql, values): Promise<any> {return; }
|
addSatement(sql, values): Promise<any> { return; }
|
||||||
|
|
||||||
@CordovaInstance()
|
@CordovaInstance()
|
||||||
sqlBatch (sqlStatements: any): Promise<any> {return; }
|
sqlBatch(sqlStatements: any): Promise<any> { return; }
|
||||||
|
|
||||||
@CordovaInstance({
|
@CordovaInstance({
|
||||||
sync: true
|
sync: true
|
||||||
})
|
})
|
||||||
abortallPendingTransactions (): void {}
|
abortallPendingTransactions(): void { }
|
||||||
|
|
||||||
@CordovaInstance({
|
@CordovaInstance({
|
||||||
sync: true
|
sync: true
|
||||||
})
|
})
|
||||||
handleStatementSuccess (handler, response): void {}
|
handleStatementSuccess(handler, response): void { }
|
||||||
|
|
||||||
|
|
||||||
@CordovaInstance({
|
@CordovaInstance({
|
||||||
sync: true
|
sync: true
|
||||||
})
|
})
|
||||||
handleStatementFailure (handler, response): void {}
|
handleStatementFailure(handler, response): void { }
|
||||||
|
|
||||||
|
|
||||||
@CordovaInstance({
|
@CordovaInstance({
|
||||||
sync: true
|
sync: true
|
||||||
})
|
})
|
||||||
run (): void {}
|
run(): void { }
|
||||||
|
|
||||||
|
|
||||||
@CordovaInstance({
|
@CordovaInstance({
|
||||||
sync: true
|
sync: true
|
||||||
})
|
})
|
||||||
abort (txFailure): void {}
|
abort(txFailure): void { }
|
||||||
|
|
||||||
|
|
||||||
@CordovaInstance({
|
@CordovaInstance({
|
||||||
sync: true
|
sync: true
|
||||||
})
|
})
|
||||||
finish (): void {}
|
finish(): void { }
|
||||||
|
|
||||||
|
|
||||||
@CordovaInstance({
|
@CordovaInstance({
|
||||||
sync: true
|
sync: true
|
||||||
})
|
})
|
||||||
abortFromQ (sqlerror): void {}
|
abortFromQ(sqlerror): void { }
|
||||||
|
|
||||||
|
|
||||||
@Cordova()
|
@Cordova()
|
||||||
static echoTest (): Promise<any> {return; }
|
static echoTest(): Promise<any> { return; }
|
||||||
|
|
||||||
@Cordova()
|
@Cordova()
|
||||||
static deleteDatabase (first): Promise<any> {return; }
|
static deleteDatabase(first): Promise<any> { return; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user