Array Operators

Operator

Description

Example

$all

Selects documents where the array property contains all of the passed in values.

{“roles”: {“$all”: [“000000000000000000000007”, “0123456789ab0123456789ab”]}}

$elemMatch

Selects documents where all properties of an array of document properties match the passed in expression. $elemMatch does not limit the results within the array, but filters the entire document for contained entries.

{“c_docs”: {“$elemMatch”: {“c_foo”: “yes”, “c_bar”: true}}}

$size

Selects documents where the size of the array property matches the passed in values.

{“c_arr”: {“$size”: 20}}