首页 > 解决方案 > MongoDB重复值错误,即使我不希望它是唯一的

问题描述

MongoError: E11000 duplicate key error collection: MyNotebookDB.notes index: title_1 dup key: { title: "Data Structures" }

这是我模型中的标题。

title: {
        type: String,
        required: true
    },

当我第一次创建我的模型时,我确实设置了标题:{unique: true},但后来我不需要标题是唯一的,所以我删除了它。我什至没有对此模型/输入进行验证。但它仍然不接受重复值并显示此错误。

标签: node.jsdatabasemongodbduplicates

解决方案


我认为您需要手动删除要求标题唯一的索引


推荐阅读