@@ -93,8 +93,10 @@ the collection since the index enforces uniqueness for the
9393
9494.. code-block:: javascript
9595
96- db.collection.insert( { _id: 2, a: [ { loc: "A" }, { qty: 5 } ] } )
97- db.collection.insert( { _id: 3, a: [ { loc: "A", qty: 10 } ] } )
96+ db.collection.insertMany( [
97+ { _id: 2, a: [ { loc: "A" }, { qty: 5 } ] },
98+ { _id: 3, a: [ { loc: "A", qty: 10 } ] }
99+ ] )
98100
99101.. seealso::
100102
@@ -168,7 +170,7 @@ value of ``{ "a.loc": "B", "a.qty": null }``.
168170
169171.. code-block:: javascript
170172
171- db.collection.insert ( { _id: 4, a: [ { loc: "B" }, { loc: "B" } ] } )
173+ db.collection.insertOne ( { _id: 4, a: [ { loc: "B" }, { loc: "B" } ] } )
172174
173175.. _unique-index-and-missing-field:
174176
@@ -194,15 +196,15 @@ field ``x``:
194196
195197.. code-block:: javascript
196198
197- db.collection.insert ( { y: 1 } )
199+ db.collection.insertOne ( { y: 1 } )
198200
199201However, the unique index errors on the insertion of a document without
200202the field ``x`` if the collection already contains a document missing
201203the field ``x``:
202204
203205.. code-block:: javascript
204206
205- db.collection.insert ( { z: 1 } )
207+ db.collection.insertOne ( { z: 1 } )
206208
207209The operation fails to insert the document because of the violation of
208210the unique constraint on the value of the field ``x``:
0 commit comments