【发布时间】:2016-12-22 12:34:50
【问题描述】:
我在删除数据库以释放存储空间时遇到问题。我已经尝试过 How can I delete PouchDB Database indefinitly, to free space? 和 https://pouchdb.com/guides/compact-and-destroy.html 的解决方案,但它不能解决我的问题。我已经使用 compact() 函数清除了以前的用户数据,但是当我尝试同步新用户数据时,其他用户的旧数据并没有被删除。例如,用户 A 有 3 个数据,用户 B 有 2 个数据。首先,我从用户 A 那里获取数据,然后我正确地获取了 3 个数据。然后,当我想从用户 B 获取数据时,我得到 5 个数据,这意味着来自用户 A 的数据没有被删除/删除。以下是我的代码:
uuid.ts
retriveTaskRefNo(url, uuid, cb){
//get reference item based on uuid
HTTP.get(url+'/get_item', {uuid: uuid}, {})
.then(data => {
//call the function removeData() in uuid.ts
this.removeData(() => {
//save reference item
this.settingProvider.setInfo(data.data, () => {
cb();
});
})
})
}
//call the removeData() in itemProvider.ts
removeData(cb){
this.itemProvider.resetDB(() => {
});
}
itemProvider.ts
constructor(public http: Http, public settingProvider: SettingProvider) {
this.initializeTaskDB();
}
initializeTaskDB(){
this.db = new PouchDB('item');
console.log('Database created Success!');
}
//function to clear database
resetDB(cb){
if(this.sync){
console.log('Cancelling sync for InspectionTask due to removeData');
this.sync.cancel();
}
this.db.destroy().then(function (response) {
console.log('success delete inspection task');
this.initializeTaskDB();
}).catch(function (err) {
console.log('eror',err);
});
}
是不是代码错了。请指导我
【问题讨论】:
标签: ionic-framework couchdb pouchdb