Skip to content

Commit 3fe3aaa

Browse files
DOCSP-26900 Fixed wording around using the projection operator with arrays (#2358) (#4370)
* Fixed wording around using the projection operator with arrays * Per internal review, cleaned up wording for consistency * Fixed pluralization and table list rendering * Incorporated internal review feedback * Changed new paragraph back to bullet to address build issues * Moved line up into preceding bullet to test build errors * Testing output * fixed indentation
1 parent 4c9ade2 commit 3fe3aaa

File tree

2 files changed

+54
-53
lines changed

2 files changed

+54
-53
lines changed

source/includes/extracts-projection.yaml

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -142,61 +142,63 @@ content: |
142142
143143
* - ``<field>: <1 or true>``
144144
145-
- Specifies the inclusion of a field. Non-zero integers are also
146-
treated as ``true``.
145+
- Specifies the inclusion of a field. If you specify a non-zero
146+
integer for the projection value, the operation treats the
147+
value as ``true``.
147148
148149
* - ``<field>: <0 or false>``
149150
150151
- Specifies the exclusion of a field.
151152
152153
* - ``"<field>.$": <1 or true>``
153154
154-
- With the use of the :projection:`$` array projection operator,
155-
you can specify the projection to return the **first** element
156-
that match the query condition on the array field; e.g.
157-
``"arrayField.$" : 1``. (Not available for :doc:`views
158-
</core/views>`.) Non-zero integers are also treated as
159-
``true``.
155+
- Uses the :projection:`$` array projection operator to return
156+
the first element that matches the query condition on the
157+
array field. If you specify a non-zero integer for the
158+
projection value, the operation treats the value as ``true``.
159+
160+
Not available for :ref:`views <views-landing-page>`.
160161
161162
* - ``<field>: <array projection>``
162163
163-
- Using the array projection operators :projection:`$elemMatch`,
164-
:projection:`$slice`, specifies the array element(s) to include,
165-
thereby excluding those elements that do not meet the
166-
expressions. (Not available for :doc:`views </core/views>`.)
164+
- Uses the array projection operators (:projection:`$elemMatch`,
165+
:projection:`$slice`) to specify the array elements to
166+
include.
167+
168+
Not available for :ref:`views <views-landing-page>`.
167169
168170
* - ``<field>: <$meta expression>``
169171
170-
- Using the :expression:`$meta` operator expression, specifies the
171-
inclusion of available :expression:`per-document metadata
172-
<$meta>`. (Not available for :doc:`views </core/views>`.)
172+
- Uses the :expression:`$meta` operator expression to specify
173+
the inclusion of available :expression:`per-document metadata
174+
<$meta>`.
175+
176+
Not available for :ref:`views <views-landing-page>`.
173177
174178
175179
* - ``<field>: <aggregation expression>``
176180
177181
- Specifies the value of the projected field.
178182
179183
Starting in MongoDB 4.4, with the use of :ref:`aggregation
180-
expressions and syntax <aggregation-expressions>`, including the
181-
use of literals and aggregation variables, you can project new
182-
fields or project existing fields with new values. For example,
184+
expressions and syntax <aggregation-expressions>`, including
185+
the use of literals and aggregation variables, you can project
186+
new fields or project existing fields with new values.
183187
184188
- If you specify a non-numeric, non-boolean literal (such as a
185-
literal string or an array or an operator expression) for the
186-
projection value, the field is projected with the new value;
187-
e.g.:
189+
literal string or an array or an operator expression) for
190+
the projection value, the field is projected with the new
191+
value, for example:
188192
189193
- ``{ field: [ 1, 2, 3, "$someExistingField" ] }``
190194
- ``{ field: "New String Value" }``
191195
- ``{ field: { status: "Active", total: { $sum: "$existingArray" } } }``
192196
193-
- To project a literal value for a field, use the :expression:`$literal`
194-
aggregation expression; e.g.:
197+
- To project a literal value for a field, use the
198+
:expression:`$literal` aggregation expression; for example:
195199
196200
- ``{ field: { $literal: 5 } }``
197-
198201
- ``{ field: { $literal: true } }``
199-
200202
- ``{ field: { $literal: { fieldWithValue0: 0, fieldWithValue1: 1 } } }``
201203
202204
In versions 4.2 and earlier, any specification value (with
@@ -219,28 +221,30 @@ content: |
219221
220222
* - ``<field>: <1 or true>``
221223
222-
- Specifies the inclusion of a field. Non-zero integers are also
223-
treated as ``true``.
224+
- Specifies the inclusion of a field. If you specify a non-zero
225+
integer for the projection value, the operation treats the
226+
value as ``true``.
224227
225228
* - ``<field>: <0 or false>``
226229
227230
- Specifies the exclusion of a field.
228231
229232
* - ``"<field>.$": <1 or true>``
230233
231-
- With the use of the :projection:`$` array projection operator,
232-
you can specify the projection to return the **first** element
233-
that match the query condition on the array field; e.g.
234-
``"arrayField.$" : 1``. (Not available for :doc:`views
235-
</core/views>`.) Non-zero integers are also treated as
236-
``true``.
234+
- Uses the :projection:`$` array projection operator to return
235+
the first element that matches the query condition on the
236+
array field. If you specify a non-zero integer for the
237+
projection value, the operation treats the value as ``true``.
238+
239+
Not available for :ref:`views <views-landing-page>`.
237240
238241
* - ``<field>: <array projection>``
239242
240-
- Using the array projection operators :projection:`$elemMatch`,
241-
:projection:`$slice`, specifies the array element(s) to include,
242-
thereby excluding those elements that do not meet the
243-
expressions. (Not available for :doc:`views </core/views>`.)
243+
- Uses the array projection operators (:projection:`$elemMatch`,
244+
:projection:`$slice`) to specify the array elements to
245+
include.
246+
247+
Not available for :ref:`views <views-landing-page>`.
244248
245249
* - ``<field>: <aggregation expression>``
246250
@@ -249,24 +253,22 @@ content: |
249253
Starting in MongoDB 4.4, with the use of :ref:`aggregation
250254
expressions and syntax <aggregation-expressions>`, including the
251255
use of literals and aggregation variables, you can project new
252-
fields or project existing fields with new values. For example,
256+
fields or project existing fields with new values.
253257
254258
- If you specify a non-numeric, non-boolean literal (such as a
255-
literal string or an array or an operator expression) for the
256-
projection value, the field is projected with the new value;
257-
e.g.:
259+
literal string or an array or an operator expression) for
260+
the projection value, the field is projected with the new
261+
value, for example:
258262
259263
- ``{ field: [ 1, 2, 3, "$someExistingField" ] }``
260264
- ``{ field: "New String Value" }``
261265
- ``{ field: { status: "Active", total: { $sum: "$existingArray" } } }``
262266
263-
- To project a literal value for a field, use the :expression:`$literal`
264-
aggregation expression; e.g.:
267+
- To project a literal value for a field, use the
268+
:expression:`$literal` aggregation expression, for example:
265269
266270
- ``{ field: { $literal: 5 } }``
267-
268271
- ``{ field: { $literal: true } }``
269-
270272
- ``{ field: { $literal: { fieldWithValue0: 0, fieldWithValue1: 1 } } }``
271273
272274
In versions 4.2 and earlier, any specification value (with
@@ -282,9 +284,9 @@ content: |
282284
For fields in an embedded documents, you can specify the field using
283285
either:
284286
285-
- :ref:`dot notation <document-dot-notation-embedded-fields>`; e.g. ``"field.nestedfield": <value>``
287+
- :ref:`dot notation <document-dot-notation-embedded-fields>`, for example ``"field.nestedfield": <value>``
286288
287-
- nested form; e.g. ``{ field: { nestedfield: <value> } }`` (*Starting in
289+
- nested form, for example ``{ field: { nestedfield: <value> } }`` (*Starting in
288290
MongoDB 4.4*)
289291
290292
---
@@ -364,7 +366,7 @@ ref: projection-positional-operator-path
364366
content: |
365367
366368
Starting in MongoDB 4.4, the :projection:`$` projection operator can
367-
only appear at the end of the field path; e.g. ``"field.$"``
369+
only appear at the end of the field path, for example ``"field.$"``
368370
or ``"fieldA.fieldB.$"``.
369371
370372
For example, starting in MongoDB 4.4, the following operation is

source/reference/method/db.collection.find.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,9 @@ For a list of array specific query operators, see :ref:`operator-query-array`.
518518
Projections
519519
~~~~~~~~~~~
520520

521-
The :ref:`projection <find-projection>` parameter specifies
522-
which fields to return. The parameter contains either include or
523-
exclude specifications, not both, unless the exclude is for the ``_id``
524-
field.
521+
The :ref:`projection <find-projection>` parameter specifies which fields
522+
to return. The parameter contains either include or exclude
523+
specifications, not both, unless the exclude is for the ``_id`` field.
525524

526525
.. note::
527526

@@ -593,7 +592,7 @@ array:
593592
{ _id: 0, 'name.last': 1, contribs: { $slice: 2 } } )
594593

595594
Starting in MongoDB 4.4, you can also specify embedded fields using the
596-
nested form, e.g.
595+
nested form, for example:
597596

598597
.. code-block:: javascript
599598

0 commit comments

Comments
 (0)