具有附加条件的猫鼬模式唯一字段

时间:2019-03-22 04:27:10

标签: mongoose

请帮助我如何在我的情况下定义猫鼬模式。

const schema = new mongoose.Schema({
 name: { type: String, required: true, unique:true },
 deleted: { type: Number, default: 0 },
});

仅当“已删除” = 0时,我才需要具有唯一的“名称”。如果“已删除” = 1,则我的“名称”可能不是唯一的。

0 个答案:

没有答案
相关问题