This is a similar question to $and query returns no result, however the answer there does not apply in this case.
I have the following query:
{
$and: [
{
ownerId: "505b832c975a5c3ca6e9523b"
},
{
privacyLevel: "Public"
}
]
}
My collection has 16 documents, all of which are “Public” and 7 of which have the ownerId above. The subqueries behave correctly and return the correct documents so I would expect 7 results from this query.
The $and query returns nothing, I am at a loss as to why that might be.
If you are just querying two fields you do not need an $and operator. Your query will simply be: