node.jspostgresqlnode-postgresnode-pg-pool

Difference between pg and pg-pool module in NodeJs?


I am working on NodeJs project which involves connection with PostgreSQL database. I came across two packages, namely, pg and pg-pool. Creator of these two packages is same, so there must be some differences in the functionalities of these two packages. Any idea, what are those? Which of the packages should be preferred?


Solution

  • It is possible to write an app by using the Pool object only, but it still must be included via the main pg driver:

    const Pool = require('pg').Pool;
    

    pg-pool only implements the pool itself + the querying interface. There is a lot more to the overall library - all resides in the pg module.

    And you only include the pg within your package.json.