- Reference >
- Database Commands >
- Administration Commands >
- cloneCollectionAsCapped
cloneCollectionAsCapped¶
On this page
Definition¶
- cloneCollectionAsCapped¶
The cloneCollectionAsCapped command creates a new 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:
{ 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 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.
Thank you for your feedback!
We're sorry! You can Report a Problem to help us improve this page.