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] }
请问该如何解决