Skip to content

Commit

Permalink
fix(campaigns): preload autojoin_body
Browse files Browse the repository at this point in the history
  • Loading branch information
serge1peshcoff committed May 2, 2020
1 parent 8a374fa commit c6d88df
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions middlewares/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ exports.fetchCampaign = async (req, res, next) => {
}

const campaign = await Campaign.findOne({
where: { id: Number(req.params.campaign_id) }
where: { id: Number(req.params.campaign_id) },
include: [{ model: Body, as: 'autojoin_body' }]
});
if (!campaign) {
return errors.makeNotFoundError(res, 'Campaign is not found.');
Expand Down Expand Up @@ -184,7 +185,8 @@ exports.fetchBodyCampaign = async (req, res, next) => {
where: {
id: Number(req.params.campaign_id),
autojoin_body_id: req.currentBody.id
}
},
include: [{ model: Body, as: 'autojoin_body' }]
});

if (!campaign) {
Expand Down

0 comments on commit c6d88df

Please sign in to comment.