I have been teaching myself web dev (using nodejs, mongodb) for a few days now and have run into a problem.
I have two tables which I need to join, followed by summing certain columns, and finally filtering (using a user specified threshold) based on the value of these sums. I do all this using aggregate pipeline.
The join and creation of columns works fine. To filter, first I create a new column, isAResult, and use match to retain the records that return true for that column. This is how I create isAResult.
{ $project: { isAResult: {$cond: { if: {$gte: ["$totalkcal", val_kcals]}, then: true, else: false }}
where val_kcals is initiated earlier as shown below.
var val_kcals = req.body.val_kcals;
Am I missing something?
via Shashwat Mishra
No comments:
Post a Comment