我有一个这样的模型用户:
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 })
如何在评论中允许重复用户,因为当我创建评论模型时不能创建相同的用户两次,我该怎么做?