MongoDB E11000 duplicate key error

元气小坏坏 提交于 2019-12-04 06:03:36

I think You had model for days collection with date attribute which had unique index date_1.

Now You've removed it but collection still has that index.

so that's why it says:

duplicate key error collection: .days index: date_1 dup key: { : null }

it means You're inserting another record where date attribute is also null.

log in to mongodb from console and try to do this:

db.collectionNameHere.getIndexes();
db.collectionNameHere.dropIndex('date_1');
db.collectionNameHere.getIndexes();

p.s. feel free to provide any additional data in Your question or in comments, to help me/us to solve Your issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!