You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
userSchema=mongoose.Schema({role: {type: String,enum: ['Admin','Owner','User']},username: {type: String,unique: true,required: true,validate: [validation.usernameValidator,'not a valid username']},passwordHash: {type: String,required: true,validate: [validation.passwordValidator,'not a valid password']},email: {type: String,unique: true,required: true,validate: [validation.emailValidator,'not a valid email address']}},{autoIndex:false});varUserModel=null;varget=function(cb){if(UserModel===null){UserModel=mongoDB.model('users',userSchema);UserModel.ensureIndexes(function(err){if(err){console.log(colors.bgRed(err));}cb(err,UserModel);});}else{cb(null,UserModel);}};
two requests from me to you:
(1) can you clarify in the docs what the benefits of setting autoIndex to false?
(2) can you clarify in the docs if ensureIndexes fires once for each index or once for all indexes?
thanks!
The text was updated successfully, but these errors were encountered:
Sometimes you'd prefer to manage indexes in production via the shell or some other tool. Mongoose is not designed to be a tool for managing mongodb indexes and ensureIndex is a primitive mechanism.
Mongoose calls ensureIndex() once for each index sequentially, and then emits an 'index' event on the model when either the index build succeeds or when one of the ensureIndex() calls fails.
vkarpov15
added
the
docs
This issue is due to a mistake or omission in the mongoosejs.com documentation
label
Jul 11, 2015
I have this code in my app:
two requests from me to you:
(1) can you clarify in the docs what the benefits of setting autoIndex to false?
(2) can you clarify in the docs if ensureIndexes fires once for each index or once for all indexes?
thanks!
The text was updated successfully, but these errors were encountered: