22

I just released my first MVP app on the iOS app store, and its doing really well. The app is essentially a chat application that uses Firebase.

Since I'm using Firebase, it's really hard to do complex queries. And in order for me to add cool features to my app. I need to be able to do that.

I decided to use NodeJs and MongoDB to run my app. However I don't want to kill what I have going right now. Is there any way, to migrate the data I have in Firebase to MongoDB and keep it in sync real time?

I was considering doing an observeSingleEvent to download all the data. and then using childadded, childremoved to keep everything in sync realtime.

Is this going to be an issue if you have a lot of active users on the app?

Also, is there a service that offers to do that?

AL.
  • 36,815
  • 10
  • 142
  • 281
slimboy
  • 1,633
  • 2
  • 22
  • 45
  • Related but not a dupe: https://stackoverflow.com/questions/42672790/firebase-for-complex-query-a-no-go Have you considered that maybe you don't need to migrate to support your complex queries? – Paul May 06 '19 at 18:51
  • What other solution replicates Firestore snapshot listeneres? That is a unique solution as I understand – giorgio79 Oct 25 '22 at 07:16

2 Answers2

29

Congratulations on the app. The problem you are facing is a classic database migration problem. My usual recommendation is the approach you outline: make a copy of the data into the new system, then keep them in sync while you move over functions to read from the new database, then finally turn off the old database completely.

For moving to MongoDB, I would recommend Stitch which uses Atlas to store data in the cloud.

This has a number of advantages: - Access to full MongoDB functionality & scalability - No lock-in for which cloud provider you use, or services you make use of - Powerful, fine-grained access controls, which you control

From Firebase, you should be able to export existing data as JSON, and them import into MongoDB with mongoimport. The docs have some create tutorials and example apps to get you started.

Nic Cottrell
  • 9,401
  • 7
  • 53
  • 76
7

I see this is an old post, I hope your migration was a success!

I would like to take the opportunity to point others that want to migrate away from Firebase to a new open source alternative called AceBase, which is inspired by Firebase and has powerful indexing and querying options. AceBase uses the same syntax as Firebase, so it's actually possible to keep most of your existing Firebase code and it should work with AceBase.

On top of that, AceBase is able to cache your data in the browser (IndexedDB) so your app can be used offline. Any changes made while offline are automatically synchronised with the server upon reconnect.

AceBase also has a unique feature called "live data proxies" that allows you to code against an in-memory object that contains your data. All local changes to the object are automatically stored in the database and synced with the server, and remote changes are reflected in your local object in realtime.

Check out AceBase at npm: https://www.npmjs.com/package/acebase