# 10.5.5. `/db/_design/design-doc/_show/show-name`

`GET` `/{db}/_design/{ddoc}/_show/{func}`

`POST` `/{db}/_design/{ddoc}/_show/{func}`

  Applies show function for null document.

  The request and response parameters are depended upon function implementation.

  Parameters: | db – Database name ddoc – Design document name func – Show function name
  Response Headers:
  | ETag – Response signature
  Query Parameters:
  | format (string) – Format of the returned response. Used by `provides()` function
  Status Codes: | 200 OK – Request completed successfully 500 Internal Server Error – Query server error

  Function:

      function(doc, req) {
          if (!doc) {
              return {body: "no doc"}
          } else {
              return {body: doc.description}
          }
      }

  Request:

      GET /recipes/_design/recipe/_show/description HTTP/1.1
      Accept: application/json
      Host: localhost:5984

  Response:

      HTTP/1.1 200 OK
      Content-Length: 6
      Content-Type: text/html; charset=utf-8
      Date: Wed, 21 Aug 2013 12:34:07 GMT
      Etag: "7Z2TO7FPEMZ0F4GH0RJCRIOAU"
      Server: CouchDB (Erlang/OTP)
      Vary: Accept

      no doc

# 10.5.6. `/db/_design/design-doc/_show/show-name/doc-id`

`GET` `/{db}/_design/{ddoc}/_show/{func}/{docid}`

`POST` `/{db}/_design/{ddoc}/_show/{func}/{docid}`

  Applies show function for the specified document.

  The request and response parameters are depended upon function implementation.

  Parameters: | db – Database name ddoc – Design document name func – Show function name docid – Document ID
  Response Headers:
  | ETag – Response signature
  Query Parameters:
  | format (string) – Format of the returned response. Used by `provides()` function
  Status Codes: | 200 OK – Request completed successfully 500 Internal Server Error – Query server error

  Function:

      function(doc, req) {
          if (!doc) {
              return {body: "no doc"}
          } else {
              return {body: doc.description}
          }
      }

  Request:

      GET /recipes/_design/recipe/_show/description/SpaghettiWithMeatballs HTTP/1.1
      Accept: application/json
      Host: localhost:5984

  Response:

      HTTP/1.1 200 OK
      Content-Length: 88
      Content-Type: text/html; charset=utf-8
      Date: Wed, 21 Aug 2013 12:38:08 GMT
      Etag: "8IEBO8103EI98HDZL5Z4I1T0C"
      Server: CouchDB (Erlang/OTP)
      Vary: Accept

      An Italian-American dish that usually consists of spaghetti, tomato sauce and meatballs.

# 10.5.7. `/db/_design/design-doc/_list/list-name/view-name`

`GET` `/{db}/_design/{ddoc}/_list/{func}/{view}`

`POST` `/{db}/_design/{ddoc}/_list/{func}/{view}`

  Applies list function for the view function from the same design document.

  The request and response parameters are depended upon function implementation.

  Parameters: | db – Database name ddoc – Design document name func – List function name view – View function name
  Response Headers:
  | ETag – Response signature Transfer-Encoding – `chunked`
  Query Parameters:
  | format (string) – Format of the returned response. Used by `provides()` function
  Status Codes: | 200 OK – Request completed successfully 500 Internal Server Error – Query server error

  Function:

      function(head, req) {
          var row = getRow();
          if (!row){
              return 'no ingredients'
          }
          send(row.key);
          while(row=getRow()){
              send(', ' + row.key);
          }
      }

  Request:

      GET /recipes/_design/recipe/_list/ingredients/by_name HTTP/1.1
      Accept: text/plain
      Host: localhost:5984

  Response:

      HTTP/1.1 200 OK
      Content-Type: text/plain; charset=utf-8
      Date: Wed, 21 Aug 2013 12:49:15 GMT
      Etag: "D52L2M1TKQYDD1Y8MEYJR8C84"
      Server: CouchDB (Erlang/OTP)
      Transfer-Encoding: chunked
      Vary: Accept

      meatballs, spaghetti, tomato sauce

# 10.5.8. `/db/_design/design-doc/_list/list-name/other-ddoc/view-name`

`GET` `/{db}/_design/{ddoc}/_list/{func}/{other-ddoc}/{view}`

`POST` `/{db}/_design/{ddoc}/_list/{func}/{other-ddoc}/{view}`

  Applies list function for the view function from the other design document.

  The request and response parameters are depended upon function implementation.

  Parameters: | db – Database name ddoc – Design document name func – List function name other-ddoc – Other design document name that holds view function view – View function name
  Response Headers:
  | ETag – Response signature Transfer-Encoding – `chunked`
  Query Parameters:
  | format (string) – Format of the returned response. Used by `provides()` function
  Status Codes: | 200 OK – Request completed successfully 500 Internal Server Error – Query server error

  Function:

      function(head, req) {
          var row = getRow();
          if (!row){
              return 'no ingredients'
          }
          send(row.key);
          while(row=getRow()){
              send(', ' + row.key);
          }
      }

  Request:

      GET /recipes/_design/ingredient/_list/ingredients/recipe/by_ingredient?key="spaghetti" HTTP/1.1
      Accept: text/plain
      Host: localhost:5984

  Response:

      HTTP/1.1 200 OK
      Content-Type: text/plain; charset=utf-8
      Date: Wed, 21 Aug 2013 12:49:15 GMT
      Etag: "5L0975X493R0FB5Z3043POZHD"
      Server: CouchDB (Erlang/OTP)
      Transfer-Encoding: chunked
      Vary: Accept

      spaghetti

# 10.5.9. `/db/_design/design-doc/_update/update-name`

`POST` `/{db}/_design/{ddoc}/_update/{func}`

  Executes update function on server side for `null` document.

  Parameters: | db – Database name ddoc – Design document name func – Update function name
  Response Headers:
  | X-Couch-Id – Created/updated document’s ID X-Couch-Update-Newrev – Created/updated document’s revision
  Status Codes: | 200 OK – No document was created or updated 201 Created – Document was created or updated 500 Internal Server Error – Query server error

  Function:

      function(doc, req) {
          if (!doc){
            return [null, {'code': 400,
                           'json': {'error': 'missed',
                                    'reason': 'no document to update'}}]
          } else {
              doc.ingredients.push(req.body);
              return [doc, {'json': {'status': 'ok'}}];
          }
      }

  Request:

      POST /recipes/_design/recipe/_update/ingredients HTTP/1.1
      Accept: application/json
      Content-Length: 10
      Content-Type: application/json
      Host: localhost:5984

      "something"

  Response:

      HTTP/1.1 404 Object Not Found
      Cache-Control: must-revalidate
      Content-Length: 52
      Content-Type: application/json
      Date: Wed, 21 Aug 2013 14:00:58 GMT
      Server: CouchDB (Erlang/OTP)

      {
          "error": "missed",
          "reason": "no document to update"
      }

# 10.5.10. `/db/_design/design-doc/_update/update-name/doc-id`

`PUT` `/{db}/_design/{ddoc}/_update/{func}/{docid}`

  Executes update function on server side for the specified document.

  Parameters: | db – Database name ddoc – Design document name func – Update function name docid – Document ID
  Response Headers:
  | X-Couch-Id – Created/updated document’s ID X-Couch-Update-Newrev – Created/updated document’s revision
  Status Codes: | 200 OK – No document was created or updated 201 Created – Document was created or updated 500 Internal Server Error – Query server error

  Function:

      function(doc, req) {
          if (!doc){
              return [null, {'code': 400,
                             'json': {'error': 'missed',
                                      'reason': 'no document to update'}}]
          } else {
              doc.ingredients.push(req.body);
              return [doc, {'json': {'status': 'ok'}}];
          }
      }

  Request:

      POST /recipes/_design/recipe/_update/ingredients/SpaghettiWithMeatballs HTTP/1.1
      Accept: application/json
      Content-Length: 5
      Content-Type: application/json
      Host: localhost:5984

      "love"

  Response:

      HTTP/1.1 201 Created
      Cache-Control: must-revalidate
      Content-Length: 16
      Content-Type: application/json
      Date: Wed, 21 Aug 2013 14:11:34 GMT
      Server: CouchDB (Erlang/OTP)
      X-Couch-Id: SpaghettiWithMeatballs
      X-Couch-Update-NewRev: 12-a5e099df5720988dae90c8b664496baf

      {
          "status": "ok"
      }