javascript - Couchdb's Update Event Handler in Node.js -
i want create app in node.js. app modified document, lets :
{_id: xxx, text: "hello"}
every time document changed, want execute function in node.js app. it's
$db.on('update', function(id){ console.log("there changes in " + id) })
how can node.js ?
you looking couchdb's changes feed. every time document updated in db
, have subscribed to, notification sent. can hear on notification , execute code.
you can subscribe particular document id's. see request options in post request.
also since using node js suggest take @ follow library. makes want lot easier.
example:-
var follow = require('follow'); follow({db: "<database name here>", include_docs:true}, function(error, change) { if(!error) { console.log(change.doc) // updated doc console.log("got alter number " + change.seq + ": " + change.id); } });
javascript node.js couchdb
No comments:
Post a Comment