steliosf
steliosf

Reputation: 3879

Can I add listeners to Multiple Databases in Firebase?

Regarding the recent announcement of the multi-database support within a Firebase project, can we add listeners to multiple databases? Or should we connect to maximum one database at a time?

For example, let's say that I have created two databases, DB-1 and DB-2. I want to add a listener for changes in node-A in DB-1 and another listener in node-B in DB-2. Is this possible? I've read the documentation but it's a bit contradicting:

Each app instance only connects to one database at any given moment.

...

If each client needs to connect to multiple databases during a session, you can reduce the number of simultaneous connections to each database instance by connecting to each database instance for only as long as is necessary.

Upvotes: 1

Views: 267

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317968

You can certainly connect to multiple databases at the same time, according to the documentation. There may be cases when you want to reduce the active number of active connections your app is making, especially if you have a lot of shards, each with a lot of activity, so the advice stands for those cases, if this applies to you.

Upvotes: 2

Related Questions