Skip to content

Commit e3b5628

Browse files
committed
feedback
1 parent b704c36 commit e3b5628

19 files changed

+140
-32
lines changed

source/fundamentals/crud/write-operations/update-many/arrays.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,26 +272,36 @@ Update Arrays
272272
.. tab:: Positional Operator (Sync)
273273
:tabid: update-many-positional-sync
274274

275+
.. include:: /includes/update-many/positional-operator-code-intro.rst
276+
275277
.. literalinclude:: /includes/code-examples/update-many/UpdateManyArrays.cs
276278
:language: csharp
277279
:copyable: true
278280
:dedent:
279281
:start-after: // start-update-many-positional
280282
:end-before: // end-update-many-positional
281283

284+
.. include:: /includes/update-arrays-positional-operator-note.rst
285+
282286
.. tab:: Positional Operator (Async)
283287
:tabid: update-many-positional-async
284288

289+
.. include:: /includes/update-many/positional-operator-code-intro.rst
290+
285291
.. literalinclude:: /includes/code-examples/update-many/UpdateManyArrays.cs
286292
:language: csharp
287293
:copyable: true
288294
:dedent:
289295
:start-after: // start-update-many-positional-async
290296
:end-before: // end-update-many-positional-async
291297

298+
.. include:: /includes/update-arrays-positional-operator-note.rst
299+
292300
.. tab:: LINQ (Sync)
293301
:tabid: update-many-positional-linq-sync
294302

303+
.. include:: /includes/update-many/positional-linq-code-intro.rst
304+
295305
.. literalinclude:: /includes/code-examples/update-many/UpdateManyArrays.cs
296306
:language: csharp
297307
:copyable: true
@@ -302,6 +312,8 @@ Update Arrays
302312
.. tab:: LINQ (Async)
303313
:tabid: update-many-positional-linq-async
304314

315+
.. include:: /includes/update-many/positional-linq-code-intro.rst
316+
305317
.. literalinclude:: /includes/code-examples/update-many/UpdateManyArrays.cs
306318
:language: csharp
307319
:copyable: true
@@ -316,6 +328,8 @@ Update Arrays
316328
.. tab:: Positional Operator (Sync)
317329
:tabid: update-many-filteredpositional-sync
318330

331+
.. include:: /includes/update-many/filteredpositional-operator-code-intro.rst
332+
319333
.. literalinclude:: /includes/code-examples/update-many/UpdateManyArrays.cs
320334
:language: csharp
321335
:copyable: true
@@ -326,6 +340,8 @@ Update Arrays
326340
.. tab:: Positional Operator (Async)
327341
:tabid: update-many-filteredpositional-async
328342

343+
.. include:: /includes/update-many/filteredpositional-operator-code-intro.rst
344+
329345
.. literalinclude:: /includes/code-examples/update-many/UpdateManyArrays.cs
330346
:language: csharp
331347
:copyable: true
@@ -336,6 +352,8 @@ Update Arrays
336352
.. tab:: LINQ (Sync)
337353
:tabid: update-many-filteredpositional-linq-sync
338354

355+
.. include:: /includes/update-many/filteredpositional-linq-code-intro.rst
356+
339357
.. literalinclude:: /includes/code-examples/update-many/UpdateManyArrays.cs
340358
:language: csharp
341359
:copyable: true
@@ -346,6 +364,8 @@ Update Arrays
346364
.. tab:: LINQ (Async)
347365
:tabid: update-many-filteredpositional-linq-async
348366

367+
.. include:: /includes/update-many/filteredpositional-linq-code-intro.rst
368+
349369
.. literalinclude:: /includes/code-examples/update-many/UpdateManyArrays.cs
350370
:language: csharp
351371
:copyable: true
@@ -360,6 +380,8 @@ Update Arrays
360380
.. tab:: Positional Operator (Sync)
361381
:tabid: update-many-allpositional-sync
362382

383+
.. include:: /includes/update-many/allpositional-operator-code-intro.rst
384+
363385
.. literalinclude:: /includes/code-examples/update-many/UpdateManyArrays.cs
364386
:language: csharp
365387
:copyable: true
@@ -370,6 +392,8 @@ Update Arrays
370392
.. tab:: Positional Operator (Async)
371393
:tabid: update-many-allpositional-async
372394

395+
.. include:: /includes/update-many/allpositional-operator-code-intro.rst
396+
373397
.. literalinclude:: /includes/code-examples/update-many/UpdateManyArrays.cs
374398
:language: csharp
375399
:copyable: true
@@ -380,6 +404,8 @@ Update Arrays
380404
.. tab:: LINQ (Sync)
381405
:tabid: update-many-allpositional-linq-sync
382406

407+
.. include:: /includes/update-many/allpositional-linq-code-intro.rst
408+
383409
.. literalinclude:: /includes/code-examples/update-many/UpdateManyArrays.cs
384410
:language: csharp
385411
:copyable: true
@@ -390,6 +416,8 @@ Update Arrays
390416
.. tab:: LINQ (Async)
391417
:tabid: update-many-allpositional-linq-async
392418

419+
.. include:: /includes/update-many/allpositional-linq-code-intro.rst
420+
393421
.. literalinclude:: /includes/code-examples/update-many/UpdateManyArrays.cs
394422
:language: csharp
395423
:copyable: true

source/fundamentals/crud/write-operations/update-one/arrays.txt

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,32 +266,42 @@ Update Arrays
266266
:emphasize-lines: 15-19
267267

268268
.. replacement:: positional-code-example-tabs
269-
269+
270270
.. tabs::
271271

272272
.. tab:: Positional Operator (Sync)
273273
:tabid: update-one-positional-sync
274274

275+
.. include:: /includes/update-one/positional-operator-code-intro.rst
276+
275277
.. literalinclude:: /includes/code-examples/update-one/UpdateOneArrays.cs
276278
:language: csharp
277279
:copyable: true
278280
:dedent:
279281
:start-after: // start-update-one-positional
280282
:end-before: // end-update-one-positional
281283

284+
.. include:: /includes/update-arrays-positional-operator-note.rst
285+
282286
.. tab:: Positional Operator (Async)
283287
:tabid: update-one-positional-async
284-
288+
289+
.. include:: /includes/update-one/positional-operator-code-intro.rst
290+
285291
.. literalinclude:: /includes/code-examples/update-one/UpdateOneArrays.cs
286292
:language: csharp
287293
:copyable: true
288294
:dedent:
289295
:start-after: // start-update-one-positional-async
290296
:end-before: // end-update-one-positional-async
291297

298+
.. include:: /includes/update-arrays-positional-operator-note.rst
299+
292300
.. tab:: LINQ (Sync)
293301
:tabid: update-one-positional-linq-sync
294302

303+
.. include:: /includes/update-one/positional-linq-code-intro.rst
304+
295305
.. literalinclude:: /includes/code-examples/update-one/UpdateOneArrays.cs
296306
:language: csharp
297307
:copyable: true
@@ -302,6 +312,8 @@ Update Arrays
302312
.. tab:: LINQ (Async)
303313
:tabid: update-one-positional-linq-async
304314

315+
.. include:: /includes/update-one/positional-linq-code-intro.rst
316+
305317
.. literalinclude:: /includes/code-examples/update-one/UpdateOneArrays.cs
306318
:language: csharp
307319
:copyable: true
@@ -316,6 +328,8 @@ Update Arrays
316328
.. tab:: Positional Operator (Sync)
317329
:tabid: update-one-filteredpositional-sync
318330

331+
.. include:: /includes/update-many/filteredpositional-operator-code-intro.rst
332+
319333
.. literalinclude:: /includes/code-examples/update-one/UpdateOneArrays.cs
320334
:language: csharp
321335
:copyable: true
@@ -326,6 +340,8 @@ Update Arrays
326340
.. tab:: Positional Operator (Async)
327341
:tabid: update-one-filteredpositional-async
328342

343+
.. include:: /includes/update-many/filteredpositional-operator-code-intro.rst
344+
329345
.. literalinclude:: /includes/code-examples/update-one/UpdateOneArrays.cs
330346
:language: csharp
331347
:copyable: true
@@ -336,6 +352,8 @@ Update Arrays
336352
.. tab:: LINQ (Sync)
337353
:tabid: update-one-filteredpositional-linq-sync
338354

355+
.. include:: /includes/update-many/filteredpositional-linq-code-intro.rst
356+
339357
.. literalinclude:: /includes/code-examples/update-one/UpdateOneArrays.cs
340358
:language: csharp
341359
:copyable: true
@@ -346,6 +364,8 @@ Update Arrays
346364
.. tab:: LINQ (Async)
347365
:tabid: update-one-filteredpositional-linq-async
348366

367+
.. include:: /includes/update-many/filteredpositional-linq-code-intro.rst
368+
349369
.. literalinclude:: /includes/code-examples/update-one/UpdateOneArrays.cs
350370
:language: csharp
351371
:copyable: true
@@ -360,6 +380,8 @@ Update Arrays
360380
.. tab:: Positional Operator (Sync)
361381
:tabid: update-one-allpositional-sync
362382

383+
.. include:: /includes/update-one/allpositional-operator-code-intro.rst
384+
363385
.. literalinclude:: /includes/code-examples/update-one/UpdateOneArrays.cs
364386
:language: csharp
365387
:copyable: true
@@ -370,6 +392,8 @@ Update Arrays
370392
.. tab:: Positional Operator (Async)
371393
:tabid: update-one-allpositional-async
372394

395+
.. include:: /includes/update-one/allpositional-operator-code-intro.rst
396+
373397
.. literalinclude:: /includes/code-examples/update-one/UpdateOneArrays.cs
374398
:language: csharp
375399
:copyable: true
@@ -380,6 +404,8 @@ Update Arrays
380404
.. tab:: LINQ (Sync)
381405
:tabid: update-one-allpositional-linq-sync
382406

407+
.. include:: /includes/update-one/allpositional-linq-code-intro.rst
408+
383409
.. literalinclude:: /includes/code-examples/update-one/UpdateOneArrays.cs
384410
:language: csharp
385411
:copyable: true
@@ -390,6 +416,8 @@ Update Arrays
390416
.. tab:: LINQ (Async)
391417
:tabid: update-one-allpositional-linq-async
392418

419+
.. include:: /includes/update-one/allpositional-linq-code-intro.rst
420+
393421
.. literalinclude:: /includes/code-examples/update-one/UpdateOneArrays.cs
394422
:language: csharp
395423
:copyable: true

source/includes/code-examples/update-many/UpdateMany.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static void CombineUpdates()
106106

107107
var combinedUpdate = Builders<Restaurant>.Update.Combine(
108108
Builders<Restaurant>.Update.Set("cuisine", "French"),
109-
Builders<Restaurant>.Update.PopLast("grades")
109+
Builders<Restaurant>.Update.Unset("borough")
110110
);
111111

112112
_restaurantsCollection.UpdateMany(filter, combinedUpdate);
@@ -121,7 +121,7 @@ public static async Task CombineUpdatesAsync()
121121

122122
var combinedUpdate = Builders<Restaurant>.Update.Combine(
123123
Builders<Restaurant>.Update.Set("cuisine", "French"),
124-
Builders<Restaurant>.Update.PopLast("grades")
124+
Builders<Restaurant>.Update.Unset("borough")
125125
);
126126

127127
await _restaurantsCollection.UpdateManyAsync(filter, combinedUpdate);

source/includes/code-examples/update-one/UpdateOne.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public static void CombineUpdates()
9999

100100
var combinedUpdate = Builders<Restaurant>.Update.Combine(
101101
Builders<Restaurant>.Update.Set("cuisine", "French"),
102-
Builders<Restaurant>.Update.PopLast("grades")
102+
Builders<Restaurant>.Update.Unset("borough")
103103
);
104104

105105
_restaurantsCollection.UpdateOne(filter, combinedUpdate);
@@ -114,7 +114,7 @@ public static async Task CombineUpdatesAsync()
114114

115115
var combinedUpdate = Builders<Restaurant>.Update.Combine(
116116
Builders<Restaurant>.Update.Set("cuisine", "French"),
117-
Builders<Restaurant>.Update.PopLast("grades")
117+
Builders<Restaurant>.Update.Unset("borough")
118118
);
119119

120120
await _restaurantsCollection.UpdateOneAsync(filter, combinedUpdate);

source/includes/page-templates/update/arrays.rst

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ Because these values already exist in the array, the update operation does nothi
163163
Remove Values
164164
-------------
165165

166+
The following sections explain how to remove values from an array field.
167+
168+
First Value
169+
~~~~~~~~~~~
170+
166171
To remove the first value from an array, call the ``Builders.Update.PopFirst()`` method.
167172
This method accepts the following parameter:
168173

@@ -183,6 +188,9 @@ object from the ``Grades`` array in |matching-document-or-documents|:
183188

184189
|popfirst-code-example-tabs|
185190

191+
Last Value
192+
~~~~~~~~~~
193+
186194
To remove the last value from an array, call the ``Builders.Update.PopLast()`` method:
187195
This method accepts the following parameter:
188196

@@ -203,6 +211,9 @@ object from the ``Grades`` array in |matching-document-or-documents|:
203211

204212
|poplast-code-example-tabs|
205213

214+
All Instances of a Value
215+
~~~~~~~~~~~~~~~~~~~~~~~~
216+
206217
To remove all instances of a specific value from an array, call the
207218
``Builders.Update.Pull()`` method. This method accepts the following parameters:
208219

@@ -228,6 +239,9 @@ a specific ``GradeEntry`` object from the ``Grades`` array in |matching-document
228239

229240
|pull-code-example-tabs|
230241

242+
All Instances of Multiple Values
243+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
244+
231245
To remove all instances of more than one specific value from an array, call the
232246
``Builders.Update.PullAll()`` method.
233247
This method accepts the following parameters:
@@ -254,6 +268,9 @@ specific ``GradeEntry`` objects from the ``Grades`` array in |matching-document-
254268

255269
|pullall-code-example-tabs|
256270

271+
All Values That Match a Condition
272+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273+
257274
To remove all values that match a specific condition from an array, call the
258275
``Builders.Update.PullFilter()`` method.
259276
This method accepts the following parameters:
@@ -315,42 +332,30 @@ The following sections describe different ways to update matching values in an a
315332
First Matching Value
316333
~~~~~~~~~~~~~~~~~~~~
317334

318-
To update only the first value in an array that matches a query filter, use the
319-
positional operator (``$``) with the ``Set()`` method.
320-
321-
.. note::
322-
323-
To use the positional operator, the array field must be part of the query filter.
324-
325-
The following example uses the ``Set()`` method and the positional operator to
326-
update the ``Grades`` array in |matching-document-or-documents|. First,
327-
it finds *only the first* ``GradeEntry`` object in the ``Grades`` array where the ``Grade`` property
328-
has the value ``"A"``. Then, it updates the ``Score`` property of the first matching
329-
``GradeEntry`` object to 100.
335+
To update the first value in an array, you can use either the positional operator
336+
(``$``) or LINQ syntax.
337+
Select a :guilabel:`Positional Operator` or :guilabel:`LINQ` tab to
338+
see the corresponding syntax.
330339

331340
|positional-code-example-tabs|
332341

333342
All Matching Values
334343
~~~~~~~~~~~~~~~~~~~
335344

336-
To update all values in an array that match a specified condition, use the filtered
337-
positional operator (``$[<identifier>]``) with the ``Set()`` method.
338-
339-
The following example uses the ``Set()`` method and the filtered positional operator
340-
to update the ``Score`` property of all matching
341-
``GradeEntry`` objects in the ``Grades`` array to 100 in |matching-document-or-documents|:
345+
To update all values in an array that match a specified condition, you can use either
346+
the filtered positional operator (``$[<identifier>]``) or LINQ syntax.
347+
Select a :guilabel:`Positional Operator` or :guilabel:`LINQ` tab to
348+
see the corresponding syntax.
342349

343350
|filteredpositional-code-example-tabs|
344351

345352
All Values
346353
~~~~~~~~~~
347354

348-
To update all values in an array that match a query filter, use the all-positional operator
349-
(``$[]``) with the ``Set()`` method.
350-
351-
The following example uses the ``Set()`` method and the all-positional operator
352-
to update the ``Score`` property of all ``GradeEntry`` objects in the ``Grades`` array
353-
to 100 in |matching-document-or-documents|:
355+
To update all values in an array that match a query filter, you can use either the
356+
all-positional operator (``$[]``) or LINQ syntax.
357+
Select a :guilabel:`Positional Operator` or :guilabel:`LINQ` tab to
358+
see the corresponding syntax.
354359

355360
|allpositional-code-example-tabs|
356361

source/includes/page-templates/update/fields.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ method. This method accepts the following parameters:
108108

109109
**Data Type:** ``TField``
110110

111-
Set If Lower or Greater
112-
-----------------------
111+
Set by Comparison
112+
-----------------
113113

114114
To update the value of the field to a specified value, but only if the specified value
115115
is *greater than* the current value of the field, call the ``Builders.Update.Max()``

0 commit comments

Comments
 (0)