So I was creating a user model and set the email field to unique:true
and everything seems to be fine, but when I decided that "Meh, I want the email to be NOT unique", so remove the the unique:true
option, and guess what? ... Yes you guessed it return duplicate error, so I added the unique:false
and set it to false
and the error still persisted. With a little research on stackoverflow I came across with this answer. Well the answer solved the problem but It's such a bummer to drop the index manually. Wouldn't it be nice if mongoose just drops the index automatically when the option is set to unique:false
? #midnightthoughts lol
Good suggestion, will keep it open for a future release, but not a high priority because index management is not really mongoose's strong suit
+1
This is would be nice to have
@CruiseMan Am still waiting for this to be implemented. 馃槅
@jofftiquez you can just use syncIndexes() https://mongoosejs.com/docs/api.html#model_Model.syncIndexes
@vkarpov15 thanks for the update!
Most helpful comment
Good suggestion, will keep it open for a future release, but not a high priority because index management is not really mongoose's strong suit