How can I delete all records in a database in CouchDB?

I found this bookmarklet that adds you features to the Futon view. It adds you select all, delete all buttons and a delete column with delete checkboxes. It could be a good start, but you might want to modify it a bit since it doesn't seem to work all the time.

http://www.elijahmanor.com/couch-potato-bookmarklet-lazy-features-for-couchdbs-futon/


Here is a python script to do the job:

import couchdb
couch = couchdb.Server('http://localhost:5984/')
couchdb = 'DATABASE'
db = couch[couchdb]
for id in db:
    db.delete(db[id])

There is no way to drop Data except deleting each doc (or updating a bunch of known doc-id's with _rev=xxx and "_deleted:true" in a _bulk)

Deleting and recreating is ok.


The code below deletes all databases (not all records!) using Node.js. You need to install nano and after that execute following code:

var nano = require('nano')('http://localhost:5984');

nano.db.list(function(err, body) {
  body.forEach(function(db) {
     nano.db.destroy(db);
  });
});

Tags:

Couchdb