How To Prevent Firebase Firestore Emulator From Clearing The Database At Exit?

Viewed 4218

I'm Planning To Use Firebase - Firestore Emulators For Handling Some Huge Amount Of Data That's Coming From A Websocket.

I just need to process the data locally in realtime.

Firestore Emulator Is A great choice since it has all the features I need. But the issue is it clears the database every time the Emulator is turned off. is there any config or settings that can change this behaviour?

if it is not possible. can somebody tell me any other Approach to use firestore locally? or any other alternative to firebase that I can use locally.

3 Answers

With the recent updates to Firebase Emulator, you use export the data when the emulator is running and import when it starts again.

To export the data

firebase emulators:export <export-directory>

To start and import the emulator

firebase emulators:start --import <export-directory>

I've managed this starting Firebase emulator with parameters to export data on exit and import existing one:

firebase emulators:start --import=exported-dev-data --export-on-exit=exported-dev-data

This way the emulator always export the data I've generated to folder exported-dev-data, and loads it back when starting again.

Currently you need to write code to populate the database during each run of the emulator.

If you would like to see different behavior, please file an issue on GitHub.

Related