Within MongoDB aggregate pipeline, match between fields

26 views Asked by At

I have part of aggregate pipeline that is using that code that is working

$expr: {$in: ["$myCompanyBidsData._id", "$bestCompanyBids._id"]},

I want fetch data that the _id of myCompanyBidsData that wont match _id of one of the object in the listbestCompanyBids.

I have tried to use $nin, not inside/outside the $expr, but its not working.

1

There are 1 answers

0
Nipuna Jayawardana On

try this. i could not give a more complete answer without seeing the query.

{
  $match: {
     $expr: {
         $not: {
             $in: ["$myCompanyBidsData._id", "$bestCompanyBids._id"]
         }
     }
  }
}