@@ -918,7 +918,7 @@ with :method:`~db.collection.update()`.
918918
919919 .. code-block:: javascript
920920
921- db.books.insertMany([
921+ db.books.insertMany( [
922922 {
923923 _id: 5,
924924 item: "RQM909",
@@ -933,7 +933,7 @@ with :method:`~db.collection.update()`.
933933 info: { publisher: "1111", pages: 72 },
934934 reorder: true
935935 }
936- ])
936+ ] )
937937
938938 The following operation specifies both the ``multi`` option and
939939 the ``upsert`` option. If matching documents exist, the
@@ -1067,10 +1067,10 @@ Create a ``members`` collection with the following documents:
10671067
10681068.. code-block:: javascript
10691069
1070- db.members.insertMany([
1070+ db.members.insertMany( [
10711071 { "_id" : 1, "member" : "abc123", "status" : "A", "points" : 2, "misc1" : "note to self: confirm status", "misc2" : "Need to activate", "lastUpdate" : ISODate("2019-01-01T00:00:00Z") },
10721072 { "_id" : 2, "member" : "xyz123", "status" : "A", "points" : 60, "misc1" : "reminder: ping me at 100pts", "misc2" : "Some random comment", "lastUpdate" : ISODate("2019-01-01T00:00:00Z") }
1073- ])
1073+ ] )
10741074
10751075Assume that instead of separate ``misc1`` and ``misc2`` fields, you
10761076want to gather these into a new ``comments`` field. The following
@@ -1133,11 +1133,11 @@ Create a ``students3`` collection with the following documents:
11331133
11341134.. code-block:: javascript
11351135
1136- db.students3.insert( [
1136+ db.students3.insertMany( [
11371137 { "_id" : 1, "tests" : [ 95, 92, 90 ], "lastUpdate" : ISODate("2019-01-01T00:00:00Z") },
11381138 { "_id" : 2, "tests" : [ 94, 88, 90 ], "lastUpdate" : ISODate("2019-01-01T00:00:00Z") },
11391139 { "_id" : 3, "tests" : [ 70, 75, 82 ], "lastUpdate" : ISODate("2019-01-01T00:00:00Z") }
1140- ]);
1140+ ] )
11411141
11421142Using an aggregation pipeline, you can update the documents with the
11431143calculated grade average and letter grade.
@@ -1219,11 +1219,11 @@ collection with the following documents:
12191219
12201220.. code-block:: javascript
12211221
1222- db.students.insertMany([
1222+ db.students.insertMany( [
12231223 { "_id" : 1, "grades" : [ 95, 92, 90 ] },
12241224 { "_id" : 2, "grades" : [ 98, 100, 102 ] },
12251225 { "_id" : 3, "grades" : [ 95, 110, 100 ] }
1226- ])
1226+ ] )
12271227
12281228To update all elements that are greater than or equal to ``100`` in the
12291229``grades`` array, use the filtered positional operator
@@ -1260,7 +1260,7 @@ collection with the following documents:
12601260
12611261.. code-block:: javascript
12621262
1263- db.students2.insertMany([
1263+ db.students2.insertMany( [
12641264 {
12651265 "_id" : 1,
12661266 "grades" : [
@@ -1277,7 +1277,7 @@ collection with the following documents:
12771277 { "grade" : 85, "mean" : 85, "std" : 4 }
12781278 ]
12791279 }
1280- ])
1280+ ] )
12811281
12821282To modify the value of the ``mean`` field for all elements in the
12831283``grades`` array where the grade is greater than or equal to ``85``,
@@ -1328,14 +1328,14 @@ collection with the following documents:
13281328
13291329.. code-block:: javascript
13301330
1331- db.members.insertMany([
1331+ db.members.insertMany( [
13321332 { "_id" : 1, "member" : "abc123", "status" : "P", "points" : 0, "misc1" : null, "misc2" : null },
13331333 { "_id" : 2, "member" : "xyz123", "status" : "A", "points" : 60, "misc1" : "reminder: ping me at 100pts", "misc2" : "Some random comment" },
13341334 { "_id" : 3, "member" : "lmn123", "status" : "P", "points" : 0, "misc1" : null, "misc2" : null },
13351335 { "_id" : 4, "member" : "pqr123", "status" : "D", "points" : 20, "misc1" : "Deactivated", "misc2" : null },
13361336 { "_id" : 5, "member" : "ijk123", "status" : "P", "points" : 0, "misc1" : null, "misc2" : null },
13371337 { "_id" : 6, "member" : "cde123", "status" : "A", "points" : 86, "misc1" : "reminder: ping me at 100pts", "misc2" : "Some random comment" }
1338- ])
1338+ ] )
13391339
13401340Create the following indexes on the collection:
13411341
@@ -1430,12 +1430,11 @@ In :binary:`~bin.mongosh`, create a collection named
14301430
14311431.. code-block:: javascript
14321432
1433- db.myColl.insertMany(
1434- [
1433+ db.myColl.insertMany( [
14351434 { _id: 1, category: "café", status: "A" },
14361435 { _id: 2, category: "cafe", status: "a" },
14371436 { _id: 3, category: "cafE", status: "a" }
1438- ] )
1437+ ] )
14391438
14401439The following operation includes the :ref:`collation <collation>`
14411440option and sets ``multi`` to ``true`` to update all matching documents:
0 commit comments