title: Mongoose - find matching array values
body: <p>I'm creating a REST API with Node.js using Mongoose to access my backend MongoDB database. I have an array (variations) inside of one of my collections (also variations) and need to retrieve the object in the array that matches a provided value.</p>
  
  <p>So far I've got this which returns an empty value...</p>
  
  <pre><code>//Get variation by ID
  app.get('/v1/:id', async (request, response) =&gt; {
      try {
          var result = await variationsModel.find({ 'variationID': request.params.id }).exec();
          response.send(result);
      } catch (error) {
          response.status(500).send(error);
      }
  })
  </code></pre>
  
  <p>And here's the model I've defined in the API...</p>
  
  <pre><code>const variationsModel = mongoose.model("variations", {
      "variations": [
          {
          "variationID": String,
          "custID": String,
          "projID": String,
          "variationTitle": String,
          "variationDesc": String,
          "variationStatus": String,
          "variationChargeable": String,
          "variationCost": String,
          "requireMaterial": String,
          "variationRequestor": String,
          "variationCreationDate": String,
          "variationImages": [
              {
              "imageId": String
              }
          ],
          "variationCategory": String
          }
      ]
  });
  </code></pre>
  
  <p>Anyone point me in the right direction?</p>
  
  <p>Thanks!</p>