Skip to main content

$lt

The $lt operator checks if the first value is less than the second value.

Input

  • An array containing exactly two values to compare

Output

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

Examples

Basic Comparison

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

False Comparison

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

Field Value Comparison

{
  "$lt": [
    {
      "$input": "temperature"
    },
    0
  ]
}
Result: true if the temperature field is less than 0, otherwise false

String Comparison

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