Skip to content

Commit aac4cad

Browse files
committed
DOCS-5167: Move 3.0 dot notation change example out of API reference
Fix of 0086057
1 parent e5147ee commit aac4cad

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

source/includes/apiargs-method-db.collection.update-param.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ description: |
88
99
.. include:: /includes/fact-mongodb30-upsert-id.rst
1010
11+
For an example, see :ref:`mongodb30-upsert-id`.
12+
1113
interface: method
1214
name: query
1315
operation: db.collection.update
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
For example, consider the following update operation. Since the update
2+
operation specifies ``upsert:true`` and the query specifies conditions on the
3+
``_id`` field using dot notation, then the update will result in an error when
4+
constructing the document to insert.
5+
6+
.. code-block:: javascript
7+
8+
db.collection.update( { "_id.name": "Robert Frost", "_id.uid": 0 },
9+
{ "categories": ["poet", "playwright"] },
10+
{ upsert: true } )
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
When you execute an :method:`~db.collection.update()` with the ``upsert``
2-
option, you can no longer use :ref:`document-dot-notation` to select only on
3-
part of the ``_id`` field. For example, the following will raise an error:
1+
When you execute an :method:`~db.collection.update()` with ``upsert: true`` and
2+
the query matches no existing document, MongoDB will refuse to insert a new
3+
document if the query specifies conditions on the ``_id`` field using
4+
:ref:`dot notation <document-dot-notation>`.
45

5-
.. code-block:: javascript
6+
This restriction ensures that the order of fields embedded in the ``_id``
7+
document is well-defined and not bound to the order specified in the query
68

7-
db.collection.update( { "_id.authorID": 1 },
8-
{ "name": "Robert Frost" },
9-
{ upsert: true } )
9+
If you attempt to insert a document in this way, MongoDB will raise an error.

source/reference/method/db.collection.update.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@ The remaining operations would either:
177177
applications may retry the operation which will succeed as an update
178178
operation.
179179

180+
.. _mongodb30-upsert-id:
181+
182+
``upsert:true`` with a Dotted ``_id`` Query
183+
```````````````````````````````````````````
184+
185+
.. include:: /includes/fact-mongodb30-upsert-id.rst
186+
187+
.. include:: /includes/fact-mongodb30-upsert-id-example.rst
188+
189+
180190
.. _multi-parameter:
181191

182192
Multi Parameter

source/release-notes/3.0-compatibility.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ General Compatibility Changes
458458

459459
.. include:: /includes/fact-mongodb30-upsert-id.rst
460460

461+
.. include:: /includes/fact-mongodb30-upsert-id-example.rst
462+
461463
Deprecate Access to ``system.indexes`` and ``system.namespaces``
462464
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
463465

0 commit comments

Comments
 (0)