我注意到我的數據庫的大小在刪除/恢復文檔與自動壓縮設置爲true
後增加。我做錯了什麼?pouchdb大小增加whilte刪除和恢復文檔
這裏是我的代碼:
var db = new PouchDB("myDB", {adapter: "idb", auto_compaction: true});
var docs = [{_id: "0", name: "foo1"}, {_id: "1", name: "foo2"}];
db.bulkDocs(docs).then(function() {
db.allDocs({include_docs: true}).then(function(result) {
docs = result.rows.map(function(row) {
return row.doc;
});
};
};
function remove() {
for (var i in docs) {
docs[i]._deleted = true;
}
return db.bulkDocs(docs);
};
function restore() {
for (var i in docs) {
delete docs[i]._deleted;
delete docs[i]._rev;
}
return db.bulkDocs(docs);
}
// Calling this function increases the size of the DB
function test() {
return remove(docs).then(restore);
}