【发布时间】:2016-09-06 14:03:26
【问题描述】:
我正在尝试使用简单的模式将一个字段设置为唯一的。但无论我做什么,它都不起作用。这是我的设置方式:
let schema = new SimpleSchema({
name: {
type: String,
label: 'Committee name',
max: 200
},
shortName: {
type: String,
label: 'Short name',
max: 10,
index: true,
sparse: true,
unique: true,
autoValue: (com) => {
if (com.shortName) {
return com.shortName.toLowerCase();
}
}
},
});
我什至尝试重置流星。如果我添加重复值,它不会添加记录,但在验证时甚至不会给出任何错误。
【问题讨论】:
-
您使用的是插入更新还是更新插入?
-
是的。添加项目我使用
insert但在此之前我使用验证方法得到错误:Collection.simpleSchema().namedContext('insertForm').validate(values)
标签: meteor meteor-collection2 simple-schema