1

When we use firebase in RN, we let the app directly send a request to firebase.

But why when we use MongoDB, we let the app sends requests to the backend server first, and then let the server to send request to the database? This is different from the firebase flow.

Aron
  • 169
  • 8
  • Related: [JDBC vs Web Service for Android](https://stackoverflow.com/q/15853367/295004) – Morrison Chang Dec 24 '21 at 01:28
  • MongoDB fully supports REST calls from the client so along with @FrankvanPuffelen correct answer (use Realm) you can also use REST calls. More importantly though, those two platforms are totally different in their approach. Firebase is an event driven **online first** database, where the intention is your data is stored in Firebase (on their server). MongoDB (Realm) is an **offline first** database where app data is stored locally first and later sync'd to the server. Two totally different approaches, so yes, the flow is different and can further vary depending on your use case. – Jay Dec 25 '21 at 14:37

1 Answers1

2

While it is possible to use MongoDB as a traditional database, and put your own server between the database and the client-side application logic, it is also possible to allow the client-side application to directly access the database with MongoDB Realm.

You could do the same with Firebase: you can disallow all access from client-side applications in security rules and then only use your own server-code to access the database.

Neither approach is pertinently better than the other, so you should pick what's the best fit for your use-case, what you're most comfortable with, or what you want to learn more about.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807