Comparing version 5.0.1 to 6.0.0
# CHANGELOG | ||
*versions follow [SemVer](http://semver.org)* | ||
## 6.0.0 - 2020-08-10 | ||
**BREAKING CHANGES**: [`db.update`](https://github.com/maxlath/blue-cot#update) stops to create empty (`{ _id }`) docs when the updated doc can't be found, rejecting with a 404 instead. | ||
## 5.0.0 - 2020-08-10 | ||
@@ -5,0 +8,0 @@ **BREAKING CHANGES**: [`db.fetch`](https://github.com/maxlath/blue-cot#fetch) now returns a { docs, errors } object |
@@ -76,10 +76,5 @@ const querystring = require('querystring') | ||
if (++attempt > 10) throw errors_.new('too many attempts', 400, { docId, fn }) | ||
let doc | ||
// Throw if the doc doesn't exist | ||
const doc = await db.get(docId) | ||
try { | ||
doc = await db.get(docId) | ||
} catch (err) { | ||
if (err.statusCode === 404) doc = { _id: docId } | ||
else throw err | ||
} | ||
try { | ||
const res = await db.put(fn(doc)) | ||
@@ -86,0 +81,0 @@ if (res.ok) return res |
@@ -24,3 +24,3 @@ { | ||
], | ||
"version": "5.0.1", | ||
"version": "6.0.0", | ||
"main": "lib/cot.js", | ||
@@ -27,0 +27,0 @@ "dependencies": { |
@@ -207,4 +207,2 @@ [CouchDB](http://couchdb.org/) library with a simple, functional-programing-friendly API. | ||
If `updateFunction` needs to do asynchronous work, it may return a promise. | ||
#### bulk | ||
@@ -211,0 +209,0 @@ `POST /<dbName>/_bulk_docs` |
32154
508
350