Skip to content

Commit

Permalink
fix(bodies): passing transaction correctly when deleting a body (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
serge1peshcoff authored Sep 16, 2020
1 parent 4fa5829 commit f4f33d1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions middlewares/bodies.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ exports.setBodyStatus = async (req, res) => {
}

// Deleting all the stuff related to body.
await JoinRequest.destroy({ where: { body_id: req.currentBody.id } }, { transaction: t });
await BodyMembership.destroy({ where: { body_id: req.currentBody.id } }, { transaction: t });
await Circle.destroy({ where: { body_id: req.currentBody.id } }, { transaction: t });
await Payment.destroy({ where: { body_id: req.currentBody.id } }, { transaction: t });
await JoinRequest.destroy({ where: { body_id: req.currentBody.id }, transaction: t });
await BodyMembership.destroy({ where: { body_id: req.currentBody.id }, transaction: t });
await Circle.destroy({ where: { body_id: req.currentBody.id }, transaction: t });
await Payment.destroy({ where: { body_id: req.currentBody.id }, transaction: t });
});

return res.json({
success: true,
data: req.currentBody
Expand Down

0 comments on commit f4f33d1

Please sign in to comment.