Upstash Documentation

$must

1 min read

The $must operator requires all specified conditions to match. Documents are only included in results if they satisfy every condition within the $must clause. This implements logical AND behavior.

When you specify multiple field conditions at the top level of a query without any boolean operator, they are implicitly wrapped in a $must. These queries are equivalent:

Syntax Options#

The $must operator accepts either an object or an array:

  • Object syntax: Each key-value pair is a condition that must match
  • Array syntax: Each element is a separate condition object that must match

Array syntax is useful when you have multiple conditions on the same field or when building queries programmatically.

Examples#