/
cloneCollectionAsCapped.txt
45 lines (32 loc) · 1.25 KB
/
cloneCollectionAsCapped.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
=======================
cloneCollectionAsCapped
=======================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. dbcommand:: cloneCollectionAsCapped
The :dbcommand:`cloneCollectionAsCapped` command creates a new
:term:`capped collection` from an existing, non-capped collection
within the same database. The operation does not affect the
original non-capped collection.
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.
Behavior
--------
If the ``capped size`` is less than the size of the source collection,
then not all documents in the source collection will exist in the destination
capped collection.