@@ -44,7 +44,7 @@ The following sections describe these methods in more detail.
44
44
Many of the methods in this guide have multiple overloads. The examples
45
45
in this guide use the simplest overload for demonstration purposes. For
46
46
more information about the available overloads, see the
47
- :manual:` {+new-api-root+} API documentation </api-reference>`.
47
+ `API documentation. {+new-api-root+}/index.html>`__
48
48
49
49
.. tip:: Interactive Lab
50
50
@@ -73,7 +73,7 @@ methods all accept the following parameters:
73
73
- An instance of the ``FilterDefinition`` class that specifies the documents to update.
74
74
To learn how to create a query filter, see :ref:`csharp-specify-query`.
75
75
76
- **Data Type:** `FilterDefinition<TDocument> <{+new-api-root+>/MongoDB.Driver/MongoDB.Driver.FilterDefinition-1.html>`__
76
+ **Data Type:** `FilterDefinition <{+new-api-root+>/MongoDB.Driver/MongoDB.Driver.FilterDefinition-1.html>`__
77
77
78
78
* - ``update``
79
79
- An instance of the ``UpdateDefinition`` class. This object specifies the kind of update
@@ -99,8 +99,8 @@ Update Multiple Values
99
99
----------------------
100
100
101
101
The ``UpdateOne()``, ``UpdateOneAsync()``, ``UpdateMany()``, and ``UpdateManyAsync()``
102
- methods each accept one ``UpdateDefinition`` object. The following sections describe how
103
- to multiple values in a single method call.
102
+ methods each accept only one ``UpdateDefinition`` object. The following sections describe how
103
+ to update multiple values in a single method call.
104
104
105
105
Combine Update Definitions
106
106
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -124,13 +124,13 @@ The ``Combine()`` method returns a single ``UpdateDefinition`` object that defin
124
124
multiple update operations.
125
125
126
126
The following code example uses the ``Combine()`` method to combine a
127
- :manual:`$set </reference/operator/update/set/#mongodb-update-up.-set>` operation and a
128
- :manual:`$pop </reference/operator/update/pop/#mongodb-update-up.-pop >`
127
+ :manual:`$set </reference/operator/update/set/#mongodb-update-up.-set>` operation and an
128
+ :manual:`$unset </reference/operator/update/pop/#mongodb-update-up.-unset >`
129
129
operation:
130
130
131
131
.. tabs::
132
132
133
- .. tab:: UpdateOne (Synchronous )
133
+ .. tab:: UpdateOne (Sync )
134
134
:tabid: update-one-sync
135
135
136
136
.. literalinclude:: /includes/code-examples/update-one/UpdateOne.cs
@@ -140,7 +140,7 @@ operation:
140
140
:start-after: // start-combine-sync
141
141
:end-before: // end-combine-sync
142
142
143
- .. tab:: UpdateOne (Asynchronous )
143
+ .. tab:: UpdateOne (Async )
144
144
:tabid: update-one-async
145
145
146
146
.. literalinclude:: /includes/code-examples/update-one/UpdateOne.cs
@@ -150,7 +150,7 @@ operation:
150
150
:start-after: // start-combine-async
151
151
:end-before: // end-combine-async
152
152
153
- .. tab:: UpdateMany (Synchronous )
153
+ .. tab:: UpdateMany (Sync )
154
154
:tabid: update-many-sync
155
155
156
156
.. literalinclude:: /includes/code-examples/update-many/UpdateMany.cs
@@ -160,7 +160,7 @@ operation:
160
160
:start-after: // start-combine-sync
161
161
:end-before: // end-combine-sync
162
162
163
- .. tab:: UpdateMany (Asynchronous )
163
+ .. tab:: UpdateMany (Async )
164
164
:tabid: update-many-async
165
165
166
166
.. literalinclude:: /includes/code-examples/update-many/UpdateMany.cs
@@ -173,8 +173,12 @@ operation:
173
173
Update Pipelines
174
174
~~~~~~~~~~~~~~~~
175
175
176
- Builders.Update.Pipeline is used to create an update pipeline for MongoDB update operations. An update pipeline allows you to specify a sequence of update stages that modify the documents in a collection. Each stage in the pipeline is an update operation that transforms the document in some way. This is similar to the aggregation pipeline but is used specifically for updates.
177
- This method accepts the following parameter:
176
+ If your application connects to {+mdb-server+} 4.2 or later, you can join
177
+ a sequence of update operations into a single
178
+ :manual:`aggregation pipeline. </core/aggregation-pipeline/>`
179
+
180
+ To create an update pipeline, call the ``Builders.Update.Pipeline()`` method. This method
181
+ accepts the following parameter:
178
182
179
183
.. list-table::
180
184
:widths: 30 70
@@ -184,17 +188,69 @@ This method accepts the following parameter:
184
188
- Description
185
189
186
190
* - ``pipeline``
187
- - A ``PipelineDefinition`` instance that specifies the update pipeline.
191
+ - A ``PipelineDefinition`` instance that represents the update pipeline. To create
192
+ a ``PipelineDefinition`` object, create a BSON object for each update operation you
193
+ want to perform, then pass these objects to the ``Pipeline.Create()`` method.
188
194
189
195
**Data Type:** ``PipelineDefinition<TDocument, TDocument>``
190
196
191
- .. tip:: Aggregation Pipelines in Update Operations
197
+ The ``Pipeline()`` method returns a single ``UpdateDefinition`` object that defines
198
+ multiple aggregation stages.
199
+
200
+ The following code example uses the ``Pipeline()`` method to combine a
201
+ :manual:`$set </reference/operator/update/set/#mongodb-update-up.-set>` operation and an
202
+ :manual:`$unset </reference/operator/update/pop/#mongodb-update-up.-unset>`
203
+ operation:
204
+
205
+ .. tabs::
206
+
207
+ .. tab:: UpdateOne (Sync)
208
+ :tabid: update-one-sync
209
+
210
+ .. literalinclude:: /includes/code-examples/update-one/UpdateOne.cs
211
+ :language: csharp
212
+ :copyable: true
213
+ :dedent:
214
+ :start-after: // start-pipeline-sync
215
+ :end-before: // end-pipeline-sync
216
+
217
+ .. tab:: UpdateOne (Async)
218
+ :tabid: update-one-async
219
+
220
+ .. literalinclude:: /includes/code-examples/update-one/UpdateOne.cs
221
+ :language: csharp
222
+ :copyable: true
223
+ :dedent:
224
+ :start-after: // start-pipeline-async
225
+ :end-before: // end-pipeline-async
226
+
227
+ .. tab:: UpdateMany (Sync)
228
+ :tabid: update-many-sync
229
+
230
+ .. literalinclude:: /includes/code-examples/update-many/UpdateMany.cs
231
+ :language: csharp
232
+ :copyable: true
233
+ :dedent:
234
+ :start-after: // start-pipeline-sync
235
+ :end-before: // end-pipeline-sync
236
+
237
+ .. tab:: UpdateMany (Async)
238
+ :tabid: update-many-async
239
+
240
+ .. literalinclude:: /includes/code-examples/update-many/UpdateMany.cs
241
+ :language: csharp
242
+ :copyable: true
243
+ :dedent:
244
+ :start-after: // start-pipeline-async
245
+ :end-before: // end-pipeline-async
246
+
247
+ .. note:: Unsupported Operations
192
248
193
- If you are using MongoDB Version 4.2 or later, you can use aggregation
194
- pipelines made up of a subset of aggregation stages in update operations . For
195
- more information on the aggregation stages MongoDB supports in
196
- aggregation pipelines used in update operations, see the tutorial about building
197
- :manual:`updates with aggregation pipelines </tutorial/update-documents-with-aggregation-pipeline/>` .
249
+ Update pipelines don't support all update operations, but they do support certain
250
+ aggregation stages not found in other update definitions . For a list of
251
+ update operations supported by pipelines, see
252
+ :manual:`Updates with Aggregation Pipeline </ tutorial/update-documents-with-aggregation-pipeline/>`
253
+ in the {+mdb-server+} manual .
198
254
199
255
.. _csharp-update-options:
200
256
0 commit comments