Skip to main content

$min

The $min operator returns the smaller of two values. If the values are of numeric type, it compares them numerically. If they are strings, it performs lexicographic comparison.

Input

  • An array containing exactly two values to compare

Output

  • The smaller of the two input values

Examples

Numeric Comparison

{
  "$min": [
    5,
    10
  ]
}
Result: 5

String Comparison

{
  "$min": [
    "apple",
    "banana"
  ]
}
Result: "apple"

Field Value Comparison

{
  "$min": [
    {
      "$input": "temperature_today"
    },
    {
      "$input": "temperature_yesterday"
    }
  ]
}
Result: The lower temperature between today and yesterday