我有一个包含 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 },
});