@@ -3,3 +3,56 @@ Update Multiple Documents
33=========================
44
55.. default-domain:: mongodb
6+
7+ You can update multiple documents in a collection by using the ``UpdateMany()``
8+ method.
9+
10+ The following example passes a query filter and an update parameter to the
11+ ``UpdateMany()`` method, which matches documents in the
12+ ``listingsAndReviews`` collection where the value of the ``address.market``
13+ field is "Sydney" and multiplies the ``price`` field in the matching
14+ documents by a factor of *1.15*:
15+
16+ .. include:: /includes/run-example-tip.rst
17+
18+ .. literalinclude:: /code-snippets/updateMany.go
19+ :start-after: begin updatemany
20+ :end-before: end updatemany
21+ :emphasize-lines: 5
22+ :language: go
23+ :dedent:
24+
25+ Click here **<TODO: github link to file>** to see a fully runnable example.
26+
27+ Expected Result
28+ ---------------
29+
30+ After you run the code example, the ``price`` field of the matched
31+ documents will reflect the multiplication. The updated documents will
32+ appear similar to these:
33+
34+ .. code-block:: json
35+ :copyable: false
36+
37+ // results truncated
38+ ...
39+ { "_id" : "10091713", ... , "name" : "Surry Hills Studio", ... , "price" : 181.00, ... },
40+ { "_id" : "9908871", ... , "name" : "Family friendly beach house", ... , "price" : 751.00, ... },
41+ { "_id" : "20989061", ... , "name" : "Big and sunny Narraben room", ... , "price" : 60.00, ... },
42+ ...
43+
44+ Additional Information
45+ ----------------------
46+
47+ For more information on updating documents, specifying query filters, and
48+ handling potential errors, see our guide on **<TODO: change a document
49+ fundamental page>**.
50+
51+ For more information on update operators,
52+ see the :manual:`MongoDB update operator reference documentation
53+ </reference/operator/update/#update-operators>`.
54+
55+ API Documentation
56+ ~~~~~~~~~~~~~~~~~
57+
58+ `UpdateMany() <https://pkg.go.dev/go.mongodb.org/
[email protected] /mongo#Collection.UpdateMany>`_
0 commit comments