Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
APPLIES TO:
MongoDB vCore
This command is used to match documents where any of the bit positions specified in a bitmask are clear (that is, 0). It's useful for querying documents with binary data or flags stored as integers. This operator enables efficient querying based on specific bit patterns.
{
<field>: { $bitsAnyClear: <bitmask> }
}
<field>
: The field in the document to be queried.<bitmask>
: A bitmask where each bit position represents a position to check if it's clear (0).
Consider a collection named stores
with documents similar to the provided JSON structure. To find stores where the totalStaff.fullTime
field has any of the first 3 bits clear, you can use the following query:
db.stores.find({
"store.staff.totalStaff.fullTime": { $bitsAnyClear: 0b00000111 }
})
In this example, 0b00000111
is the bitmask representing the first 3 bits. The query would return documents where any of the first 3 bits of the totalStaff.fullTime
field are clear.
- Review options for Migrating from MongoDB to Azure Cosmos DB for MongoDB (vCore)
- Read more about Feature compatibility with MongoDB