title: MongoDB. Query for array in Subdocument
body: <p>i am new to mongodb so please correct me if i am using the wrong terms:</p>
  
  <p>I have the following document(excerpt)</p>
  
  <pre><code>{
      "_id" : ObjectId("524b0a1a7294ec8a39d4230f"),
      "name" : "Irbesartan",
      "decompositions" : [
              "IRB_444",
              "IRB_442",
              "IRB_446",
              "Valsartan acid"
      ],
      "precursor" : [
              {
                      "mass" : 429,
                      "ion" : "+H",
                      "charge" : "+",
                      "fragments" : [
                              207,
                              195,
                              180
                      ]
              },
              {
                      "mass" : 427.2252,
                      "ion" : "-H",
                      "charge" : "-",
                      "fragments" : [
                              193,
                              399
                      ]
              }
      ]
  }
  </code></pre>
  
  <p>With </p>
  
  <pre><code>db.substances.findOne({name: "Irbesartan"}).precursor
  </code></pre>
  
  <p>i get the following</p>
  
  <pre><code>[
      {
              "mass" : 429,
              "ion" : "+H",
              "charge" : "+",
              "fragments" : [
                      207,
                      195,
                      180
              ]
      },
      {
              "mass" : 427.2252,
              "ion" : "-H",
              "charge" : "-",
              "fragments" : [
                      193,
                      399
              ]
      }
  ]
  </code></pre>
  
  <p>But i want to acces the fields inside, espacially the fragment array (using Mongo Shell)</p>
  
  <p>Is this possible in one query?</p>
  
  <p>Or is it better to store the precursor as an array instead of a subdocument?</p>