Skip to main content

$eq

The $eq operator checks if two values are equal.

Input

  • An array containing exactly two values to compare

Output

  • true if the two values are equal
  • false if the two values are not equal

Examples

Basic Equality

{
  "$eq": [
    5,
    5
  ]
}
Result: true

Inequality

{
  "$eq": [
    "hello",
    "world"
  ]
}
Result: false

Comparing Field Values

{
  "$eq": [
    {
      "$input": "status"
    },
    "active"
  ]
}
Result: true if the status field equals “active”, otherwise false

Number Comparison

{
  "$eq": [
    {
      "$input": "count"
    },
    10
  ]
}
Result: true if the count field equals 10, otherwise false