Skip to content

Commit 440ea50

Browse files
committed
wip
1 parent 3f5cec0 commit 440ea50

File tree

1 file changed

+3
-44
lines changed
  • source/fundamentals/crud/write-operations

1 file changed

+3
-44
lines changed

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

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ methods all accept the following parameters:
8585

8686
* - ``options``
8787
- *Optional.* An instance of the ``UpdateOptions`` class that specifies the
88-
configuration for the update operation. The default value is ``null``. To learn
89-
about the available options, see :ref:`csharp-update-options`.
88+
configuration for the update operation. The default value is ``null``. For a list
89+
of available option, see :ref:`csharp-update-options`.
9090

9191
**Data Type:** `UpdateOptions <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.UpdateOptions.html>`__
9292

@@ -320,47 +320,6 @@ The ``UpdateOptions`` class contains the following properties:
320320

321321
**Data Type:** `BsonDocument <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.BsonDocument.html>`__
322322

323-
Example
324-
~~~~~~~
325-
326-
The following code uses the ``UpdateMany()`` method to find all documents where the
327-
``borough`` field has the value "Manhattan", then updates the ``borough``
328-
value in these documents to "Manhattan (north)". Because the ``IsUpsert`` option is
329-
set to ``true``, the driver inserts a new document if the query filter doesn't
330-
match any existing documents.
331-
332-
.. io-code-block::
333-
:copyable: true
334-
335-
.. input::
336-
:language: csharp
337-
338-
var filter = Builders<Restaurant>.Filter
339-
.Eq(restaurant => restaurant.Borough, "Manhattan");
340-
341-
var update = Builders<Restaurant>.Update
342-
.Set(restaurant => restaurant.Borough, "Manhattan (north)");
343-
344-
UpdateOptions opts = new UpdateOptions()
345-
{
346-
Comment = new BsonString("Borough updated for C# Driver Fundamentals"),
347-
IsUpsert = true
348-
};
349-
350-
Console.WriteLine("Updating documents...");
351-
var result = _restaurantsCollection.UpdateMany(filter, update, opts);
352-
353-
Console.WriteLine($"Updated documents: {result.ModifiedCount}");
354-
Console.WriteLine($"Result acknowledged? {result.IsAcknowledged}");
355-
356-
.. output::
357-
:language: none
358-
:visible: false
359-
360-
Updating documents...
361-
Updated documents: 10259
362-
Result acknowledged? True
363-
364323
Return Value
365324
------------
366325

@@ -402,7 +361,7 @@ The ``UpdateResult`` class contains the following properties:
402361
- The ID of the document that was upserted in the database, if the driver
403362
performed an upsert.
404363

405-
**Data Type:** `BsonValue <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.BsonValue.html>`__
364+
**Data Type:** `BsonValue <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.BsonValue.html>`__
406365

407366
Additional Information
408367
----------------------

0 commit comments

Comments
 (0)