Skip to main content

$gt

The $gt operator checks if the first value is greater than the second value.

Input

  • An array containing exactly two values to compare

Output

  • true if the first value is greater than the second value
  • false otherwise (including when either value is null)

Examples

Basic Comparison

{
  "$gt": [
    10,
    5
  ]
}
Result: true

False Comparison

{
  "$gt": [
    3,
    7
  ]
}
Result: false

Field Value Comparison

{
  "$gt": [
    {
      "$input": "age"
    },
    18
  ]
}
Result: true if the age field is greater than 18, otherwise false

String Comparison

{
  "$gt": [
    "zoo",
    "apple"
  ]
}
Result: true (lexicographic comparison)