I have three arrays of coupon_ids, id_counter and Incre_ctr. Now the value of coupon_id for any index is present in the same index in id_counter and in increase_ctr. So for coupon_id "584559bd1f65d363bd5d25f0" the id_counter value is 200, and the increase_ctr is 5.
coupon_ids = ["584559bd1f65d363bd5d25f0", "584559bd1f65d363bd5d25f1", "584559bd1f65d363bd5d25f2", "584559bd1f65d363bd5d25f4"]; id_counter = [200, 300, 400]; increase_ctr = [5, 6, 7]; couponmodel.findAndUpdate({'_id' : { $in : coupons_ids }, "id_counter": id_counter[index] /* how to get id_counter corresponding to index which is matched inside $in */}, { id_counter: new_id_counter, $inc: {curr_ctr: increase_ctr /* how to get increate_ctr corresponding to index which is matched inside $in */} }, function(err, numberAffected, raw){ if(err){ } else { } });
Now, can someone tell me how I can write the above request so that for coupon_id [index] I can use "id_counter" = id_counter [index] and "Incre_ctr" = increase_ctr [index] in the request.
If we could use $ update with an aggregate, then my problem will be solved easily, but since Aggregates does not support $ update, how can I solve my problem.
source share