We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Below is a snippet of code I am trying to get working... basically I get the pool and call connect on it to get a single connection.
I call beginTransaction on the connection, run my statements, then call commit or rollback.
The problem with this, is that after 3 calls to this function, the pool stops working and doesn't respond to anything.
Am I doing something wrong here? Should I not be using a pool to do transactions?
export async function executeStatements(statements: Statement[]) { const pool = await getPool(); const connection = await pool.connect(); await connection.beginTransaction(); try { const results = statements.map((statement) => connection.query( statement.sql, statement.parameters as Array<number | string>, ), ); (await Promise.allSettled(results)).forEach((promise) => { if (promise.status === "rejected") { throw Error(); } }); await connection.commit(); } catch (error) { await connection.rollback(); } return; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Below is a snippet of code I am trying to get working... basically I get the pool and call connect on it to get a single connection.
I call beginTransaction on the connection, run my statements, then call commit or rollback.
The problem with this, is that after 3 calls to this function, the pool stops working and doesn't respond to anything.
Am I doing something wrong here? Should I not be using a pool to do transactions?
The text was updated successfully, but these errors were encountered: