Trigger after document update on couchDB

I am using couchDB and I just wanted to fire an HTTP request when any update is done on the couchDb side. I am updating document using java api (in android app). Thanks in advance, any clue would be appreciated.

+3


source to share


2 answers


CouchDB does not send requests (it only responds to them).

However, you can implement a working script (in node JS for example) that connects to CouchDB and modifies the feed using feed=longpolling

. Then you can keep listening for changes as they occur and react to them in any way you want - for example, send an HTTP request.



If you plan on implementing this in node, the follow npm package might be helpful .

+3


source


You might be able to implement this with PouchDB live sync

like below:



var localDB = new PouchDB('localdb')
var remoteDB = new PouchDB('http://192.168.1.106:5984/remotedb')

localDB.sync(remoteDB, {
    live: true,
    retry: true
}).on('change', function (change) {
    // Something changed
    // trigger appropriate events here
})

      

0


source







All Articles