如何允许子文档猫鼬中的重复字段?

时间:2020-12-24 14:31:34

标签: node.js

我有一个这样的模型用户:

const userSchema = mongoose.Schema({
     name: { type: String, required: true},
     email: { type: String, required: true, unique: true },
     password: { type: String, requried: true }, }); And a subdocument called: Comments like this: const commentSchema = mongoose.Schema({
     comment: { type: String },
     user: [UserSchema]
     doctor: { type: mongoose.Schema.Types.ObjectId, ref: 'Doctor', required: true }, }, {
     timestamps: true })

如何在评论中允许重复用户,因为当我创建评论模型时不能创建相同的用户两次,我该怎么做?

0 个答案:

没有答案
相关问题