From 964045de152fc5bd05f568c9f0be2ec3d2d3d381 Mon Sep 17 00:00:00 2001 From: kay Date: Thu, 13 Sep 2012 12:54:02 -0400 Subject: [PATCH] DOCS-433 operator does a short-circuit eval of expression --- source/reference/operator/and.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/reference/operator/and.txt b/source/reference/operator/and.txt index 8a4bc62734b..7d5561e421f 100644 --- a/source/reference/operator/and.txt +++ b/source/reference/operator/and.txt @@ -10,10 +10,14 @@ $and *Syntax*: ``{ $and: [ { }, { } , ... , { } ] }`` - :operator:`$and` performs a logical ``AND`` operation on an array - of *two or more* expressions (e.g. ````, + :operator:`$and` performs a logical ``AND`` operation on an array of + *two or more* expressions (e.g. ````, ````, 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 ```` evaluates to + ``false``, MongoDB will skip the evaluation of the remaining + expressions. Consider the following example: @@ -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: