I have an existing collection that I need to convert into a Capped Collection using the method listed:
> db.runCommand({"convertToCapped": "mycoll", size: 100000});
However, the max field is not accepted as a parameter
> db.mycol1.convertToCapped
function (bytes) {
if (!bytes) {
throw "have to specify # of bytes";
}
return this._dbCommand({convertToCapped: this._shortName, size: bytes});
}
Any idea how to set this?
max is only an option in the createCollection method, not convertToCapped:
db.createCollection("mycoll", {capped:true, size:100000, max:100});
There's a cloneCollectionAsCapped, but it doesn't look like there's a max doc option there either: http://docs.mongodb.org/manual/reference/command/cloneCollectionAsCapped/
You may need to create a new capped collection with the max parameter and transfer data and indices from the existing collection. See http://learnmongo.com/posts/easily-move-documents-between-collections-or-databases/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With