0

So, I am having an aggregate query

{ $match: { 'projects.status.status': 'Approved' , 'projects.status.college_id': '$collegeDetail._id' }},

within which I am having this Match Query , where first part of the match query return correct document if latter part is removed.

$collegeDetail._id Is unable to match the correct element. Though the id in this field is same and of same data type as that of (projects.status.college_id)

Any help would be appreciated. Thanks.

iatsi
  • 151
  • 1
  • 10
  • This question is not same as the one you mentioned @Neil Lunn . This match query is in aggregate part of the query. We cant use $where in aggregate's match. – iatsi May 31 '18 at 09:14
  • There's other solutions there than using `$where`. Look further and scroll down. You want `$redact` or even `$expr` if your MongoDB supports the latter. It certainly supports the former. – Neil Lunn May 31 '18 at 09:20
  • Thanks dude. My local Version is 3.4. So $expr didnt worked. And neither $cmp could compare two objectids . But somehow $eq did. :) – iatsi May 31 '18 at 09:58

0 Answers0