Invoking an update handler via a Cradle nodejs client should be a simple task but I felt like I spent 10 minutes too many, piecing together documentation on it, since its not explicitly documented in the README.md file.
Based on the comments in the pull request where this functionality was added, here's a sample:
Based on the comments in the pull request where this functionality was added, here's a sample:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Let's say you want the client to invoke the equivalent of following URL request: | |
// https://my.iriscouch.com/db_name/_design/my_design_doc/_update/my_handler/my_doc_id?field=title&value=test | |
// You would do this via Cradle like so: | |
var db = adminConnection.database('db_name'); | |
vendDB.update( | |
'my_design_doc/my_handler', | |
my_doc_id, | |
{ | |
'title': 'test' | |
}, | |
function (err, res) { | |
if (err) { | |
console.error(err); | |
} else { | |
console.log(res); | |
} | |
} | |
); |
0 comments:
Post a Comment