Answer the question
In order to leave comments, you need to log in
How to execute a certain code after a function call?
There is a code:
exports.prepareTransaction = () => {
return new Promise((resolve, reject) => {
pool.getConnection((err, connection) => {
if (err) throw err;
const beginTransaction = promisify(connection.beginTransaction).bind(connection);
const query = promisify(connection.query).bind(connection);
const commit = promisify(connection.commit).bind(connection);
const rollback = promisify(connection.rollback).bind(connection);
resolve({beginTransaction, query, commit, rollback});
});
});
};
let transaction = await connection.prepareTransaction();
try {
await transaction.beginTransaction();
...
await transaction.commit();
}
const commit = promisify(connection.commit( () => connection.release() )).bind(connection);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question