Search code examples
firebasefirebase-realtime-databasegoogle-cloud-firestoregoogle-cloud-functionsfirebase-cli

Start firebase emulator with default database filled with dummy data


Whenever I start the emulator I have to import a database for the realtime database and sometimes make the top level collections manually for firestore.

Is there a way to setup the emulator, such that the databases are already ready?

I don't want this to be filled with all the data from the actual project but rather some dummy data that is suffficient to carry out local development.

Again, I am not asking for this setup to run tests, (as is mentioned here) but rather for daily development.


Solution

  • If you want to import default data when the emulator starts, have a look at the documentation on importing and exporting data, which says:

    You can export data from the Authentication, Cloud Firestore, Realtime Database and Cloud Storage emulators to use as a shareable, common baseline data set.

    And the documentation for the --import flag:

    --import=import_directory

    Optional. Use with the Authentication, Cloud Firestore, Realtime Database or Cloud Storage emulator. Import data saved using the --export-on-exit startup option or the emulators:export command to a running Authentication, Cloud Firestore, Realtime Database or Cloud Storage emulator instance. Any data currently in emulator memory will be [overwritten].