When we use $elemMatch operator as a projection then we get some matching sub documents while some ObjectIDs without any fields. What is the reason for the same, unable to understand from video.
Hi @Niket_Agrawal, interesting question.
I think of it like this:
- The first step selects all documents with
- This subset is the input for the second part.
_idis always printed, unless
$elemMatchwill only print if there is a match
- Then you only see the
( I can’t find this in the docs, so it’s just an interpretation. )
Thanks for superb and simple explanation Sir.