title: How to incorporate $lt and $divide in mongodb
body: <p>I am a newbie in MongoDB but I am trying to query to identify if any of my field meets the requirements. </p>
  
  <p>Consider the following:</p>
  
  <p>I have a collection where EACH document is formatted as:</p>
  
  <pre><code>{  
      "nutrition" : [
          {
              "name" : "Energy",
              "unit" : "kcal",
              "value" : 150.25,
              "_id" : ObjectId("fdsfdslkfjsdf")
          }
          {---then there's more in the array---}
      ]
      "serving" : 4
      "id": "Food 1"
  }
  </code></pre>
  
  <p>My current code looks something like this:</p>
  
  <pre><code>db.recipe.find(
      {"nutrition": {$elemMatch: {"name": "Energy", "unit": "kcal", "value": {$lt: 300}}}},
      {"id":1, _id:0}
      )
  </code></pre>
  
  <p>Under the array nutrition, there's a field with its name called Energy with it's value being a number. It checks if that value is less than 300 and outputs all the documents that meets this requirement (I made it only output the field called id). </p>
  
  <p>Now my question is the following:</p>
  
  <p>1) For each document, I have another field called "serving" and I am supposed to find out if "value"/"serving" is still less than 300. (As in divide value by serving and see if it's still less than 300)</p>
  
  <p>2) Since I am using .find, I am guessing I can't use $divide operator from aggregation?</p>
  
  <p>3) I been trying to play around with aggregation operators like $divide + $cond, but no luck so far.</p>
  
  <p>4) Normally in other languages, I would just create a variable a = value/serving then run it through an if statement to check if it's less than 300 but I am not sure if that's possible in MongoDB</p>
  
  <p>Thank you.</p>