compared with
Version 5 by Sergey Avseyev
on Feb 26, 2013 11:39.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (1)

View Page History
{"error":"key_enoent","reason":"No such key"}
{code}

h2. Couchbase Views

One of the features of the Couchbase is ability to build efficient indexes leveraging Map/Reduce. They are called Views and you can define them on Admin Console UI.

This module allows you to query your views proxying them to Couchbase. All arguments will be transparently passed to Couchbase and the result will be streamed back.

For example we have a view {{all}} defined in the design document {{characters}}. It is simple map which will just emit all known characters (without any reduce function):

{code:javascript}
function (doc, meta) {
emit(meta.id, null);
}
{code}

The result will look like
{code:none}
GET /wonderland/_design/characters/_view/all
< 200
< Transfer-Encoding: chunked
< Content-Type: application/json
{"total_rows":10,"rows":[
{"id":"bill-the-lizard","key":"bill-the-lizard","value":null},
{"id":"cheshire-cat","key":"cheshire-cat","value":null},
{"id":"dodo","key":"dodo","value":null},
{"id":"duchess","key":"duchess","value":null},
{"id":"eaglet","key":"eaglet","value":null},
{"id":"gryphon","key":"gryphon","value":null},
{"id":"king-of-hearts","key":"king-of-hearts","value":null},
{"id":"march-hare","key":"march-hare","value":null},
{"id":"mock-turtle","key":"mock-turtle","value":null},
{"id":"queen-of-hearts","key":"queen-of-hearts","value":null}
]
}
{code}

You can pass the any of supported query parameters, like {{include_docs=true}} for example:
{code:none}
GET /wonderland/_design/characters/_view/all?include_docs=true
< 200
< Transfer-Encoding: chunked
< Content-Type: application/json
{"total_rows":10,"rows":[
{"id":"bill-the-lizard","key":"bill-the-lizard","value":null,"doc":{"meta":{"id":"bill-the-lizard","rev":"1-000050d16a33cfcb0000000000000000","expiration":0,"flags":0},"json":{"name":"Bill the Lizard","species":"lizard"}}},
{"id":"cheshire-cat","key":"cheshire-cat","value":null,"doc":{"meta":{"id":"cheshire-cat","rev":"1-000050d16a3c44970000000000000000","expiration":0,"flags":0},"json":{"name":"Cheshire Cat","species":"cat"}}},
{"id":"dodo","key":"dodo","value":null,"doc":{"meta":{"id":"dodo","rev":"1-000050d16a2676470000000000000000","expiration":0,"flags":0},"json":{"name":"Dodo","species":"bird"}}},
{"id":"duchess","key":"duchess","value":null,"doc":{"meta":{"id":"duchess","rev":"1-000050d16a394b5b0000000000000000","expiration":0,"flags":0},"json":{"name":"Duchess","species":"human"}}},
{"id":"eaglet","key":"eaglet","value":null,"doc":{"meta":{"id":"eaglet","rev":"1-000050d16a2bac3f0000000000000000","expiration":0,"flags":0},"json":{"name":"Eaglet","species":"bird"}}},
{"id":"gryphon","key":"gryphon","value":null,"doc":{"meta":{"id":"gryphon","rev":"1-000050d16a50bf4a0000000000000000","expiration":0,"flags":0},"json":{"name":"Gryphon","species":"gryphon"}}},
{"id":"king-of-hearts","key":"king-of-hearts","value":null,"doc":{"meta":{"id":"king-of-hearts","rev":"1-000050d16a4de61e0000000000000000","expiration":0,"flags":0},"json":{"name":"King of Hearts","species":"card"}}},
{"id":"march-hare","key":"march-hare","value":null,"doc":{"meta":{"id":"march-hare","rev":"1-000050d16a3f1afa0000000000000000","expiration":0,"flags":0},"json":{"name":"March Hare","species":"hare"}}},
{"id":"mock-turtle","key":"mock-turtle","value":null,"doc":{"meta":{"id":"mock-turtle","rev":"1-000050d16a53d7770000000000000000","expiration":0,"flags":0},"json":{"name":"Mock Turtle","species":"turtle"}}},
{"id":"queen-of-hearts","key":"queen-of-hearts","value":null,"doc":{"meta":{"id":"queen-of-hearts","rev":"1-000050d16a4765350000000000000000","expiration":0,"flags":0},"json":{"name":"Queen of Hearts","species":"card"}}}
]
}
{code}