Emulator support for database commands
See original GitHub issueIt would be great to be able to use the database commands, such as database:get
, database:set
, and firestore:delete
to interact with the emulator suite.
Since the emulator mentions setting the environment variable FIREBASE_DATABASE_EMULATOR_HOST=localhost:9000
, then maybe it could work by detecting that variable.
To load the projects path from the emulator instead of the hosted instance, it would be great do the following:
FIREBASE_DATABASE_EMULATOR_HOST=localhost:9000 firebase database:get /projects
It would also be great to have this for Firestore delete:
FIRESTORE_EMULATOR_HOST=localhost:8080 firebase firestore:delete /projects/ABC123
NOTE: This has already been submitted as a feature request through the support page. The response was that the feature would be created on my behalf - creating this since one doesn’t appear to have been created.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (7 by maintainers)
In #2109 this was fixed for almost all commands where emulator support is reasonable. All you have to do is
export FIREBASE_DATABASE_EMULATOR_HOST=...
orexport FIRESTORE_EMULATOR_HOST=....
in your environment and the commands will target the emulators.For example:
or:
The big exception is
database:remove
because that command is implemented in a pretty complex way and I didn’t feel comfortable modifying it. For those who needdatabase:remove
in the emulator please file a new issue and we will discuss it there, I think this broad umbrella issue should be closed.All
database:*
andfirestore:*
commands which do NOT support the emulators will now warn you if you try to execute them with the environment variables set to make sure you don’t accidentally affect production.@yuchenshi we recently started setting
FIRESTORE_URL
inemulators:foo
so this won’t be a more breaking change (although we didn’t consider that one breaking the time I can see how it is).The good news is if anyone gets broken it will be: you accidentally didnt write to prod. Which is way better than the reverse.