How to find length of embedded nested array in mongodb?
问题 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: db.atolldata.aggregate([ {$project:{_id:0, fileName:1, sizeOfArray:{$size:"$loc.coordinates[0]"}}}]); . Here is my collection db.mydb.findOne()