Clint H.
unread,Aug 18, 2011, 4:46:21 PM8/18/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Mongoose Node.JS ORM
I can't get Mongoose to create a unique index for my model, which
looks like this:
var UserSchema = new mongoose.Schema({
my_id: {
type: String,
index: { unique: true },
required: true
},
name: { type: String }
});
var UserModel = mongoose.model('users', UserSchema);
New documents are inserted just fine, but the index/unique-constraint
is never created; I can insert duplicates and don't see the index when
I run db.users.getIndexes().
Dropping the database and restarting mongod doesn't seem to help.
Lastly, I have verified that if I manually run ensureIndex via shell,
the unique constraint works. I'd like to have Mongoose do it for me,
though.
Any help would be appreciated. Thanks.
[OSX 10.6, Node 0.5.1, MongoDB 1.8.2, Mongoose 1.8.2, mongodb 0.9.6-7]