Complete the code to import the pg module.
const { Client } = require('[1]');You need to import the pg module to use PostgreSQL in Node.js.
Complete the code to create a new client with connection details.
const client = new Client({ connectionString: '[1]' });The connection string must start with postgresql:// and include user, password, host, port, and database name.
Fix the error in the code to connect the client asynchronously.
await client.[1]();The method to start the connection is connect(), and it returns a promise.
Fill both blanks to query the database and get results.
const res = await client.[1]('[2]');
Use query method with a SQL string to get data from the database.
Fill all three blanks to close the client connection properly.
try { await client.[1](); // do queries } finally { await client.[2](); console.[3]('Connection closed'); }
You connect first, then disconnect in finally block, and log a message with console.log.
