Skip to content

Commit 6267fa7

Browse files
DOCS-16308 findAndModify and deleteOne partial shard key updates (#4798)
* DOCS-16308 partial shard key * DOCS-16308 partial shard key * DOCS-16308 update delete one * DOCS-16308 fix method label * DOCS-16308 updates to italicized letters
1 parent f847af8 commit 6267fa7

File tree

5 files changed

+30
-17
lines changed

5 files changed

+30
-17
lines changed
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
All |single-modification-operation-names| operations for a sharded
2-
collection that specify the |single-modification-operation-option|
3-
option must include the :term:`shard key` *or* the ``_id`` field in
4-
the query specification.
1+
To use |single-modification-operation-names| operations for a sharded
2+
collection that specify the |single-modification-operation-option| option:
53

6-
|single-modification-operation-names| operations specifying
7-
|single-modification-operation-option| in a sharded collection which do
8-
not contain either the :term:`shard key` or the ``_id`` field return an
9-
error.
4+
- If you only target one shard, you can use a partial shard key in the query specification or,
105

6+
- You can provide the :term:`shard key` or the ``_id`` field in the query
7+
specification.

source/reference/command/findAndModify.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,11 @@ Upsert with Unique Index
329329
Sharded Collections
330330
~~~~~~~~~~~~~~~~~~~
331331

332-
To use :dbcommand:`findAndModify` on a sharded collection, the query
333-
filter must include an equality condition on the shard key.
332+
To use :dbcommand:`findAndModify` on a sharded collection:
333+
334+
- If you only target one shard, you can use a partial shard key in the ``query`` field or,
335+
336+
- You can provide an equality condition on a full shard key in the ``query`` field.
334337

335338
.. include:: /includes/extracts/missing-shard-key-equality-condition-findAndModify.rst
336339

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ for precise deletions.
127127
Sharded Collections
128128
~~~~~~~~~~~~~~~~~~~
129129

130-
:method:`db.collection.deleteOne()` operations on a sharded collection
131-
must include the :term:`shard key` *or* the ``_id`` field in the query
132-
specification. :method:`db.collection.deleteOne()` operations in a
133-
sharded collection which do not contain either the :term:`shard key` or
134-
the ``_id`` field return an error.
130+
To use :method:`db.collection.deleteOne` on a sharded collection:
131+
132+
- If you only target one shard, you can use a partial shard key in the query specification or,
133+
134+
- You can provide the :term:`shard key` or the ``_id`` field in the query
135+
specification.
135136

136137
Transactions
137138
~~~~~~~~~~~~

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,11 @@ Upsert with Unique Index
266266
Sharded Collections
267267
~~~~~~~~~~~~~~~~~~~
268268

269-
When using :dbcommand:`findAndModify` against a sharded collection, the
270-
``query`` **must** contain an equality condition on :term:`shard key`.
269+
To use :dbcommand:`findAndModify` on a sharded collection:
270+
271+
- If you only target one shard, you can use a partial shard key in the ``query`` field or,
272+
273+
- You can provide an equality condition on a full shard key in the ``query`` field.
271274

272275
.. include:: /includes/extracts/missing-shard-key-equality-condition-findAndModify.rst
273276

source/release-notes/7.1.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ MongoDB 7.1 adds the :parameter:`indexBuildMinAvailableDiskSpaceMB`
8585
parameter, which allows you to set the minimum available disk space
8686
required for index builds.
8787

88+
Query with Partial Shard Key
89+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
90+
91+
Starting in MongoDB 7.1, :dbcommand:`findAndModify` and :method:`~db.collection.deleteOne()`
92+
can use a partial shard key to query on a sharded collection.
93+
94+
``serverStatus`` Output Change
95+
------------------------------
96+
8897
Specify a query's index using the hint field
8998
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9099

0 commit comments

Comments
 (0)