DEV Community

Discussion on: Should i use an ORM? When to use it? Which one?

Collapse
 
rolfstreefkerk profile image
Rolf Streefkerk

An ORM always has trade offs between performance (you're loading in extra libraries and at run time it needs to translate model to query) and convenience.

The other think is around tooling support, Sequelize is I think the biggest ORM for Node, takes care of a lot of the connectivity with databases and basic querying.

Then there are tools around data validation with JSON Schema that can be integrated with Sequalize that further remove the need to program this yourself.

In the end, there's a lot of benefit using this tooling to speed up development with relatively little down side.

If you want to learn the nitty gritty details on how it actually works, I would say do not use an ORM but write everything yourself with the basic Postgres API, it's a good learning experience.

Then for larger projects it probably makes sense to start using tooling to automate / generate code that is then considered to be boiler plate (you know how it works). Even with an ORM, you can always run custom queries against the database if you need to.

I hope that helps