Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PG (node-postgres) VS. sequelize

I just want to ask which database module is better, PG or sequelize? I heard that sequelize has sometimes problem with transaction. Thanks

like image 260
noone Avatar asked Oct 24 '14 15:10

noone


People also ask

Does Sequelize use PG?

PostgreSQL requires the use of the pg (or pg-native) npm package. Read more about this here. According to pg's documentation, only pg >= 8.2 is compatible with Node 14. If you're trying to use Sequelize 6 in Node 14 or newer, use that version of pg.

What is PostgreSQL vs Sequelize?

PostgreSQL can be classified as a tool in the "Databases" category, while Sequelize is grouped under "Object Relational Mapper (ORM)". "Relational database" is the primary reason why developers consider PostgreSQL over the competitors, whereas "Good ORM for node. js" was stated as the key factor in picking Sequelize.

Is Sequelize the best ORM?

As you can see there are many pros of using Sequelize as your ORM and it contains rich documentation as well. So, If you are looking for a stable ORM for your project sequelize is one of the best out of all.


1 Answers

PG is a raw driver - it simply allows us to send queries to database, and sequelize is an ORM (object relation mapper - https://en.wikipedia.org/wiki/Object-relational_mapping) - the high level module, that maps objects to database entries.

The usage of any of them depends on the scale of the project. If project is a 100 line of codes utility - I prefer raw driver. If project is quite big and have to be scalable and maintainable - I think sequelize is better.

Also using sequelize with very few changes in code you can change the database you use - from postgresql to mysql/sqlite.

It is worth noting, that you can use both modules in the same project - in part depending on transaction you can use pg, and sequelize for other parts

like image 145
vodolaz095 Avatar answered Oct 03 '22 11:10

vodolaz095