Closed tracker1 closed 2 years ago
Would improve usability to have an async use function that accepts a method that returns a promise in order to more easily scope the usage.
use
const result = await pool.use(async (client) => { // use client return "some result"; });
// rough implementation pool.use = async function(fn) { const client = await pool.acquire(); try { const result = await fn(client); pool.release(client); return result; } catch (error) { // destroy may not be appropriate, but probably safest action. pool.destroy(client); throw error; } };
This was addressed in or before v3.4.2 - see ceff50d843f1569b43670f37ff205024955d21e5
Would improve usability to have an async
use
function that accepts a method that returns a promise in order to more easily scope the usage.