couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Cottlehuber <>
Subject Re: copy docs from one db to another?
Date Tue, 26 Mar 2013 08:02:30 GMT
On 25 March 2013 22:35, Mark Hahn <> 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

{"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.:

or you can dig with firebug/devtools as you like.


View raw message