Chapter 8. CouchDB API Server Design Document Methods

Table of Contents

8.1. GET /db/_design/design-doc
8.2. PUT /db/_design/design-doc
8.3. DELETE /db/_design/design-doc
8.4. COPY /db/_design/design-doc
8.4.1. Copying a Design Document
8.4.2. Copying from a Specific Revision
8.4.3. Copying to an Existing Design Document
8.5. GET /db/_design/design-doc/attachment
8.6. PUT /db/_design/design-doc/attachment
8.7. DELETE /db/_design/design-doc/attachment
8.8. GET /db/_design/design-doc/_info
8.9. GET /db/_design/design-doc/_view/view-name
8.9.1. Querying Views and Indexes
8.9.2. Sorting Returned Rows
8.9.3. Specifying Start and End Values
8.9.4. Using Limits and Skipping Rows
8.9.5. View Reduction and Grouping
8.10. POST /db/_design/design-doc/_view/view-name
8.10.1. Multi-document Fetching
8.11. POST /db/_design/design-doc/_show/show-name
8.12. POST /db/_design/design-doc/_show/show-name/doc
8.13. GET /db/_design/design-doc/_list/list-name/other-design-doc/view-name
8.14. POST /db/_design/design-doc/_list/list-name/other-design-doc/view-name
8.15. GET /db/_design/design-doc/_list/list-name/view-name
8.16. POST /db/_design/design-doc/_list/list-name/view-name
8.17. PUT /db/_design/design-doc/_update/updatename/doc
8.18. POST /db/_design/design-doc/_update/updatename
8.19. ALL /db/_design/design-doc/_rewrite/rewrite-name/anything

In CouchDB, design documents provide the main interface for building a CouchDB application. The design document defines the views used to extract information from CouchDB through one or more views. Design documents are created within your CouchDB instance in the same way as you create database documents, but the content and definition of the documents is different. Design Documents are named using an ID defined with the design document URL path, and this URL can then be used to access the database contents.

Views and lists operate together to provide automated (and formatted) output from your database.

A list of the available methods and URL paths are provided below:

Table 8.1. Design Document API Calls

MethodPathDescription
GET/db/_design/design-doc Returns the latest revision of the design document
PUT/db/_design/design-doc Creates or updates a design document
DELETE/db/_design/design-doc Deletes the design document
COPY/db/_design/design-doc Copies the design document
GET/db/_design/design-doc/_info Returns information about the design document
GET/db/_design/design-doc/_list/list-name/other-design-doc/view-name Invokes the list handler to translate the given view results
POST/db/_design/design-doc/_list/list-name/other-design-doc/view-name Invokes the list handler to translate the given view results for certain documents
GET/db/_design/design-doc/_list/list-name/view-name Invokes the list handler to translate the given view results
POST/db/_design/design-doc/_list/list-name/view-name Invokes the list handler to translate the given view results for certain documents
ALL/db/_design/design-doc/_rewrite/rewrite-name/anything Invokes the URL rewrite handler and processes the request after rewriting
GET/db/_design/design-doc/_show/show-name Invokes the show handler without a document
GET/db/_design/design-doc/_show/show-name/doc Invokes the show handler for the given document
POST/db/_design/design-doc/_update/update-name Invokes the update handler without a document ID
PUT/db/_design/design-doc/_update/update-name/doc Invokes the update handler with a specific document ID
GET/db/_design/design-doc/_view/view-name Returns results of the view
POST/db/_design/design-doc/_view/view-name Returns certain rows from the view
GET/db/_design/design-doc/attachment Gets an attachment of the design document
PUT/db/_design/design-doc/attachment Inserts an attachment to the design document
DELETE/db/_design/design-doc/attachment Deletes an attachment from the design document