File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
source/reference/operator Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 10
10
11
11
*Syntax*: ``{ $and: [ { <expression1> }, { <expression2> } , ... , { <expressionN> } ] }``
12
12
13
- :operator:`$and` performs a logical ``AND`` operation on an array
14
- of *two or more* expressions (e.g. ``<expression1>``,
13
+ :operator:`$and` performs a logical ``AND`` operation on an array of
14
+ *two or more* expressions (e.g. ``<expression1>``,
15
15
``<expression2>``, etc.) and selects the documents that satisfy
16
- *all* the expressions in the array.
16
+ *all* the expressions in the array. With the :operator:`$and`
17
+ operator, MongoDB performs a short-circuit evaluation of the
18
+ expressions. If the first expression ``<expression1>`` evaluates to
19
+ ``false``, MongoDB will skip the evaluation of the remaining
20
+ expressions.
17
21
18
22
Consider the following example:
19
23
27
31
- ``price`` field value equals ``1.99`` **and**
28
32
- ``qty`` field value is less than ``20`` **and**
29
33
- ``sale`` field value is equal to ``true``.
30
-
34
+
31
35
MongoDB provides an implicit ``AND`` operation when specifying a
32
36
comma separated list of expressions. For example, you may write the
33
37
above query as:
You can’t perform that action at this time.
0 commit comments