$bitsAllClear as bitwise query operator

APPLIES TO: MongoDB vCore

The $bitsAllClear operator is used to match documents where all the bit positions specified in a bitmask are clear (that is, 0). This operator is useful in scenarios where you need to filter documents based on specific bits being unset in a binary representation of a field.

Syntax

The syntax for the $bitsAllClear operator is as follows:

{
  <field>: {
    $bitsAllClear: <bitmask>
  }
}

Parameters

Description
field The field in the document to be evaluated.
count A bitmask where each bit position specifies the corresponding bit position in the field's value that must be clear (0).