Bluebird-based Cot fork
Installing
npm install blue-cot
Differences with Cot
- Returns Bluebird promises
- Class-less, thus a different initialization, but the rest of the API stays the same
- Consequently,
blue-cot
is this
-free: no need to bind functions contexts! 4xx
and 5xx
responses will return rejected promises (should be handled with .catch
)- Adds some view functions goodies
Initialization
const bluecot = require('blue-cot')
const config = {
hostname: 'localhost'
port: 5984,
ssl: true
auth: 'username:password'
user: 'username'
pass: 'password'
debug: true
}
const getDbApi = bluecot(config)
const db = getDbApi('some-db-name')
Those are the same than for cot-node
. Just remember this difference in error handling: here, 4xx
and 5xx
responses from CouchDB will return rejected promises (should be handled with .catch
)
- docUrl
- info
- get
- exists
- put
- post
- batch
- update
- delete
- bulk
- buildQueryString
- viewQuery
- view
- allDocs
- viewKeysQuery
- viewKeys
- allDocsKeys
- changes
View functions
To access those, pass a design doc name as second argument
const db = getDbApi('some-db-name', 'some-design-doc-name')
- viewCustom
- viewByKeysCustom
- viewByKey
- viewFindOneByKey
- viewByKeys
see lib/view_functions
If you find this module useful, consider making a PR to improve the documentation