DEV Community 👩‍💻👨‍💻


Posted on

NodeJS & PostgreSQL: ORM Overview


In the last two parts, we learned how to connect a database to a server:

ORM (Object-Relational-Mapper)

What does an ORM do?

In short, an ORM is a layer between the server and the database.
The server talks with the ORM and the ORM talks to the database.
The ORM creates objects, that map to the relational data.
It handles your queries, so you don't have to write native SQL, you can query the database with your application language.

List of ORMs:

  • sequelize: Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server
  • TypeORM: Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server, Oracle, sql.js, CockroachDB
  • objection: Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server, Oracle, Amazon Redshift

Comparison on npmtrends

If you use MongoDB, you can use an ODM, e.g. mongoose.


  • you don't have to learn/know/write SQL, because the ORM handles it
  • it will be easier to change your database dialect
  • your application is less vulnerable to SQL injections


  • you have to learn the ORM
  • one additional layer of abstraction decreases the speed (theoretically)

Further Reading

Wiki: ORM


  • Do you use an ORM/ODM (e.g. Mongoose)? Which one? Why?

Top comments (2)

bradtaniguchi profile image

I currently am using mongoose for a side project I've been working on for the following reasons:

  1. Its been a few years since I even looked at SQL, been working on NoSQL lately, so I stuck with it.
  2. Its a side project, I'd rather build it faster with NoSQL+ORM
  3. Its still pretty relational, and could 100% of been done with an SQL solution, but again NoSQL gives me more flexibility out of the box to change/update stuff as I need
  4. mlab provides a generous free tier which is great 😄

I don't believe the hype of NoSQL being the future. SQL is here to stay, but this doesn't mean NoSQL doesn't have its place :)

hazriqpedia profile image
Hazriq Ishak

I have the same case and yes, I don't think I'm that into NoSQL.

At start, Mongo seems easier. I dont have to create the schema and my data can be anything. After a while, when the data is a lot more than before, and I need to generate a report, it will start to get messy.

Stop sifting through your feed.

Find the content you want to see.

Change your feed algorithm by adjusting your experience level and give weights to the tags you follow.