Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you create a capped collection using mongoose?

I'm trying to create a capped collection using Mongoose, however the following creates a collection that is not capped:

var schema = new mongoose.Schema(
{
    Name: { type: String },
    Text: { type: String }
},
{
    capped: { max: 5, size: 1000000 }
});

I'm pretty sure I'm following the documentation's example properly, but clearly I'm doing something wrong.

like image 972
Mike Pateras Avatar asked Oct 18 '12 05:10

Mike Pateras


1 Answers

new Schema({..}, { capped: { size: 1024, max: 1000, autoIndexId: true } });
like image 97
Javier Gomez Avatar answered Nov 04 '22 17:11

Javier Gomez