2016-03-29 18:50:03 +08:00
|
|
|
import {CordovaInstance, Plugin, Cordova} from './plugin';
|
|
|
|
declare var sqlitePlugin;
|
|
|
|
/**
|
|
|
|
* @name SQLite
|
|
|
|
*/
|
|
|
|
@Plugin({
|
2016-04-30 10:47:01 +08:00
|
|
|
pluginRef: 'sqlitePlugin',
|
|
|
|
plugin: 'cordova-sqlite-storage',
|
|
|
|
repo: 'https://github.com/litehelpers/Cordova-sqlite-storage'
|
2016-03-29 18:50:03 +08:00
|
|
|
})
|
|
|
|
export class SQLite {
|
|
|
|
|
2016-04-30 11:56:49 +08:00
|
|
|
private _objectInstance: any;
|
|
|
|
get databaseFeatures(): any {
|
2016-03-29 18:50:03 +08:00
|
|
|
return this._objectInstance.databaseFeatures;
|
|
|
|
}
|
|
|
|
|
2016-04-30 11:56:49 +08:00
|
|
|
constructor (config: any) {
|
2016-03-29 18:50:03 +08:00
|
|
|
new Promise((resolve, reject) => {
|
|
|
|
sqlitePlugin.openDatabase(config, resolve, reject);
|
|
|
|
}).then(
|
|
|
|
db => this._objectInstance = db,
|
|
|
|
error => console.warn(error)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@CordovaInstance({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-04-30 11:56:49 +08:00
|
|
|
addTransaction (transaction: any): void {}
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
@CordovaInstance()
|
2016-04-30 11:56:49 +08:00
|
|
|
transaction (fn: any): Promise<any> {return; }
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
@CordovaInstance()
|
2016-04-30 11:56:49 +08:00
|
|
|
readTransaction (fn: any): Promise<any> {return; }
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
@CordovaInstance({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-04-30 11:56:49 +08:00
|
|
|
startNextTransaction (): void {}
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
@CordovaInstance()
|
2016-04-30 11:56:49 +08:00
|
|
|
close (): Promise<any> {return; }
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
@CordovaInstance({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-04-30 11:56:49 +08:00
|
|
|
start (): void {}
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
@CordovaInstance()
|
2016-04-30 11:56:49 +08:00
|
|
|
executeSql (statement: string, params: any): Promise<any> {return; }
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
@CordovaInstance()
|
2016-04-30 11:56:49 +08:00
|
|
|
addSatement (sql, values): Promise<any> {return; }
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
@CordovaInstance()
|
2016-04-30 11:56:49 +08:00
|
|
|
sqlBatch (sqlStatements: any): Promise<any> {return; }
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
@CordovaInstance({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-04-30 11:56:49 +08:00
|
|
|
abortallPendingTransactions (): void {}
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
@CordovaInstance({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-04-30 11:56:49 +08:00
|
|
|
handleStatementSuccess (handler, response): void {}
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
@CordovaInstance({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-04-30 11:56:49 +08:00
|
|
|
handleStatementFailure (handler, response): void {}
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
@CordovaInstance({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-04-30 11:56:49 +08:00
|
|
|
run (): void {}
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
@CordovaInstance({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-04-30 11:56:49 +08:00
|
|
|
abort (txFailure): void {}
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
@CordovaInstance({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-04-30 11:56:49 +08:00
|
|
|
finish (): void {}
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
@CordovaInstance({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-04-30 11:56:49 +08:00
|
|
|
abortFromQ (sqlerror): void {}
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static echoTest (): Promise<any> {return; }
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static deleteDatabase (first): Promise<any> {return; }
|
2016-03-29 18:50:03 +08:00
|
|
|
|
|
|
|
}
|