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 — querying the posts_by_user view

Remember that design document is still a document, which means that we can query it just as we would query a regular document. The only difference will be that we need to use a slightly different URL pattern to hit the correct file.

  1. Open Terminal.
  2. Use a curl statement to query our design document by passing a key of johndoe (or another user in your database that has a decent amount of posts), then pass it through python mjson.tool to make it a bit prettier:
    curl http://127.0.0.1:5984/verge/_design/application/_view/posts_by_user?key=%22johndoe%22 | python -mjson.tool
    
    
  3. The terminal will respond with something similar to the following:
    { "offset": 0, "rows": [ { "id": "352e5c2d51fb1293c44a2146d4003aa3", ...

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