When used in the $match stage, these two aggregation stages return different documents:
$expr: {
$eq: ["$cheese", undefined]
}
{
cheese: {$eq: undefined}
}
The field cheese
is not a property of any document in the collection.
In the second query, it returns all documents, which is expected behavior.
In the first query, it returns no documents.
What explains the difference?