在MongoDB中,如何限制3个字段RegisterUserId,PageId和IsFavourite的数据输入。它们都不是唯一的吗? 该查询应该是什么?
以下是我的架构
var FavMasterSchema = new Schema({
FavUrl:String,
RegisterUserId : { type: Schema.Types.ObjectId, ref: 'User',select: false},
PageId: { type: Schema.Types.ObjectId},
IsFavourite: {type: Boolean,default:false}
});
module.exports = mongoose.model('t_FavMaster', FavMasterSchema);
答案 0 :(得分:0)
试试这个:
var FavMasterSchema = new Schema({
FavUrl:String,
RegisterUserId : { type: Schema.Types.ObjectId, ref: 'User',select: false},
PageId: { type: Schema.Types.ObjectId},
IsFavourite: {type: Boolean,default:false}
});