I have a MongoDB collection with documents in the following format:
{
\"_id\" : ObjectId(\"4e8ae86d08101908e1000001\"),
\"name\" : [\"Name\"],
\"zipcod
I found this solution, to find items with an array field greater than certain length
db.allusers.aggregate([
{$match:{username:{$exists:true}}},
{$project: { count: { $size:"$locations.lat" }}},
{$match:{count:{$gt:20}}}
])
The first $match aggregate uses an argument thats true for all the documents. If blank, i would get
"errmsg" : "exception: The argument to $size must be an Array, but was of type: EOO"