On 25 March 2013 22:35, Mark Hahn <[email protected]> wrote: > I have a database with a zillion docs that I need to empty. I just want > the design docs left behind. I googled and saw some techniques that > require writing code. > > Could I just GET the docs with curl and then PUT them? > > Any other way to do it?
GET http://couch/db/_all_docs?startkey=%22_design/%22&endkey=%22_design0%22&include_docs=true PUT/POST is left as an excercise to the gentle reader. Bulk docs is your friend. You'll need to remove revs, and turn {"total_rows":18075,"offset":352,"rows":[ into {"all_or_nothing": true, "docs": [ As Nils said, you should store all your ddocs in erica/couchapp form under version control. Ditto the nodejs version. This example uses erica, but couchapp would still do the job: ; list all ddocs curl -sk http://couch/db/_all_docs\?startkey\=%22_design/%22\&endkey\=%22_design0%22 | jgrep --start rows -s "id" ; for each of the ddocs above clone them into a separate directory erica clone http://host/db/_design/$ddoc $ddoc IIRC erica doesn't support multiple ddocs in the same couchapp, I could be wrong on that. For these sorts of questions I usually look at the innards of futon e.g.: https://github.com/apache/couchdb/blob/master/share/www/script/futon.browse.js#L404-L439 or you can dig with firebug/devtools as you like. A+ Dave
