# 1.5.9. `/{db}/_design/{ddoc}/_show/{func}`

Warning

Show functions are deprecated in CouchDB 3.0, and will be removed in CouchDB 4.0.

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

    - 401 Unauthorized – Unauthorized request to a protected API

    - 403 Forbidden – Insufficient permissions / Too many requests with invalid credentials

    - 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

# 1.5.10. `/{db}/_design/{ddoc}/_show/{func}/{docid}`

Warning

Show functions are deprecated in CouchDB 3.0, and will be removed in CouchDB 4.0.

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

    - 401 Unauthorized – Unauthorized request to a protected API

    - 403 Forbidden – Insufficient permissions / Too many requests with invalid credentials

    - 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.

# 1.5.11. `/{db}/_design/{ddoc}/_list/{func}/{view}`

Warning

List functions are deprecated in CouchDB 3.0, and will be removed in CouchDB 4.0.

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

    - 401 Unauthorized – Unauthorized request to a protected API

    - 403 Forbidden – Insufficient permissions / Too many requests with invalid credentials

    - 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

# 1.5.12. `/{db}/_design/{ddoc}/_list/{func}/{other-ddoc}/{view}`

Warning

List functions are deprecated in CouchDB 3.0, and will be removed in CouchDB 4.0.

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

    - 401 Unauthorized – Unauthorized request to a protected API

    - 403 Forbidden – Insufficient permissions / Too many requests with invalid credentials

    - 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

# 1.5.13. `/{db}/_design/{ddoc}/_update/{func}`

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

    - 401 Unauthorized – Unauthorized request to a protected API

    - 403 Forbidden – Insufficient permissions / Too many requests with invalid credentials

    - 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"
      }

# 1.5.14. `/{db}/_design/{ddoc}/_update/{func}/{docid}`

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

    - 401 Unauthorized – Unauthorized request to a protected API

    - 403 Forbidden – Insufficient permissions / Too many requests with invalid credentials

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

      PUT /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"
      }