In this exercise, we'll create a document by initiating a POST
call. You'll notice that our curl
statement will start to get a bit more complex.
1. Create a document in the
test-db
database by running the following command in Terminal:curl -X POST -H "Content-Type:application/json" -d '{"type": "customer", "name":"Tim Juravich", "location":"Seattle, WA"}' http://localhost:5984/test-db
2. Terminal will respond with something similar to the following:
{"ok":true,"id":"39b1fe3cdcc7e7006694df91fb002082","rev":"1-8cf37e845c61cc239f0e98f8b7f56311"}
3. Let's retrieve the newly created document from CouchDB. Start by copying the ID you were returned at the last response of the Terminal to your clipboard; mine is
39b1fe3cdcc7e7006694df91fb002082
, but yours will be different. Then run this command in Terminal, pasting your ID at the end of the URL:curl -X GET http://localhost:5984/test-db/41198fc6e20d867525a8faeb7a000015 | python -mjson.tool
4....