MongooseJS cant disable unique to field

前端 未结 3 1610
小蘑菇
小蘑菇 2020-12-10 07:02

This is my mongoosejs schema. I set name unique to false, but this is what i get: MongoError: insertDocument :: caused by :: 11000 E11000 duplicate key error index:

相关标签:
3条回答
  • 2020-12-10 07:33

    Go to the DB(MongoDB)--> Collections --> Your_Table --> Indexes --> Right Click on the Unique Field --> Exit Index --> Uncheck the Unique field --> Save

    0 讨论(0)
  • 2020-12-10 07:42

    MongoDB Compass

    If you are using MongoDB Compass then you can choose your document and then click on Indexes and delete the index which you want to delete.

    0 讨论(0)
  • 2020-12-10 07:46

    Mongoose won't modify existing indexes, so you'll need to drop that index in the MongoDB shell and then let Mongoose recreate it using the definition in your schema:

    > db.images.dropIndex('name_1');
    
    0 讨论(0)
提交回复
热议问题