Skip to content

DOCS-557 add ref to cloneCollectionAsCapped in convertToCapped #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions source/reference/command/cloneCollectionAsCapped.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
=======================
cloneCollectionAsCapped
=======================

.. default-domain:: mongodb

.. dbcommand:: cloneCollectionAsCapped

The :dbcommand:`cloneCollectionAsCapped` command creates a new
:term:`capped collection` from an existing, non-capped collection
within the same database. The original non-capped collection
remains after the operation.

The command has the following syntax:

.. code-block:: javascript

{ cloneCollectionAsCapped: <existing collection>, toCollection: <capped collection>, size: <capped size> }

The command copies an ``existing collection`` and creates a new
``capped collection`` with a maximum size specified by the ``capped
size`` in bytes. The name of the new capped collection must be
distinct and cannot be the same as that of the original existing
collection. To replace the original non-capped collection with a
capped collection, use the :dbcommand:`convertToCapped` command.

During the cloning, the :dbcommand:`cloneCollectionAsCapped` command
exhibit the following behavior:

- The documents in the original collection will be traversed in
:term:`$natural order <natural order>` and loaded into a new
capped collection.

- If the ``capped size`` specified for the capped collection is
smaller than the size of the original uncapped collection, then
the documents will be aged out of the collection based on
insertion order(First In, First Out).

11 changes: 10 additions & 1 deletion source/reference/command/convertToCapped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ convertToCapped
.. dbcommand:: convertToCapped

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

The command has the following syntax:

Expand All @@ -30,6 +31,14 @@ convertToCapped
smaller than the size of the original uncapped collection, then
the documents will be aged out of the collection based on
insertion order(First In, First Out).

- The actual conversion process consists of the
:dbcommand:`cloneCollectionAsCapped` command followed by a
:dbcommand:`renameCollection` command. First, the
:dbcommand:`cloneCollectionAsCapped` command creates the capped
collection. Then, the original collection is dropped. Finally, the
:dbcommand:`renameCollection` command renames the new capped
collection to the name of the original collection.

.. note::

Expand Down