唯一的如果不是空猫鼬模式

时间:2021-06-16 06:41:02

标签: javascript mongodb mongoose

我有一个包含 2 种类型类别的模式,这不是必需的,我想创建 2 个 expCat,但由于第一个 colCat 变为空,因此它使我出错,因此第二个也变为空,这使我出错,因为它是唯一的.

const categoryModel = mongoose.Schema({
  colCat: { type: String, unique: true, sparse: true, index: true },
  expCat: { type: String, unique: true, sparse: true, index: true },
});

0 个答案:

没有答案
相关问题