node.js UnhandledPromiseRejectionWarning报错原因解决

UnhandledPromiseRejectionWarning: MongoError: E11000 duplicate key error collection: blog.users index: email_1 dup key: { email: “[email protected]” } 报错
在这里插入图片描述
因为邮箱我设置的是不能与数据库里面的邮箱号重复,所以往数据库中插入一个相同邮箱号的数据时,会出现上述错误!

在这里插入图片描述
解决方案:更改邮箱号后再插入,或者删除数据库里面的数据,或者去掉unique。

猜你喜欢

转载自blog.csdn.net/qq_41329287/article/details/114984567