No, you do not have to use Mongodb with Node.js

Search for a command to run...

No comments yet. Be the first to comment.
The missing node.js framework

Part 2 - how to prepare for internship

The story how I got my first internship

There are 3 ways to declare a variable in Javascript: using one of the keywords var, const or let. Prior to ES6, var used to be the only way to declare a variable. You had no other choice. However, it had some weird and unexpected behavior, which oft...

Vast majority of beginner nodejs tutorials use mongodb for the database. For simplicity sake, this is fine for beginners. It saves them the hassle of dealing with SQL table relations, so they can just stick any data in and get it out to render it on the page.
After learning the basics of building apps with Node.js, you may decide to build an app on your own. The courses and tutorials you learned from taught you Mongodb. It seems like next logical step:
It seems like Mongodb is hand crafted for Javascript environment. For the first time ever, we can use one the same language in all 3 layers of our applications:
Knowing this, its easy for beginners to fall into a trap of thinking Mongodb is the only database to use to persist data in Node.js apps. Experienced developers, coming to Node.js from other technical backgrounds, often ask: "Can I use Postgres/Mysql with Node.js?"
Node.js is Javascript runtime environment. It is a symbiosis between a Javascript interpreter and some C++ code that let's you write server or desktop apps with Javascript language.
This was not possible before, since Javascript is a language meant to be use in the context of a browser, thus confined within it for security reasons. Node.js sets Javascript free.
Having Javascript execute outside of browsers allows us to do things such as networking, file system manipulation, getting operating system information, multi-threading (even though Javascript is a single-threaded language) and much more that was done with most other languages like Java, C#, PHP, Ruby, Python, etc.
Since a Node.js app runs in the memory, a node app would need to preserve data in the database so it doesn't get lost. Which database can you use with node? Any database that you can find a driver for, which is all of them.
There is nothing in Node.js that dictates your choice of database. It does not favor any particular database system, neither relational nor non-relational.
Database is an external service from the point of view of a node app. You only need a driver and a running instance of a database to use it. Node.js doesn't care about that at all.
Use whatever database you want.