Skip to content

Commit 33a58a3

Browse files
(DOCS-15080): Deletes allowed on capped collections (#2333)
* (DOCS-15080): deletes allowed on capped collections * more updates * remove unused include * address review feedback
1 parent b3f316b commit 33a58a3

File tree

8 files changed

+39
-58
lines changed

8 files changed

+39
-58
lines changed

source/core/capped-collections.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,6 @@ Updates
9999
If you plan to update documents in a capped collection, create an index
100100
so that these update operations do not require a collection scan.
101101

102-
Document Deletion
103-
~~~~~~~~~~~~~~~~~
104-
105-
You cannot delete documents from a capped collection. To remove all
106-
documents from a collection, use the :method:`~db.collection.drop()`
107-
method to drop the collection and recreate the capped collection.
108-
109102
Sharding
110103
~~~~~~~~
111104

source/core/index-ttl.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,8 @@ Restrictions
174174

175175
- The ``_id`` field does not support TTL indexes.
176176

177-
- You cannot create a TTL index on a :doc:`capped collection
178-
</core/capped-collections>` because MongoDB cannot remove documents
179-
from a capped collection.
177+
- You cannot create a TTL index on a :ref:`capped collection
178+
<manual-capped-collection>`.
180179

181180
- You cannot create a TTL index on a :doc:`time series collection
182181
</core/timeseries-collections>`. Similar functionality is provided

source/includes/fact-remove-capped-collection-restriction.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

source/reference/command/delete.txt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ Definition
1717

1818
The :dbcommand:`delete` command removes documents from a collection.
1919
A single :dbcommand:`delete` command can contain multiple delete
20-
specifications. The command cannot operate on :doc:`capped
21-
collections </core/capped-collections>`. The remove methods provided
22-
by the MongoDB drivers use this command internally.
20+
specifications. The delete methods provided by the MongoDB drivers
21+
use this command internally.
2322

2423
.. versionchanged:: 5.0
2524

@@ -500,18 +499,22 @@ The following is an example document returned for a successful
500499
{ ok: 1, n: 1 }
501500

502501
The following is an example document returned for a :dbcommand:`delete`
503-
command that encountered an error:
502+
command that encountered an error because it specified a non-existent
503+
index in the ``hint`` field:
504504

505505
.. code-block:: javascript
506506

507507
{
508-
"ok" : 1,
509-
"n" : 0,
510-
"writeErrors" : [
511-
{
512-
"index" : 0,
513-
"code" : 10101,
514-
"errmsg" : "can't remove from a capped collection: test.cappedLog"
515-
}
516-
]
508+
n: 0,
509+
writeErrors: [
510+
{
511+
index: 0,
512+
code: 2,
513+
errmsg: 'error processing query: ns=test.products: hat $eq "bowler"\n' +
514+
'Sort: {}\n' +
515+
'Proj: {}\n' +
516+
' planner returned error :: caused by :: hint provided does not correspond to an existing index'
517+
}
518+
],
519+
ok: 1
517520
}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,6 @@ Definition
109109
Behavior
110110
--------
111111

112-
.. _deleteMany-capped-collection:
113-
114-
Capped Collections
115-
~~~~~~~~~~~~~~~~~~
116-
117-
:method:`db.collection.deleteMany()` throws a ``WriteError`` exception
118-
if used on a :term:`capped collection`. To remove all documents from a
119-
capped collection, use :method:`db.collection.drop()`.
120-
121112
.. _deleteMany-timeseries-collection:
122113

123114
Time Series Collections

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,6 @@ Deletion Order
122122
the filter. Use a field that is part of a :term:`unique index` such as ``_id``
123123
for precise deletions.
124124

125-
.. _deleteOne-capped-collection:
126-
127-
Capped Collections
128-
~~~~~~~~~~~~~~~~~~
129-
130-
:method:`db.collection.deleteOne()` returns a ``WriteError`` exception
131-
if used on a :term:`capped collection`.
132-
133125
.. _deleteOne-timeseries-collection:
134126

135127
Time Series Collections

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,6 @@ document sorted by a specified order, use the :ref:`findAndModify()
146146
When removing multiple documents, the remove operation may interleave
147147
with other read and/or write operations to the collection.
148148

149-
Capped Collections
150-
~~~~~~~~~~~~~~~~~~
151-
152-
.. include:: /includes/fact-remove-capped-collection-restriction.rst
153-
154149
Time Series Collections
155150
~~~~~~~~~~~~~~~~~~~~~~~
156151

@@ -360,4 +355,3 @@ concern error, the results include :data:`WriteResult.writeError` field:
360355
.. seealso::
361356

362357
:method:`WriteResult.hasWriteError()`
363-

source/release-notes/5.0.txt

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,27 @@ Starting in MongoDB 5.0:
591591
- DDL operations auditing on :term:`secondaries <secondary>` has
592592
changes. See :ref:`auditing-audit-events-and-filter`.
593593

594+
.. _5.0-rel-notes-capped-collections:
595+
596+
Capped Collections
597+
------------------
598+
599+
Capped Collection Deletes Are Replicated to Secondaries
600+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
601+
602+
Starting in MongoDB 5.0, the :ref:`implicit delete operations
603+
<capped_collections_remove_documents>` for :ref:`replica set
604+
<replication>` :term:`capped collections <capped collection>` are
605+
processed by the primary and replicated to the :ref:`secondary members
606+
<replica-set-secondary-members-ref>`.
607+
608+
Explicit Deletes Allowed on Capped Collections
609+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
610+
611+
Starting in MongoDB 5.0.7, you can delete documents from :ref:`capped
612+
collections <manual-capped-collection>` using :ref:`delete methods
613+
<delete-additional-methods>`.
614+
594615
.. _5.0-rel-notes-change-streams:
595616

596617
Change Streams
@@ -989,16 +1010,6 @@ with this naming change.
9891010
General Improvements
9901011
--------------------
9911012

992-
Capped Collection Deletes Are Replicated to Secondaries
993-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
994-
995-
Starting in MongoDB 5.0, the
996-
:ref:`implicit delete operations <capped_collections_remove_documents>`
997-
for :doc:`replica set </replication>`
998-
:term:`capped collections <capped collection>` are processed by
999-
the primary and replicated to the
1000-
:doc:`secondary members </core/replica-set-secondary/>`.
1001-
10021013
Execution Plan Statistics for Query with ``$lookup`` Pipeline Stage
10031014
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10041015

0 commit comments

Comments
 (0)