iriscouch / follow

Very stable, very reliable, NodeJS CouchDB _changes follower
Apache License 2.0
393 stars 82 forks source link

Multiple databases #33

Closed lancecarlson closed 11 years ago

lancecarlson commented 11 years ago

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

klaemo commented 11 years ago

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) { ... })
// ...
lancecarlson commented 11 years ago

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!

klaemo commented 11 years ago

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.

jhs commented 11 years ago

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.
}