How to limit PouchDB revisions or permanently delete revisions How to limit PouchDB revisions or permanently delete revisions database database

How to limit PouchDB revisions or permanently delete revisions


I got the answer by opening an issue on the pouchDb's github:link to github issue.

Below is the answer from @daleyharvey on github. As you can see the main thing was adding revs_limit: 1 to my initialisation. That stopped my db from growing without bounds.

new PouchDB('name', {revs_limit: 1, auto_compaction: true}) should do what you want, revs_limit is the number of revisions we keep track off (which is what your seeing) compaction deletes the contents of those revisions


Just as a side-note, for my use case I eventually found out that there was no need to use an advanced db such as PouchDB, in the end end - I needed either plain WebSQL or local storage.


Have you tried auto compaction?

var db = new PouchDB('mydb', {auto_compaction: true});db.put({_id: 'foo', version: 1}).then(function () {  return db.get('foo');}).then(function (doc) {  doc.version = 2;  return db.put(doc);}).then(function () {  // Revision 1 is already unavailable!}).catch(function (err) {  // handle errors});