- Reference >
- Database Commands >
- Administration Commands >
- cloneCollectionAsCapped
cloneCollectionAsCapped¶
-
cloneCollectionAsCapped¶ The
cloneCollectionAsCappedcommand 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:
The command copies an
existing collectionand creates a newcapped collectionwith a maximum size specified by thecapped sizein 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 theconvertToCappedcommand.During the cloning, the
cloneCollectionAsCappedcommand exhibit the following behavior:- MongoDB will transverse the documents in the original collection in natural order as they’re loaded.
- If the
capped sizespecified for the new collection is smaller than the size of the original uncapped collection, then MongoDB will begin overwriting earlier documents in insertion order, which is first in, first out (e.g “FIFO”).