I've a document like this:
{
"_id" : ObjectId("xxx"),
"users" : [
{
"_id" : ObjectId("xxx")
},
{
"_id" : ObjectId("yyy")
}
]
}
users is an array, which can contain two or more than two objects.
If I've to request strictly two objects via a mongo query, how can I do it?
.find({
"users._id" : { $in: [ObjectId("xxx"), ObjectId("yyy")] }
})
This above query will fetch all the docs that've either've xxx user or yyy user in them. How can I form a query where if the both xxx and yyy are only there, then only that doc is to be fetched.
Let me know if you need more info to understand the problem. And huge thanks in advance for the help.
$alloperator instead of$in.