- 92
- 0
const CommentsSchema = new Schema({
userId: { type: Schema.Types.ObjectId, ref: 'User', require: true },
articleId: { type: Schema.Types.ObjectId, ref: 'Article', require: true },
content: { type: String, require: true },
created_at: { type: Date, default: Date.now },
thumbsUp: [{ type: Schema.Types.ObjectId, ref: 'User' }],
thumbsDown: [{ type: Schema.Types.ObjectId, ref: 'User' }]
})
commentModel = {
userId: ctx.session.user._id || ctx.request.body.userId,
articleId: articleId,
content: content
};
Comments.create(commentModel)
第二次插入数据的时候报错
name: 'MongoError',
message: 'E11000 duplicate key error collection: myblog.comments index: thumbsUp_1 dup key: { : undefined }',
driver: true,
code: 11000,
index: 0,
errmsg: 'E11000 duplicate key error collection: myblog.comments index: thumbsUp_1 dup key: { : undefined }',
getOperation: [Function],
toJSON: [Function],
toString: [Function] }
请问该如何解决
- 共 0 条
- 全部回答
-
吃我一记▽可爱杀、@ 普通会员 1楼
The "E11000 duplicate key error collection" error occurs when a database table has duplicate keys, and the database server is unable to insert or update a record with the same key. This error is usually caused by a database transaction that tries to insert a record with a duplicate key, but the server is unable to handle the transaction because it has a duplicate key. To resolve this error, you should check the database schema to make sure that there are no duplicate keys in the table. You should also check the database transaction log to see if the transaction was able to proceed to the next step, or if it was rolled back because of the duplicate key error. If the error persists, you may need to consult with a database administrator or a database expert to determine the cause of the error and find a solution.
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部
