[Aggregation] Reference current iteration field in $elemMatch

Hey,

This is my basic $elemMatch

"$elemMatch": {
                    "item_field_1": { $eq: "$item_field_2" }
                }

I cannot find how to make a self reference un $elemMatch, that possible ?

You need to reference your variable with two dollar signs ($$) and make a self-reference with one dollar sign ($). Like this:

{
  $match: {
    $expr: { $eq: ['$item', '$$var']},
  },
},