PouchDB compact() call-open source projects pouchdb/pouchdb
nlawson
CouchDB and PouchDB always keep a “tombstone” revision for deleted documents, because otherwise funky things would happen during replication. So those deleted docs don’t go away during compaction; compaction just gets rid of any revisions older than the most recent one.
There is also a “purge” command that can really eliminate a document and its history, but it’s pretty drastic, and most of the time you don’t want to do it unless you have to (source). Also, it’s not supported in PouchDB yet, although it’s in progress.
If you’re just worried about a doc taking up space, instead of simply calling pouch.remove()
, you can do:
pouch.get('mydoc').then(function (doc) {
var deletedDoc = {
_id : doc._id,
_rev : doc._rev,
_deleted : true
};
return pouch.put(doc);
}).then(function (res) {
// etc.
}).catch(function (err) {
// etc.
};