Skip to content

Commit f7aeee5

Browse files
author
Sam Kleinman
committed
DOCS-469: adding version change information to elemMatch projection operator
1 parent b618f0d commit f7aeee5

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

source/reference/projection/elemMatch.txt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ $elemMatch (projection)
88

99
.. projection:: $elemMatch
1010

11+
.. versionadded:: 2.2
12+
1113
Use the :projection:`$elemMatch` projection operator to limit the
1214
response of a query to a single matching element of an
1315
array. Consider the following:
1416

15-
.. example::
17+
.. example::
18+
19+
Given the following document fragment:
1620

17-
Given the following document fragment:
18-
1921
.. code-block:: javascript
20-
22+
2123
{
2224
_id: ObjectId(),
2325
zipcode: 63109
@@ -27,24 +29,24 @@ $elemMatch (projection)
2729
{ name: "jeff", school: 108, age: 15 }
2830
]
2931
}
30-
31-
Consider the following :method:`find() <db.collection.find()>`
32+
33+
Consider the following :method:`find() <db.collection.find()>`
3234
operation:
3335

3436
.. code-block:: javascript
35-
36-
db.students.find( { zipcode: 63109 },
37-
{ _id: 0,
37+
38+
db.students.find( { zipcode: 63109 },
39+
{ _id: 0,
3840
dependents: { $elemMatch: { school: 102 } } } )
3941

4042
The query would return all documents where the value of the
4143
``zipcode`` field is ``63109``, while the projection excludes
4244
the ``_id`` field and only includes those elements of the
4345
``dependents`` array where the ``school`` element has a valueof
4446
``102``. The documents would take the following form:
45-
47+
4648
.. code-block:: javascript
47-
49+
4850
{
4951
dependents: [
5052
{ name: "john", school: 102, age: 10 },

0 commit comments

Comments
 (0)