Skip to content

Commit 48c7040

Browse files
DOCSP-26900 Fixed wording around using the projection operator with arrays (#2358)
* 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 2df1e03 commit 48c7040

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
@@ -134,61 +134,63 @@ content: |
134134
135135
* - ``<field>: <1 or true>``
136136
137-
- Specifies the inclusion of a field. Non-zero integers are also
138-
treated as ``true``.
137+
- Specifies the inclusion of a field. If you specify a non-zero
138+
integer for the projection value, the operation treats the
139+
value as ``true``.
139140
140141
* - ``<field>: <0 or false>``
141142
142143
- Specifies the exclusion of a field.
143144
144145
* - ``"<field>.$": <1 or true>``
145146
146-
- With the use of the :projection:`$` array projection operator,
147-
you can specify the projection to return the **first** element
148-
that match the query condition on the array field; e.g.
149-
``"arrayField.$" : 1``. (Not available for :doc:`views
150-
</core/views>`.) Non-zero integers are also treated as
151-
``true``.
147+
- Uses the :projection:`$` array projection operator to return
148+
the first element that matches the query condition on the
149+
array field. If you specify a non-zero integer for the
150+
projection value, the operation treats the value as ``true``.
151+
152+
Not available for :ref:`views <views-landing-page>`.
152153
153154
* - ``<field>: <array projection>``
154155
155-
- Using the array projection operators :projection:`$elemMatch`,
156-
:projection:`$slice`, specifies the array element(s) to include,
157-
thereby excluding those elements that do not meet the
158-
expressions. (Not available for :ref:`views <views-landing-page>`.)
156+
- Uses the array projection operators (:projection:`$elemMatch`,
157+
:projection:`$slice`) to specify the array elements to
158+
include.
159+
160+
Not available for :ref:`views <views-landing-page>`.
159161
160162
* - ``<field>: <$meta expression>``
161163
162-
- Using the :expression:`$meta` operator expression, specifies the
163-
inclusion of available :expression:`per-document metadata
164-
<$meta>`. (Not available for :ref:`views <views-landing-page>`.)
164+
- Uses the :expression:`$meta` operator expression to specify
165+
the inclusion of available :expression:`per-document metadata
166+
<$meta>`.
167+
168+
Not available for :ref:`views <views-landing-page>`.
165169
166170
167171
* - ``<field>: <aggregation expression>``
168172
169173
- Specifies the value of the projected field.
170174
171175
Starting in MongoDB 4.4, with the use of :ref:`aggregation
172-
expressions and syntax <aggregation-expressions>`, including the
173-
use of literals and aggregation variables, you can project new
174-
fields or project existing fields with new values. For example,
176+
expressions and syntax <aggregation-expressions>`, including
177+
the use of literals and aggregation variables, you can project
178+
new fields or project existing fields with new values.
175179
176180
- If you specify a non-numeric, non-boolean literal (such as a
177-
literal string or an array or an operator expression) for the
178-
projection value, the field is projected with the new value;
179-
e.g.:
181+
literal string or an array or an operator expression) for
182+
the projection value, the field is projected with the new
183+
value, for example:
180184
181185
- ``{ field: [ 1, 2, 3, "$someExistingField" ] }``
182186
- ``{ field: "New String Value" }``
183187
- ``{ field: { status: "Active", total: { $sum: "$existingArray" } } }``
184188
185-
- To project a literal value for a field, use the :expression:`$literal`
186-
aggregation expression; e.g.:
189+
- To project a literal value for a field, use the
190+
:expression:`$literal` aggregation expression; for example:
187191
188192
- ``{ field: { $literal: 5 } }``
189-
190193
- ``{ field: { $literal: true } }``
191-
192194
- ``{ field: { $literal: { fieldWithValue0: 0, fieldWithValue1: 1 } } }``
193195
194196
In versions 4.2 and earlier, any specification value (with
@@ -211,28 +213,30 @@ content: |
211213
212214
* - ``<field>: <1 or true>``
213215
214-
- Specifies the inclusion of a field. Non-zero integers are also
215-
treated as ``true``.
216+
- Specifies the inclusion of a field. If you specify a non-zero
217+
integer for the projection value, the operation treats the
218+
value as ``true``.
216219
217220
* - ``<field>: <0 or false>``
218221
219222
- Specifies the exclusion of a field.
220223
221224
* - ``"<field>.$": <1 or true>``
222225
223-
- With the use of the :projection:`$` array projection operator,
224-
you can specify the projection to return the **first** element
225-
that match the query condition on the array field; e.g.
226-
``"arrayField.$" : 1``. (Not available for :doc:`views
227-
</core/views>`.) Non-zero integers are also treated as
228-
``true``.
226+
- Uses the :projection:`$` array projection operator to return
227+
the first element that matches the query condition on the
228+
array field. If you specify a non-zero integer for the
229+
projection value, the operation treats the value as ``true``.
230+
231+
Not available for :ref:`views <views-landing-page>`.
229232
230233
* - ``<field>: <array projection>``
231234
232-
- Using the array projection operators :projection:`$elemMatch`,
233-
:projection:`$slice`, specifies the array element(s) to include,
234-
thereby excluding those elements that do not meet the
235-
expressions. (Not available for :ref:`views <views-landing-page>`.)
235+
- Uses the array projection operators (:projection:`$elemMatch`,
236+
:projection:`$slice`) to specify the array elements to
237+
include.
238+
239+
Not available for :ref:`views <views-landing-page>`.
236240
237241
* - ``<field>: <aggregation expression>``
238242
@@ -241,24 +245,22 @@ content: |
241245
Starting in MongoDB 4.4, with the use of :ref:`aggregation
242246
expressions and syntax <aggregation-expressions>`, including the
243247
use of literals and aggregation variables, you can project new
244-
fields or project existing fields with new values. For example,
248+
fields or project existing fields with new values.
245249
246250
- If you specify a non-numeric, non-boolean literal (such as a
247-
literal string or an array or an operator expression) for the
248-
projection value, the field is projected with the new value;
249-
e.g.:
251+
literal string or an array or an operator expression) for
252+
the projection value, the field is projected with the new
253+
value, for example:
250254
251255
- ``{ field: [ 1, 2, 3, "$someExistingField" ] }``
252256
- ``{ field: "New String Value" }``
253257
- ``{ field: { status: "Active", total: { $sum: "$existingArray" } } }``
254258
255-
- To project a literal value for a field, use the :expression:`$literal`
256-
aggregation expression; e.g.:
259+
- To project a literal value for a field, use the
260+
:expression:`$literal` aggregation expression, for example:
257261
258262
- ``{ field: { $literal: 5 } }``
259-
260263
- ``{ field: { $literal: true } }``
261-
262264
- ``{ field: { $literal: { fieldWithValue0: 0, fieldWithValue1: 1 } } }``
263265
264266
In versions 4.2 and earlier, any specification value (with
@@ -274,9 +276,9 @@ content: |
274276
For fields in an embedded documents, you can specify the field using
275277
either:
276278
277-
- :ref:`dot notation <document-dot-notation-embedded-fields>`; e.g. ``"field.nestedfield": <value>``
279+
- :ref:`dot notation <document-dot-notation-embedded-fields>`, for example ``"field.nestedfield": <value>``
278280
279-
- nested form; e.g. ``{ field: { nestedfield: <value> } }`` (*Starting in
281+
- nested form, for example ``{ field: { nestedfield: <value> } }`` (*Starting in
280282
MongoDB 4.4*)
281283
282284
---
@@ -356,7 +358,7 @@ ref: projection-positional-operator-path
356358
content: |
357359
358360
Starting in MongoDB 4.4, the :projection:`$` projection operator can
359-
only appear at the end of the field path; e.g. ``"field.$"``
361+
only appear at the end of the field path, for example ``"field.$"``
360362
or ``"fieldA.fieldB.$"``.
361363
362364
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
@@ -526,10 +526,9 @@ For a list of array specific query operators, see :ref:`operator-query-array`.
526526
Projections
527527
~~~~~~~~~~~
528528

529-
The :ref:`projection <find-projection>` parameter specifies
530-
which fields to return. The parameter contains either include or
531-
exclude specifications, not both, unless the exclude is for the ``_id``
532-
field.
529+
The :ref:`projection <find-projection>` parameter specifies which fields
530+
to return. The parameter contains either include or exclude
531+
specifications, not both, unless the exclude is for the ``_id`` field.
533532

534533
.. note::
535534

@@ -601,7 +600,7 @@ array:
601600
{ _id: 0, 'name.last': 1, contribs: { $slice: 2 } } )
602601

603602
Starting in MongoDB 4.4, you can also specify embedded fields using the
604-
nested form, e.g.
603+
nested form, for example:
605604

606605
.. code-block:: javascript
607606

0 commit comments

Comments
 (0)