question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Emulator support for database commands

See original GitHub issue

It 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:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
samtsterncommented, Apr 9, 2020

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=... or export FIRESTORE_EMULATOR_HOST=.... in your environment and the commands will target the emulators.

For example:

# Assume the database emulator is running on port 9000
FIREBASE_DATABASE_EMULATOR_HOST=localhost:9000 firebase database:get /foo/bar

or:

# Assume the direstore emulator is running on port 8080
FIRESTORE_EMULATOR_HOST=localhost:8080 firebase firestore:delete --recursive /foo

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 need database: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:* and firestore:* 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.

1reaction
samtsterncommented, Apr 6, 2020

@yuchenshi we recently started setting FIRESTORE_URL in emulators: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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Start the emulator from the command line - Android Developers
Use the emulator command to start the emulator, as an alternative to running your project or starting it through the AVD Manager. Here's...
Read more >
Connect your app to the Realtime Database Emulator - Firebase
Local Emulator Suite supports emulation of real Firebase projects and demo projects. Project type, Features, Use with emulators. Real. A real Firebase project ......
Read more >
Command-line and PowerShell reference for Azure Cosmos ...
Learn the command-line parameters for Azure Cosmos DB Emulator, how to control the emulator with PowerShell, and how to change the number of ......
Read more >
Terminal | DataGrip Documentation - JetBrains
Initially, the terminal emulator runs with your default system shell, but it supports many other shells, such as Windows PowerShell, Command ...
Read more >
Running the Datastore Emulator - Google Cloud
In addition, the emulator can help you generate indexes for your production Datastore instance and delete unneeded indexes. This page guides you through ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found