DEV Community

Oyetoke Toby
Oyetoke Toby

Posted on

Which is the Best Database for NodeJS?

Which of the below is your preferred database for Node:

  • MySQL
  • PostgreSQL
  • MongoDB
  • SQLite

Top comments (7)

Collapse
 
shubho profile image
Shubhojyoti

The database you choose will depends on your project needs. If I need strict relations in my data I do not use MongoDB. In such cases, SQLite usually serves my purpose for POCs and in prod I like PostgresSQL. I love using Sequelize ORM docs.sequelizejs.com/ which supports MySQL/PostgreSQL/SQLite. For apps that involves file storage I use MongoDB.

Collapse
 
dechamp profile image
DeChamp

+1 for sequelize

Collapse
 
schaan profile image
Schaan Alq.

+1 for Sequelize!

Collapse
 
dmfay profile image
Dian Fay

I'm partial to Postgres in general but the most important considerations are really your data model and other requirements, not what you're running. If your data model is hierarchical with few relationships (unusual, but it happens) MongoDB is built for that. If your project is small-scale enough that you're okay with the database living on the same filesystem and having only one active connection at a time, SQLite will do perfectly well, although if you've already got Postgres running there's no reason not to use that either.

Collapse
 
cbrintnall profile image
Christian Brintnall
  • SQLite for when I'm doing a very quick PoC.
  • MongoDB for when I'm trying to get that PoC to production quickly, and just needs a basic data store.
  • PostgreSQL when I need a powerful database in production and I'm not necessarily in a sprint to the end.
Collapse
 
devdrake0 profile image
Si

This is such an incredibly broad question.

The choice of database should not be decided because it's someones "preferred" technology.

What's the best database for the project you're working on - that's the question you should be asking.

That's the question you should be asking of every technology you use. Is Node even the right language for the job you're trying to do?

Collapse
 
schaan profile image
Schaan Alq.

MongoDB is what I'm using for almost anything if I have the power to choose. Because as a frontend developer I really don't want to spend too much time on creating subtle data model schemes for lightweight projects. But we use a lot postgres in the real production.