阅读文档后:https ://github.com/brianc/node-pg-pool ,我有点担心重用该new Pool()方法。
文档建议我需要放置new Pool()之前exports,return就像这样
// db.js
const pool = new Pool();
module.exports = () => { return pool; }
这样我可以重用Pool直到idleTimeoutMillisor client.release(),通过使用require()其他文件例如:
const connect = require('./db')
connect().query(' .... ');
如果这是正确的,它是如何工作的?node.js 是否缓存new Pool(), 因为它不在里面module.exports?