Given on August 16th, 2010, at the ChicagoDB user's group
- Get CouchDB
- Install and start CouchDB
- Navigate to http://localhost:5984/_utils
- Create yourself an admin account, with a username of 'admin' and a password of 'admin'
curl -X PUT http://admin:admin@localhost:5984/employees/
curl http://localhost:5984/employees
PUT or POST can be used. POST will use a server generated DocID. Use PUT if you want to specify the DocID. PUT is recommended, because some network intermediaries will resend POST requests, resulting in duplicate documents.
curl -X PUT http://localhost:5984/employees/1234 -d @first_doc.json
curl http://localhost:5984/employees/1234
First, make a change to the first_doc.json file. For example, change the last name from "Woo" to "Wood". In addition, be sure to include the "_rev" property that was returned when you fetched the document in the previous command. CouchDB will reject document updates with a conflict error if they don't include the revision number of the current document.
curl -X PUT http://localhost:5984/employees/1234 -d @first_doc.json
curl -X DELETE http://localhost:5984/employees/1234?rev=xxxx
curl -X PUT http://localhost:5984/employees/1 -d @john.json
curl -X PUT http://localhost:5984/employees/2 -d @ryan.json
curl -X PUT http://localhost:5984/employees/3 -d @ethan.json
curl -X PUT http://localhost:5984/employees/4 -d @bob.json
curl -X PUT http://admin:admin@localhost:5984/employees/_design/stats -d @stats_design_doc.json
curl 'http://localhost:5984/employees/_design/stats/_view/total_employees'
curl 'http://localhost:5984/employees/_design/stats/_view/by_lastname'
curl 'http://localhost:5984/employees/_design/stats/_view/by_lastname?include_docs=true'
curl 'http://localhost:5984/employees/_design/stats/_view/by_lastname?startkey="A"&endkey="H"&include_docs=true'
curl 'http://localhost:5984/employees/_design/stats/_view/by_lastname?key="Wood"&include_docs=true'
curl 'http://localhost:5984/employees/_design/stats/_view/dependents?reduce=false'
curl 'http://localhost:5984/employees/_design/stats/_view/dependents?key="1"&reduce=false'
curl 'http://localhost:5984/employees/_design/stats/_view/dependents?startkey="1"&endkey="1"'
curl 'http://localhost:5984/employees/_design/stats/_view/total_payroll'
curl 'http://localhost:5984/employees/_design/stats/_view/by_date_hired?startkey=\[2010,3,10\]'
curl 'http://localhost:5984/employees/_design/stats/_view/by_date_hired?startkey=\[2010,3,10\]&include_docs=true'
curl 'http://localhost:5984/employees/_design/stats/_view/by_date_hired?startkey=\[2010,{}\]&include_docs=true'