How to use node-postgres in node.js?

I'm new and poorly understood right I do. Nowhere else to ask )
OK, I hooked up the dependency npm i pg. created the file db.js with the connection settings.

5B1JnN8E2O8.jpg
in the file routes.js call db and make the query run successfully.
JshixS37_g0.jpg
Do I need to close the connection or what ? If I have many controllers to the ranting
and every time I call db - creates a new instance of a connection after all.
June 14th 19 at 19:04
1 answer
June 14th 19 at 19:06
Look at strontium https://node-postgres.com/features/pooling
Just what you need.

Find more questions by tags Node.jsPostgreSQL