Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating from Firebase to NodeJS MongoDB

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?

like image 533
slimboy Avatar asked Jan 31 '17 04:01

slimboy


People also ask

Can I migrate from Firebase to MongoDB?

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.

Is it possible to migrate from Firebase?

Firebase is a JSON data base where the database structure is not tabular, it is a tree. So you won't be able to Migrate the database as it is, you will have to redesign the data schema to fit into a tree structure.

Can I use both Firebase and MongoDB?

Firebase database is a fork of MongoDB. You can take advantage of all built-in features of Firebase over MongoDB.


2 Answers

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.

like image 154
Nic Cottrell Avatar answered Oct 19 '22 01:10

Nic Cottrell


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

like image 25
Ewout Stortenbeker Avatar answered Oct 19 '22 02:10

Ewout Stortenbeker