@@ -922,7 +922,7 @@ with :method:`~db.collection.update()`.
922922
923923 .. code-block:: javascript
924924
925- db.books.insertMany([
925+ db.books.insertMany( [
926926 {
927927 _id: 5,
928928 item: "RQM909",
@@ -937,7 +937,7 @@ with :method:`~db.collection.update()`.
937937 info: { publisher: "1111", pages: 72 },
938938 reorder: true
939939 }
940- ])
940+ ] )
941941
942942 The following operation specifies both the ``multi`` option and
943943 the ``upsert`` option. If matching documents exist, the
@@ -1071,10 +1071,10 @@ Create a ``members`` collection with the following documents:
10711071
10721072.. code-block:: javascript
10731073
1074- db.members.insertMany([
1074+ db.members.insertMany( [
10751075 { "_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") },
10761076 { "_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") }
1077- ])
1077+ ] )
10781078
10791079Assume that instead of separate ``misc1`` and ``misc2`` fields, you
10801080want to gather these into a new ``comments`` field. The following
@@ -1137,11 +1137,11 @@ Create a ``students3`` collection with the following documents:
11371137
11381138.. code-block:: javascript
11391139
1140- db.students3.insert( [
1140+ db.students3.insertMany( [
11411141 { "_id" : 1, "tests" : [ 95, 92, 90 ], "lastUpdate" : ISODate("2019-01-01T00:00:00Z") },
11421142 { "_id" : 2, "tests" : [ 94, 88, 90 ], "lastUpdate" : ISODate("2019-01-01T00:00:00Z") },
11431143 { "_id" : 3, "tests" : [ 70, 75, 82 ], "lastUpdate" : ISODate("2019-01-01T00:00:00Z") }
1144- ]);
1144+ ] )
11451145
11461146Using an aggregation pipeline, you can update the documents with the
11471147calculated grade average and letter grade.
@@ -1223,11 +1223,11 @@ collection with the following documents:
12231223
12241224.. code-block:: javascript
12251225
1226- db.students.insertMany([
1226+ db.students.insertMany( [
12271227 { "_id" : 1, "grades" : [ 95, 92, 90 ] },
12281228 { "_id" : 2, "grades" : [ 98, 100, 102 ] },
12291229 { "_id" : 3, "grades" : [ 95, 110, 100 ] }
1230- ])
1230+ ] )
12311231
12321232To update all elements that are greater than or equal to ``100`` in the
12331233``grades`` array, use the filtered positional operator
@@ -1264,7 +1264,7 @@ collection with the following documents:
12641264
12651265.. code-block:: javascript
12661266
1267- db.students2.insertMany([
1267+ db.students2.insertMany( [
12681268 {
12691269 "_id" : 1,
12701270 "grades" : [
@@ -1281,7 +1281,7 @@ collection with the following documents:
12811281 { "grade" : 85, "mean" : 85, "std" : 4 }
12821282 ]
12831283 }
1284- ])
1284+ ] )
12851285
12861286To modify the value of the ``mean`` field for all elements in the
12871287``grades`` array where the grade is greater than or equal to ``85``,
@@ -1332,14 +1332,14 @@ collection with the following documents:
13321332
13331333.. code-block:: javascript
13341334
1335- db.members.insertMany([
1335+ db.members.insertMany( [
13361336 { "_id" : 1, "member" : "abc123", "status" : "P", "points" : 0, "misc1" : null, "misc2" : null },
13371337 { "_id" : 2, "member" : "xyz123", "status" : "A", "points" : 60, "misc1" : "reminder: ping me at 100pts", "misc2" : "Some random comment" },
13381338 { "_id" : 3, "member" : "lmn123", "status" : "P", "points" : 0, "misc1" : null, "misc2" : null },
13391339 { "_id" : 4, "member" : "pqr123", "status" : "D", "points" : 20, "misc1" : "Deactivated", "misc2" : null },
13401340 { "_id" : 5, "member" : "ijk123", "status" : "P", "points" : 0, "misc1" : null, "misc2" : null },
13411341 { "_id" : 6, "member" : "cde123", "status" : "A", "points" : 86, "misc1" : "reminder: ping me at 100pts", "misc2" : "Some random comment" }
1342- ])
1342+ ] )
13431343
13441344Create the following indexes on the collection:
13451345
@@ -1434,12 +1434,11 @@ In :binary:`~bin.mongosh`, create a collection named
14341434
14351435.. code-block:: javascript
14361436
1437- db.myColl.insertMany(
1438- [
1437+ db.myColl.insertMany( [
14391438 { _id: 1, category: "café", status: "A" },
14401439 { _id: 2, category: "cafe", status: "a" },
14411440 { _id: 3, category: "cafE", status: "a" }
1442- ] )
1441+ ] )
14431442
14441443The following operation includes the :ref:`collation <collation>`
14451444option and sets ``multi`` to ``true`` to update all matching documents:
0 commit comments