I have a collection where every document in the collection has an array named foo
that contains a set of embedded documents. Is there currently a trivial way in the MongoDB shell to count how many instances are within foo
? something like:
db.mycollection.foos.count()
or db.mycollection.foos.size()
?
Each document in the array needs to have a unique foo_id
and I want to do a quick count to make sure that the right amount of elements are inside of an array for a random document in the collection.