node.js - MongoDB重复值错误,即使我不希望它是唯一的
问题描述
MongoError: E11000 duplicate key error collection: MyNotebookDB.notes index: title_1 dup key: { title: "Data Structures" }
这是我模型中的标题。
title: {
type: String,
required: true
},
当我第一次创建我的模型时,我确实设置了标题:{unique: true},但后来我不需要标题是唯一的,所以我删除了它。我什至没有对此模型/输入进行验证。但它仍然不接受重复值并显示此错误。
解决方案
我认为您需要手动删除要求标题唯一的索引
推荐阅读
- html - 试图从 POST 请求中检索数据
- android - 进程 'command 'git'' 以非零退出值 128 结束
- java - IntelliJ IDEA - 在 Oracle JDK 下启用连字
- c# - 将应用程序提交到 Google Play 会导致 API 级别错误
- c# - 在富文本框中显示串行端口数据期间“无法访问已处理的对象”
- asp.net-mvc - 使用 InProc 缓存数据存储页面持久性的元数据(不带膨胀服务器)
- big-o - 扫描有界长度字符串的复杂性。O(n) 还是 O(1)?
- javascript - MAP vs REDUCE 我应该选择哪个?
- azure - 将根域指向 Azure Function
- xamarin - Xamarin Visual Studio for MAC. Automatic Provisioning failed: An App ID with Identifier '*' is not available