iriscouch / follow

Very stable, very reliable, NodeJS CouchDB _changes follower

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple databases

lancecarlson opened this issue · comments

How would you go about creating a node app that could follow multiple databases in one process?

Simply set up a follow feed for each database.
for example:

follow("https://example.iriscouch.com/db1", function(error, change) { ... })
follow("https://example.iriscouch.com/db2", function(error, change) { ... })
// ...

I was under the assumption that the first follow would block and the 2nd follow would never get hit. I guess this assumption is wrong? I will have to try this. Thx!

That's the point of node! Non-blocking I/O. :)

Am 08.07.2013 um 21:49 schrieb Lance Carlson notifications@github.com:

I was under the assumption that the first follow would block and the 2nd follow would never get hit. I guess this assumption is wrong? I will have to try this. Thx!


Reply to this email directly or view it on GitHub.

Yes, and if you want a common function to handle both databases, you can do that yourself.

follow("https://example.iriscouch.com/db1", function(error, change) {
  change(error, "db1", change)
})
follow("https://example.iriscouch.com/db2", function(error, change) {
  change(error, "db2", change)
})

function change(error, db, change) {
  console.log('Change on %d: %j', db, change) // etc.
}