title: How to find the elements in the sub-document in MongoDB
body: <p>If I have a data in MongoDB as the following with 2 documents and each document has sub-document of sensors. How can I get the list of <strong>sensors</strong> which the <strong>nodeId</strong> is 1 in MongoDB?</p>
  
  <pre><code>{
    "name": "Site 1",
    "sensors": [
      { "nodeId": 1, "value": "23" },
      { "nodeId": 1, "value": "34" },
      { "nodeId": 2, "value": "66" }
    ]
  }
  
  {
    "name": "Site 2",
    "sensors": [
      { "nodeId": 2, "value": "78" },
      { "nodeId": 2, "value": "99" },
      { "nodeId": 2, "value": "11" },
      { "nodeId": 1, "value": "45" }
    ]
  }
  </code></pre>
  
  <p><strong>Expected Output</strong></p>
  
  <pre><code>{ 
    "sensors": [
      { "nodeId": 1, "value": "23" },
      { "nodeId": 1, "value": "34" },
      { "nodeId": 1, "value": "45" }
    ]
  }
  </code></pre>