$eq/$ne/$gt/$gte/$lt/$lte

Reference type:Cheat sheetFormat:Syntax + example + use case

Reference group: Conditional and logical expressions

What it does

Compares expression values and returns booleans.

Syntax

Comparison expressions such as {$gt: [a, b]}

Use case

Compare two fields in a document.

$eq/$ne/$gt/$gte/$lt/$lte: practical example
{ $match: { $expr: { $gt: ["$sold", "$threshold"] } } }
💡 Explanation Compares expression values and returns booleans. When to use it Compare two fields in a document.
Key Takeaways
  • Compares expression values and returns booleans.
  • Typical use: Compare two fields in a document.