I'm trying to achieve a very simple thing:
START TRANSACTION;
DELETE FROM table WHERE id = 1;
ROLLBACK;
Running this on the postgres database works perfectly. With massive.js it doesn't:
this.db.run(
"START TRANSACTION",
[]
);
setTimeout(() => {
this.db.run(
"DELETE FROM table WHERE id = $1"
[1]
);
}, 2000);
setTimeout(() => {
this.db.run(
"ROLLBACK;"
[]
);
}, 4000);
It doesn't rollback the changes, just deletes from the database. COMMIT doesn't work as well. What's wrong?
Is there some way to dump queries order?
Massive uses pg-promise underneath, which in turn supports transactions:
See also:
Monitoring Queries shows you how to do it, or you can add event query handler within
db.driverConfigobject when initializingmassive.