node-postgres
node-postgres copied to clipboard
Question: is there any method to check whether a client is connected or not
const client=new Client("connectstring"; I know client has connect and end methods to connect to or disconnect from db
1.is there any method to check whether client is in connected state or disconnected state? 2. if client.end() is called, client.connect() cannot be called ,right? I have to create a new instance of Client to connect to db?
- use client.connection._ending which have boolean value. value will be true if the connection already ended, value will be false if connection not yet ended.
- yes you must create another client.
CMIIW