Changes (2)

* auth scheme, on this step you might only protect your API endpoint using nginx built-in means * expiration handling. in Couchbase database it is possible to associate with the key expiration time. This feature will be exposed later

There are several terms we are using while describing this API.

|| Term || Definition|| | document | Arbitrary JSON or BLOB value. It could be referenced by its ID | | bucket | The logical storage, which contains the documents. Like *database* in SQL world, or *collection* in mongodb |

Lets assume we have a bucket named {{wonderland}}.

h2. Document CRUD

This section shows how to perform simple Create, Retrieve, Update and Delete operations

Note that when you are using POST request, the server is always supposed to create the new document. This means that you will get an error if the document already exists. {code:none} POST /wonderland/foobar > Content-Type: application/json {"foo":"bar"} < 409 < Content-Type: application/json < Content-Length: 74 {"error":"key_eexists","reason":"Key exists (with a different ETag value)"} {code}

In case when the given document ID isn't exist in the bucket you will get *404 Not Found* {code:none} GET /wonderland/red-queen < 404 < Content-Type: application/json < Content-Length: 45 {"error":"key_enoent","reason":"No such key"}

{code}

Use *HEAD* request to skip the document body HEAD /wonderland/gryphon

{code:none}

HEAD /wonderland/gryphon

< 200 < Content-Type: application/json

...

< ETag: "55c3a92df1570000" {code}

Each operation is carry ETag, which internally is CAS value. The ETag value can be used in the conditional requests with *If-Match*, *If-None-Match*. See examples of *If-Match* above.

Check if the key has been modified (in this case the server responds that it wasn't modified): {code:none} HEAD /wonderland/dormouse > If-None-Match: "3f5b792df1570000" < 304 {code}

h2. Couchbase Views

This section shows more advanced server feature: View indexes

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):