2

I am trying to understand when indexes are made in mongodb. I have just learnt that The unique Option is Not a Validator. But I have been using it as a validator in my mongoose schemas for a while now and it has been working.

The problem that I have now is that when I add the unique index to a mongoose schema property the indexes are not created. I understand that indexes are created on MongoDB and the other mongoose validations are done by mongoose on the app level.

So my question is when are indexes created in MongoDB by mongoose? I have tried restarting my node server but the new unique indexes did not work. Are they only created once?

YulePale
  • 6,688
  • 16
  • 46
  • 95

0 Answers0