MOBILE-3565 core: Fix some ESLint of CoreDbProvider
parent
8d42aaf964
commit
46323cdc80
|
@ -24,9 +24,7 @@ import { makeSingleton, SQLite, Platform } from '@singletons/core.singletons';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CoreDbProvider {
|
export class CoreDbProvider {
|
||||||
|
|
||||||
protected dbInstances = {};
|
protected dbInstances: {[name: string]: SQLiteDB} = {};
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get or create a database object.
|
* Get or create a database object.
|
||||||
|
@ -55,31 +53,31 @@ export class CoreDbProvider {
|
||||||
* @param name DB name.
|
* @param name DB name.
|
||||||
* @return Promise resolved when the DB is deleted.
|
* @return Promise resolved when the DB is deleted.
|
||||||
*/
|
*/
|
||||||
deleteDB(name: string): Promise<any> {
|
async deleteDB(name: string): Promise<void> {
|
||||||
let promise;
|
|
||||||
|
|
||||||
if (typeof this.dbInstances[name] != 'undefined') {
|
if (typeof this.dbInstances[name] != 'undefined') {
|
||||||
// Close the database first.
|
// Close the database first.
|
||||||
promise = this.dbInstances[name].close();
|
await this.dbInstances[name].close();
|
||||||
} else {
|
|
||||||
promise = Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return promise.then(() => {
|
|
||||||
const db = this.dbInstances[name];
|
const db = this.dbInstances[name];
|
||||||
delete this.dbInstances[name];
|
delete this.dbInstances[name];
|
||||||
|
|
||||||
if (Platform.instance.is('cordova')) {
|
if (db instanceof SQLiteDBMock) {
|
||||||
return SQLite.instance.deleteDatabase({
|
|
||||||
name,
|
|
||||||
location: 'default'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// In WebSQL we cannot delete the database, just empty it.
|
// In WebSQL we cannot delete the database, just empty it.
|
||||||
return db.emptyDatabase();
|
return db.emptyDatabase();
|
||||||
|
} else {
|
||||||
|
return SQLite.instance.deleteDatabase({
|
||||||
|
name,
|
||||||
|
location: 'default',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
} else if (Platform.instance.is('cordova')) {
|
||||||
|
return SQLite.instance.deleteDatabase({
|
||||||
|
name,
|
||||||
|
location: 'default',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
export class CoreDB extends makeSingleton(CoreDbProvider) {}
|
export class CoreDB extends makeSingleton(CoreDbProvider) {}
|
||||||
|
|
Loading…
Reference in New Issue