Mayor
Mayor

Reputation: 333

Firebase cloud functions emulators always write to a default database

I recently set up the firebase emulators to run my cloud functions locally. After setup, the cloud functions triggered successfully but any write to the real-time database does not reflect in the corresponding local database emulator UI. e.g when I use

snapshot.after.ref.parent.child('busy').set(true)

So I tried exporting and importing the real-time data and I discovered that all database write from cloud functions was being saved in a default database with name localhost:4000/?ns=pick2-c468b-default-rtdb and not the database that is triggering the write event.

Is this the default behaviour of the emulator and how do I go about changing or fixing it?

Upvotes: 2

Views: 385

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598807

Writes to snapshot.after.ref should go to the database that triggered the Function.

If that is not happening for you, I recommend reporting a bug with a minimal repro on the repo (which should include an entire Cloud Function, and not just the line that you think is going wrong.

Upvotes: 1

Related Questions