Aggregate $match _id $eq $toObjectId not working

Your last post made me think that may be $toObjectId works only inside $expr. I tried

{ $match: { $expr : { $eq: [ '$_id' , { $toObjectId: "61fc458b46d7874a3a97ef79" } ] } } }

and it works.

5 Likes