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();
}});
}});
Written by Marcus Zanona
Related protips
1 Response
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Couchdb
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#