so, i have 3 queries, i make the third query error on purpose, but it does not rolling back until the first query, it's just rolling back to the second query. Please help !
try {
const task = Fawn.Task();
const winner = new Winner({ type: req.body.type, coupon: req.body.coupon });
await task
.save(Winner, winner)
.update(Transaction, { coupon: req.body.coupon, type: req.body.type, createdAt: query }, {
$set: {
win: "1",
status_trx: "1"
}
})
.update(Transaction, {
status_trx: "2",
type: req.body.type,
createdAt: query
},
{
$set: {
win: "3",
status_trx: "3"
}
}).options({ multi: true });
const result = await task.run({useMongoose: true});
console.log(JSON.stringify(result));
} catch (err) {
console.log(err); // it throw error but does not rolling back until the first query
} finally {
res.send(true);
}
so, i have 3 queries, i make the third query error on purpose, but it does not rolling back until the first query, it's just rolling back to the second query. Please help !