How can i populate collections in Firestore Emulator?

2.1k views Asked by At

I have a function which returns a list of objects, I need some way so that i can populate this data in local firestore emulator and not in actual cloud firestore instance. How can I achieve it?

1

There are 1 answers

0
Frank van Puffelen On BEST ANSWER

The Firestore emulator can import data on startup by starting it with:

firebase emulators:start --import=./dir

The data to be imported has to be in a proprietary format though, so you'll want to convert your data into that format by:

  1. Writing it to the Firestore emulator using the regular Firestore API.
  2. Export the data to the import/export format by running firebase emulators:export ./dir.
  3. And then import the data into the emulator on startup as shown above.