Comparing version 4.0.8 to 5.0.0
# CHANGELOG | ||
*versions follow [SemVer](http://semver.org)* | ||
## 5.0.0 - 2020-08-10 | ||
**BREAKING CHANGES**: [`db.fetch`](https://github.com/maxlath/blue-cot#fetch) now returns a { docs, errors } object | ||
## 4.0.0 - 2019-12-31 | ||
@@ -37,3 +40,2 @@ **BREAKING CHANGES**: | ||
* Added [`db.fetch`](https://github.com/maxlath/blue-cot#fetch) | ||
* Added `db.fetch` | ||
@@ -40,0 +42,0 @@ ## 3.0.0 - 2017-01-14 |
@@ -191,3 +191,4 @@ const querystring = require('querystring') | ||
fetch: async keys => { | ||
fetch: async (keys, options) => { | ||
const throwOnErrors = options != null && options.throwOnErrors === true | ||
const { rows } = await API.viewKeysQuery('_all_docs', keys, { include_docs: true }) | ||
@@ -201,6 +202,4 @@ const docs = [] | ||
} | ||
if (errors.length > 0) { | ||
throw errors_.new('docs fetch errors', 400, { keys, errors }) | ||
} | ||
return docs | ||
if (throwOnErrors && errors.length > 0) throw errors_.new('docs fetch errors', 400, { keys, errors }) | ||
return { docs, errors } | ||
}, | ||
@@ -207,0 +206,0 @@ |
{ | ||
"name": "blue-cot", | ||
"description": "CouchDB library with a simple, functional-programing-friendly API, returning Bluebird promises", | ||
"description": "CouchDB library with a simple, functional-programing-friendly API, returning promises", | ||
"keywords": [ | ||
@@ -8,4 +8,5 @@ "couch", | ||
"promise", | ||
"promises", | ||
"bluebird" | ||
"async", | ||
"await", | ||
"promises" | ||
], | ||
@@ -24,3 +25,3 @@ "scripts": { | ||
], | ||
"version": "4.0.8", | ||
"version": "5.0.0", | ||
"main": "lib/cot.js", | ||
@@ -27,0 +28,0 @@ "dependencies": { |
@@ -233,12 +233,12 @@ [CouchDB](http://couchdb.org/) library with a simple, functional-programing-friendly API. | ||
#### fetch | ||
Takes doc ids, returns docs | ||
Takes doc ids, returns docs. | ||
```js | ||
const docs = await db.fetch([ 'doc-1', 'doc-2', 'doc-3' ]) | ||
const { docs, errors } = await db.fetch([ 'doc-1', 'doc-2', 'doc-3', 'some-non-existing-doc' ]) | ||
docs[0]._id === 'doc-1' // true | ||
docs[1]._id === 'doc-2' // true | ||
docs[2]._id === 'doc-3' // true | ||
errors[0].key === 'some-non-existing-doc' // true | ||
errors[0].error === 'not_found' // true | ||
``` | ||
(That's pretty much the same thing as `db.allDocsKeys` but with the query object set to `{ include_docs: true }`) | ||
#### changes | ||
@@ -245,0 +245,0 @@ Queries the changes feed given the specified query. `query` may contain the following keys: |
31883
506