Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node-postgres vs pg-promise for Nodejs Application

Tags:

I'm going to build a Nodejs application with Postgresql as back end. I'm not going to use ORMs like Sequelize due to poor documentation and performance problems or any other ORM - ORM is an anti-pattern.

I found node-postgres and pg-promise are candidates in this regard. So, can anyone clarify the scenarios which one of the tools is better than the other or which one is way to go with description, provided that node-postgres has been developing since 2010 and pg-promise since 2015.

like image 552
Abdisamad Khalif Avatar asked Oct 24 '16 08:10

Abdisamad Khalif


People also ask

Does PostgreSQL support node JS?

Using node-postgres , you will be able to write Node. js programs that can access and store data in a PostgreSQL database. In this tutorial, you'll use node-postgres to connect and query the PostgreSQL (Postgres in short) database.

What is the difference between pool and client postgres?

You have two options that you can connect to a PostgreSQL server with the node-postgres module. One of the options is to use a single client. The other method is to use a connection pool. However, if your application is using the database very frequently, the pool will be a better option than using a single client.

What does PG promise do?

pg-promise is a Postgres library for Node written on top of the brianc/node-postgres library. It's technically a wrapper for node-postgres and converts the callback interface into a promises based interface.


1 Answers

pg-promise uses node-postgres internally. AFAIK pg-promise is a promise-based set of higher-level APIs on top that you might find useful. I'd recommend using whichever you feel more comfortable with. I'm the author of node-postgres.

like image 71
brianc Avatar answered Oct 11 '22 01:10

brianc