I\'m trying to create a capped collection using Mongoose, however the following creates a collection that is not capped:
new Schema({..}, { capped: { size: 1024, max: 1000, autoIndexId: true } });
size
is the maximum bytes in memory till which your database is not capped or till which your older records are not removed. max
defines the number of maximum records which database will hold before capping.
You must define size component irrespective of max component. Because if your size is used before reaching max then too capping will start but vice versa is not true.
new Schema({..}, { capped: { size: 1024, max: 1000, autoIndexId: true } });
If non-capped collection already exist then you need to convert it to capped collection using following command.
db.runCommand({"convertToCapped": "collection_name", size: 100000});
Then you can able to use it with mongoose.