From 9938c44f46b10c59f8ac4700398f2f4e17f2336a Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Wed, 5 Sep 2012 10:42:14 -0700 Subject: [PATCH] clarify $elemMatch projection example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit see http://stackoverflow.com/questions/12274957/does-elemmatch-not-work-with-a-new-mongodb-2-2/12286852#12286852 and https://github.com/learnboost/mongoose/issues/1085 --- source/reference/projection/elemMatch.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/reference/projection/elemMatch.txt b/source/reference/projection/elemMatch.txt index 4e2e72976b4..ad367ba0ed4 100644 --- a/source/reference/projection/elemMatch.txt +++ b/source/reference/projection/elemMatch.txt @@ -35,9 +35,8 @@ $elemMatch (projection) .. code-block:: javascript - db.students.find( { zipcode: 63109 }, - { _id: 0, - dependents: { $elemMatch: { school: 102 } } } ) + var projection = { _id: 0, dependents: { $elemMatch: { school: 102 }}}; + db.students.find( { zipcode: 63109 }, projection); The query would return all documents where the value of the ``zipcode`` field is ``63109``, while the projection excludes