fiwowg
Last Updated: February 25, 2016
·
1.138K
· zanona

Snippet: Flush CouchDB Database inside Futon

When inside Futon database page (http://127.0.0.1:5984/_utils/database.html?database_name), use the following script to delete (flush) all documents except the _design/*** docs.

This was pretty useful for testing in my case:

var couch = new $.futon.CouchDocumentPage();
couch.db.allDocs({success: function (all) {
    var docs = all
        .rows
        .filter(function(item) { return !item.id.match('_design'); })
        .map(function (item) { return {_id: item.id, _rev: item.value.rev}});

    couch.db.bulkRemove({docs: docs}, {success: function (docs) {
        window.location.reload();
    }});
}});

1 Response
Add your response

10721

It is probably an easy job, to transform this into a bookmarklet or a chrome extension to auto-add this as a button into futon's interface. just so it is not necessary the use of snippet anymore.

over 1 year ago ·