javascript - 如果不为空,则为唯一的猫鼬模式
问题描述
我有一个包含 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 },
});
解决方案
推荐阅读
- centos7 - 如何卸载 ArangoDB
- azure - 如何控制 Azure Event Grid 触发器的并发性
- javascript - 带有 JavaScript 变量的 SVG 旋转问题
- spring - Spring Boot Admin Console 2.0.4 如何使墙板不安全?
- java - java.lang.ClassCastException:无法强制转换 MainActivity?
- ios - 具有固定宽度视图的 ScrollView 宽度约束
- r - 当我对数据进行子集化时,为什么 ggplot 会忽略我的因子水平?
- angular - 带有nativescript的角度数据表在哪里
- firebase - 未找到 HTTPS 功能。使用firebase函数:shell
- javascript - 我的带有对象和方法的 JavaScript 代码不起作用