MongoDB vs Firebase

I plan on using Firebase for my API because of it’s simplicity, and already have code written for it, but I’m wondering now whether Firebase was actually the best option. I find it a lot easier to use and set up than MongoDB, but I was wondering if there was a downside of using Firebase.

I’ve used both before and haven’t had any issues.

Definitely use mongoose. Why this, well, you already have a VPS and you can self host the DB so that you don’t have to pay for hosting. But Firebase is owned by Google and a bit harder to use.

2 Likes

Not…exactly

1 Like

Should I use MongoDB 3.something (i forgot the latest version), or MongoDB Atlas?

I use Mongoose Atlas on their free hosting plan

1 Like

Okay. I have experience using both, although sometimes I find MongoDB quite a pain in the ass to use compared to Firebase. The extra security and reliability is worth it though.

One more question. Sorry if this isn’t the right place. My primary language is Lua, and returns are kind of different in that language. In Node.js I always get undefined when returning. I’ve heard a lot about using callbacks and everything but I’m not really sure how to actually use them.


function test (data) {
  if (data) { 
    return true
  }
}

console.log(test()) --undefined

There is no value passed for the data argument, so if (data) doesn’t execute its statement, so no return value is specified.

An example of a callback is where you pass a function f in as an argument to a function g, which starts a long-running process and returns. function f is run when the long process has finished.

The code would have to look like this:

function test(data) {
if (data) {
return true
} else {
return false
  }
 }

Got it. Thanks.