pouchdb size increasing whilte deleting and restoring docs -
i've noticed size of db increasing after deleting / restoring docs auto-compaction set true
. do wrong?
here code:
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() { (var in docs) { docs[i]._deleted = true; } return db.bulkdocs(docs); }; function restore() { (var in docs) { delete docs[i]._deleted; delete docs[i]._rev; } return db.bulkdocs(docs); } // calling function increases size of db function test() { return remove(docs).then(restore); }
that's not correct way delete documents pouchdb.
use: db.remove(doc, [options], [callback])
good luck
Comments
Post a Comment