Skip to content

Commit eda1aca

Browse files
committed
DOCS-557 add ref to cloneCollectionAsCapped in convertToCapped
1 parent 34bcbc6 commit eda1aca

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
=======================
2+
cloneCollectionAsCapped
3+
=======================
4+
5+
.. default-domain:: mongodb
6+
7+
.. dbcommand:: cloneCollectionAsCapped
8+
9+
The :dbcommand:`cloneCollectionAsCapped` command creates a new
10+
:term:`capped collection` from an existing, non-capped collection
11+
within the same database. The original non-capped collection
12+
remains after the operation.
13+
14+
The command has the following syntax:
15+
16+
.. code-block:: javascript
17+
18+
{ cloneCollectionAsCapped: <existing collection>, toCollection: <capped collection>, size: <capped size> }
19+
20+
The command copies an ``existing collection`` and creates a new
21+
``capped collection`` with a maximum size specified by the ``capped
22+
size`` in bytes. The name of the new capped collection must be
23+
distinct and cannot be the same as that of the original existing
24+
collection. To replace the original non-capped collection with a
25+
capped collection, use the :dbcommand:`convertToCapped` command.
26+
27+
During the cloning, the :dbcommand:`cloneCollectionAsCapped` command
28+
exhibit the following behavior:
29+
30+
- The documents in the original collection will be traversed in
31+
:term:`$natural order <natural order>` and loaded into a new
32+
capped collection.
33+
34+
- If the ``capped size`` specified for the capped collection is
35+
smaller than the size of the original uncapped collection, then
36+
the documents will be aged out of the collection based on
37+
insertion order(First In, First Out).
38+

source/reference/command/convertToCapped.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ convertToCapped
77
.. dbcommand:: convertToCapped
88

99
The :dbcommand:`convertToCapped` command converts an existing,
10-
non-capped collection to a :term:`capped collection`.
10+
non-capped collection to a :term:`capped collection` within the same
11+
database.
1112

1213
The command has the following syntax:
1314

@@ -30,6 +31,14 @@ convertToCapped
3031
smaller than the size of the original uncapped collection, then
3132
the documents will be aged out of the collection based on
3233
insertion order(First In, First Out).
34+
35+
- The actual conversion process consists of the
36+
:dbcommand:`cloneCollectionAsCapped` command followed by a
37+
:dbcommand:`renameCollection` command. First, the
38+
:dbcommand:`cloneCollectionAsCapped` command creates the capped
39+
collection. Then, the original collection is dropped. Finally, the
40+
:dbcommand:`renameCollection` command renames the new capped
41+
collection to the name of the original collection.
3342

3443
.. note::
3544

0 commit comments

Comments
 (0)