title: How to find length of embedded nested array in mongodb?
body: <p>How to find length of embedded nested array in mongodb? For example,
  I have the below collection in my mongoDB. The loc field contains coordinates field which is an array and again it contains another array which is in 0th index. 
  How can I find length of loc.corrdinates[0] ?
  I tried to do this with using aggregation pipeline but it gives syntax error:</p>
  
  <pre><code>db.atolldata.aggregate([
                          {$project:{_id:0,
                                     fileName:1,
                           sizeOfArray:{$size:"$loc.coordinates[0]"}}}]); 
  </code></pre>
  
  <p>. </p>
  
  <p>Here is my collection </p>
  
  <p>db.mydb.findOne();</p>
  
  <pre><code>{
      "_id" : ObjectId("54ccb36fe4b0ff85abfee006"),
      "_class" : "com.inn.signaleye.model.AtollData",
      "rsrp" : "-124",
      "index" : 1,
      "rgb" : [
          192,
          157,
          0
      ],
      "loc" : {
          "type" : "Polygon",
          "coordinates" : [
              [
                  [
                      91.5254213240325,
                      26.225096
                  ],
                  [
                      91.5254099392226,
                      26.225999
                  ],
                  [
                      91.52591034644685,
                      26.226004
                  ],
                  [
                      91.52592172739666,
                      26.225101
                  ],
                  [
                      91.5254213240325,
                      26.225096
                  ]
              ]
          ]
      },
      "fileName" : "RSRP_ZOne46N_20m_SCFT.shp"
  }
  </code></pre>