Adding clearData to CompactIDB

compactIDB.clearData clears all data in the given objectstore.
This commit is contained in:
sairajzero 2020-05-02 18:48:02 +05:30
parent 38f43d805d
commit 0308af983f

View File

@ -8470,6 +8470,18 @@ Bitcoin.Util = {
});
},
clearData: function (obsName, dbName = this.dbName) {
return new Promise((resolve, reject) => {
this.openDB(dbName).then(db => {
var obs = db.transaction(obsName, "readwrite").objectStore(obsName);
let clearReq = obs.clear();
clearReq.onsuccess = (evt) => resolve(`Clear data Successful`);
clearReq.onerror = (evt) => reject(`Clear data Unsuccessful`);
db.close();
}).catch(error => reject(error));
});
},
readData: function (obsName, key, dbName = this.dbName) {
return new Promise((resolve, reject) => {
this.openDB(dbName).then(db => {