I’m trying to create a capped collection in mongoose (@2.7.1, mongo v2.0.6) via node.js.
I’ve copied the basic code from the mongoose documentation to create a test case:
var schema = new Schema({'test':String},{capped:1024});
var model = api.db.model('testcapped',schema);
var data = new model({'test': 'value'});
data.save();
This executes without errors.
However, when I subsequently use a mongo shell…
> db.testcappeds.isCapped();
false
On the other hand, if I do this in node.js, it works:
model.db.db.executeDbCommand({'convertToCapped': 'testcappeds', size: 1024}, function(e,d){});
In other words, bypassing mongoose directly calling the “convertToCapped” command is successfully working, but mongoose is not correctly capping the collection.
Am I missing something? Should I just manually cap the collection with the working code, or will this add performance overhead?
These slides indicate that Mongoose 2.7.1 does not yet support capped collections. I would recommend either dropping down into the native driver to make the collection capped, or upgrade to the newest Mongoose.