Hello everyone
I am taking M01 Basic Mongodb and in chapter4 there is one exercise asking for this:
“Find all documents in the companies collection where people named Mark used to be in the senior company leadership array, a.k.a the relationships array, but are no longer with the company.”
So I create this query:
db.companies.find({“relationships.person.first_name”:“Mark”, “relationships.is_past”:true }).count()
which returns 448 documents
However I think this other query may work:
db.companies.find({ “relationships”: { “$elemMatch”: { “is_past”: true, “person.first_name”: “Mark” } } } ).count()
This returns 256 documents
Does anyone may explain me why they return different counts?
Regards