Skip to content

Conventions

Dominic Barnes edited this page May 21, 2014 · 2 revisions

Most API calls in couchdb-api, unless otherwise specified, use the following conventions:

Return Values

Each API call returns a superagent Request object. In most cases, Request#end() has already been called, so you can't use this object to modify the request. (as of now, I can't think of much use for this)

Callbacks

This library follows the node-style callback convention, making things easier by keeping consistent.

Arguments

Unless otherwise specified, callbacks in this library have the following arguments

  1. err: an error, if one occurred. In the case of a CouchDB-specific error, the object returned will be an instance of CouchError (a special error object exposed by couchdb-api)

    By a "CouchDB-specific error", I mean the response bodies that CouchDB returns directly, for example:

    {
      "error": "not_found",
      "reason": "missing"
    }
  2. body: the response body returned by CouchDB.

    This will not be included when an error has occurred.

  3. res: the superagent Response object

Context

In callbacks, this is set to the object that issued the API call. For example, when calling Document#get(), the callback will recieve the Document object as this.

Clone this wiki locally