CouchDB quick ref/starting guide
Posted:

CouchDB starting guide

GUI (Futon). From the browser go to http://127.0.0.1:5984/_utils

List all DB's

$ curl -X GET http://127.0.0.1:5984/_all_dbs

Create DB

$ curl -X PUT http://127.0.0.1:5984/contacts

Delete DB

$ curl -X DELETE http://127.0.0.1:5984/contacts

Insert document (record)

$ curl -X put http://127.0.0.1:5984/contacts/andyjarrett -d '{"firstName":"Andy","lastName":"Jarrett","email":"andy.jarrett@example.com"}' Using the -d flag, it is recommended that you encapsulate your JSON code using single quotes rather than double quote

Get documents

$ curl -X GET http://127.0.0.1:5984/contacts/andyjarrett

Delete document

$ curl -X DELETE http://127.0.0.1:5984/contacts/johndoe?rev={USE REV FROM THE GET RECORD COMMAND}

Copy record (document)

$ curl -X COPY http://127.0.0.1:5984/contacts/andyjarrett -H "Destination: tylerdurden"

Update record (document): You'll need the rev number which the GET record command can supply.

$ curl -X PUT http://127.0.0.1:5984/contacts/tylerdurden -d '{"_rev":"1-b2a7c335ac3e754f050eda2baff6bf89","firstName":"Tyler","lastName":"Durden","email":["tyler.durden@example.com","tyler.durden@example.com"]}

List all documents

$ curl -X GET http://127.0.0.1:5984/contacts/_all_docs

List all documents (ORDER and set LIMIT)

$ curl -X GET http://127.0.0.1:5984/contacts/_all_docs?descending=true\&limit=1

All documents in the DB (as well as deleted ones) ordered by last modified. Look for the following next to deleted records: "deleted":true

$ curl -X GET http://127.0.0.1:5984/contacts/_all_docs_by_seq

comments powered by Disqus
© AndyJarrett 2013 | RSS Feed