@@ -30,28 +30,22 @@ The following sections focus on ``insertOne()`` and
30
30
method, see our
31
31
:doc:`guide on Bulk Operations </crud/write-operations/bulk/>`.
32
32
33
- A Note About ``_id``
34
- --------------------
33
+ .. note:: The ``id_`` field in Insert Operations
35
34
36
- When inserting a document, MongoDB enforces one constraint on your
37
- documents by default: each document *must* contain a unique ``_id``
38
- field.
35
+ When inserting a document, MongoDB enforces one constraint on your
36
+ documents by default: each document *must* contain a unique ``_id``
37
+ field. Duplicate ``_id`` values violate unique index constraints, resulting in a ``WriteError``.
39
38
40
- There are two ways to manage this field:
39
+ There are two ways to manage this field:
41
40
42
- - You can manage this field yourself, ensuring each value you use is unique.
43
- - You can let the driver automatically generate unique ObjectId values.
41
+ - You can manage this field yourself, ensuring each value you use is unique.
42
+ - You can let the driver automatically generate unique ObjectId values.
44
43
45
- Unless you have provided strong guarantees for uniqueness, we recommend
46
- you let the driver automatically generate ``_id`` values.
47
-
48
- .. note::
49
-
50
- Duplicate ``_id`` values violate unique index constraints, resulting
51
- in a ``WriteError``.
52
-
53
- For additional information on unique indexes, see the manual entry on
54
- :manual:`Unique Indexes </core/index-unique/>`.
44
+ Unless you have provided strong guarantees for uniqueness, we recommend
45
+ you let the driver automatically generate ``_id`` values.
46
+
47
+ For additional information on unique indexes, see the manual entry on
48
+ :manual:`Unique Indexes </core/index-unique/>`.
55
49
56
50
Insert a Single Document
57
51
------------------------
0 commit comments