Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I upload a design document to CouchDB using cURL?

Tags:

curl

couchdb

I'm trying to learn CouchDB and I can create views and such in Futon, but I want to write my design documents on the desktop and the upload them using cURL. The 'Definitive Guide' shows updating content documents with cURL but all the design documents are either Futon or CouchApp.

I'd like to download the current design doc to a local file, edit the file, then send it back to CouchDB.

What are the cURL commands to download and upload CouchDB design documents?

like image 742
Randall Bohn Avatar asked Dec 11 '10 15:12

Randall Bohn


1 Answers

Download the design file "task" in database "dev-task" to file "task.json" :

curl http://localhost:5984/dev-task/_design/task > task.json

Once the file is edited, you can put it back.

curl -X PUT http://localhost:5984/dev-task/_design/task -d @task.json

This works because task.json contains an appropriate revision number. If you want to change the file again, you need to re-download it first to get the latest revision number.

like image 187
Victor Nicollet Avatar answered Sep 28 '22 06:09

Victor Nicollet