Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions source/reference/operator/and.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ $and

*Syntax*: ``{ $and: [ { <expression1> }, { <expression2> } , ... , { <expressionN> } ] }``

:operator:`$and` performs a logical ``AND`` operation on an array
of *two or more* expressions (e.g. ``<expression1>``,
:operator:`$and` performs a logical ``AND`` operation on an array of
*two or more* expressions (e.g. ``<expression1>``,
``<expression2>``, etc.) and selects the documents that satisfy
*all* the expressions in the array.
*all* the expressions in the array. With the :operator:`$and`
operator, MongoDB performs a short-circuit evaluation of the
expressions. If the first expression ``<expression1>`` evaluates to
``false``, MongoDB will skip the evaluation of the remaining
expressions.

Consider the following example:

Expand All @@ -27,7 +31,7 @@ $and
- ``price`` field value equals ``1.99`` **and**
- ``qty`` field value is less than ``20`` **and**
- ``sale`` field value is equal to ``true``.

MongoDB provides an implicit ``AND`` operation when specifying a
comma separated list of expressions. For example, you may write the
above query as:
Expand Down