Getting Design Doc Information
To retrieve a design document, use theGET /bucket/_design/[ddoc-name]
HTTP method and URI on the8092
port.
Description
To obtain an existing design document from a bucket, use the 8092
port and GET /bucket/_design/[ddoc-name]
HTTP method URI ending with the design document name.
To retrieve all design documents in a cluster use the 8091
port with the /pools/default/buckets/[bucket-name]/ddocs
URI.
HTTP method and URI
To retrieve all the design documents with views defined on a bucket:
GET /[bucket-name]/_design/[ddoc-name]
Request Data |
Design document definition (JSON) |
Response Data |
Success and stored design document ID |
Authentication Required |
optional |
Parameters:
Syntax
Curl request syntax:
curl -u [admin]:[password] -X GET http://[localhost]:8092/[bucket-name]/_design/[ddoc-name]
HTTP response header includes a JSON document containing the metadata about the design document being accessed.
The information is returned within the X-Couchbase-Meta header of the returned data.
This information is retrieved by using the -v option to the curl command.
|
To get design document information from the cluster, the following request is made on the 8091
port.
curl -u [admin]:[password] -X GET http://[localhost]:8091/pools/default/buckets/[bucket-name]/ddocs
Examples
Curl request example:
To retrieve design doc information, the request must be made on the 8092 port.
|
To get the existing design document from the bucket test2
for the development design document ruth
and the view ruthView
curl -u Administrator:password -X GET \ http://10.5.2.117:8092/test2/_design/dev_ruth
To get design document information from the cluster, the request must be made on the 8091
port.
curl -u Administrator:password -X GET \ http://10.5.2.117:8091/pools/default/buckets/test2/ddocs
Response
Response for the following example on the bucket test2
and the development design doc dev_ruth
.
The design document is empty because no data was added.
curl -u Administrator:password -X GET \ http://10.5.2.117:8092/test2/_design/dev_john
{ "views": { "johnView": { "map": "function (doc, meta) {\n emit(meta.id, null);\n}" } } }
Response for the following request on the bucket test2
.
curl -u Administrator:password -X GET \ http://10.5.2.117:8091/pools/default/buckets/test2/ddocs
{ "rows": [ { "controllers": { "compact": "/pools/default/buckets/test2/ddocs/_design%2Fdev_ruth/controller/compactView", "setUpdateMinChanges": "/pools/default/buckets/test2/ddocs/_design%2Fdev_ruth/controller/setUpdateMinChanges" }, "doc": { "json": { "views": { "ruthView": { "map": "function (doc, meta) {\n emit(meta.id, null);\n}" } } }, "meta": { "id": "_design/dev_ruth", "rev": "1-9bdf8353" } } } ] }
The following response shows that the metadata matches the corresponding metadata for a data document.
* About to connect() to 192.168.0.77 port 8092 (#0) * Trying 192.168.0.77... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* connected * Connected to 192.168.0.77 (192.168.0.77) port 8092 (#0) * Server auth using Basic with user 'Administrator' > GET /sales/_design/something HTTP/1.1 > Authorization: Basic QWRtaW5pc3RyYXRvcjpUYW1zaW4= > User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5 > Host: 192.168.0.77:8092 > Accept: */* > Content-Type: application/json > < HTTP/1.1 200 OK < X-Couchbase-Meta: {"id":"_design/dev_sample","rev":"5-2785ea87","type":"json"} < Server: MochiWeb/1.0 (Any of you quaids got a smint?) < Date: Mon, 13 Aug 2012 10:45:46 GMT < Content-Type: application/json < Content-Length: 159 < Cache-Control: must-revalidate < { [data not shown] 100 159 100 159 0 0 41930 0 --:--:-- --:--:-- --:--:-- 53000 * Connection #0 to host 192.168.0.77 left intact * Closing connection #0
If the view does not exist, the following error is returned:
{ "error":"not_found", "reason":"missing" }
Response codes
Response codes | Description |
---|---|
200 |
Request completed successfully. |
401 |
The item requested was not available using the supplied authorization, or authorization was not supplied. |
404 |
The requested content could not be found. The returned content includes further information, as a JSON object, if available. |