8

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?

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Nurul Sundarani
  • 5,550
  • 3
  • 23
  • 52

1 Answers1

14

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.
Raphael Rafatpanah
  • 19,082
  • 25
  • 92
  • 158
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807