Always use .exec() for .find*() and .update() (#8361)

* add exec where missing in /models

* ix taskManager query

* fix top-level controllers

* fix api-v3 controllers
This commit is contained in:
Matteo Pagliazzi
2017-01-04 16:49:43 +01:00
committed by GitHub
parent 6cc359a935
commit 518b874f64
13 changed files with 93 additions and 51 deletions

View File

@@ -58,7 +58,7 @@ api.checkout = {
if (sub) {
if (sub.discount) {
if (!req.query.coupon) throw new BadRequest(res.t('couponCodeRequired'));
coupon = await Coupon.findOne({_id: cc.validate(req.query.coupon), event: sub.key});
coupon = await Coupon.findOne({_id: cc.validate(req.query.coupon), event: sub.key}).exec();
if (!coupon) throw new BadRequest(res.t('invalidCoupon'));
}
@@ -114,7 +114,7 @@ api.checkout = {
};
if (gift) {
let member = await User.findById(gift.uuid);
let member = await User.findById(gift.uuid).exec();
gift.member = member;
if (gift.type === 'subscription') method = 'createSubscription';
data.paymentMethod = 'Stripe (Gift)';