Search code examples
firebasegoogle-cloud-firestorefirebase-tools

What is the right setup to develop Firebase Functions with Firestore?


I am developing an iOS app with Firebase. The development works well with remote Firestore cloud data.

Since I have to develop Firebase Functions, as advised in Firebase document, I started to use local emulator to develop Functions.

In order to develop Functions in local Firebase emulator, local Firestore has to be used.

So I ended up developing the app with local Firestore too. I created a lot of collections/documents in local Firestore.

Later, I realized I cannot move the data in local Firestore to my original Firestore Cloud. I found articles explaining how to export remote data and import it into local but not the reverse direction (local -> remote).

Am I missing something here? Or am I making some wrong assumptions in the development setup?


Solution

  • Am I missing something here?

    No.

    Or am I making some wrong assumptions in the development setup?

    Yes.

    The emulator is a completely different piece of software than the cloud hosted service and just used for local testing and debugging. There is no synchronization between them. If you want to do that, you should use the Firebase Admin SDK to and write code to copy data between the two as you need it. You will have to query for all the documents in the emulator, then add those documents to the cloud hosted service.