O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — creating a CouchDB document

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required