cloudant-upsert
A no-dependency module that adds an upsert
function to the nodejs-cloudant module.
Install
npm install cloudant-upsert
Usage
The following adds the upsert
function to a cloudant
instance
var Cloudant = ;var cloudant = ;cloudant;
Examples
Promises
In the example below prevdoc
contains null
or the previous doc
cloudantdb ;
Callbacks
In the example below prevdoc
contains null
or the previous doc
cloudantdb
API
Promise API
upsert(id, function(prevdoc)
)
param | description |
---|---|
id |
The document id to upsert |
function(prevdoc): doc |
A function that provides the previous document (or null when inserting a new doc) as input. You must return the document to upsert. |
Callback API
upsert(id, function(prevdoc), function(err, res)}
param | description |
---|---|
id |
The document id to upsert |
function(prevdoc): doc |
A function that provides the previous document (or null when inserting a new doc) and returns a new document to upsert |
function(err, res): void |
A Node.js error first callback |