How can I delete PouchDB Database indefinitly, to free space?

允我心安 提交于 2019-12-19 09:53:21

问题


How can I drop a database in PouchDB to get the space on the disk free again? Remove only sets a paramter _deleted and keeps the Data of the record anyway.
But how can I delete records in a way that actually gets rid of them and saves up some space?
Because I'd like to reset the database every now and then so it doesn't get too big.


回答1:


It sounds like you are looking for compaction. It will do exactly what you describe. :)




回答2:


You can destroy the database and create it again.

var _db = new PouchDB('foo');

var reset = function() {
  _db.destroy().then(function() {
    _db = new PouchDB('foo');
  });
};


来源:https://stackoverflow.com/questions/28630153/how-can-i-delete-pouchdb-database-indefinitly-to-free-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!