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.
So, you need to persist some data
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 stores all data in JSON format
- You can easily fetch any data from the database
- You easily send that data to the client
- It's blazing fast, just like Node.js
- You don't have to learn another language just for databases
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?"
You can use any database you want
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.