当在服务器上定义autoValue时,它工作得很好:
slug: {
type: String,
index: true,
unique: true,
autoValue: function () {
var title = this.field("title");
if (Meteor.isServer && title.isSet)
return Helpers.slugify(title.value);
}
}
但是,如果我想在客户端也定义autoValue,像这样:
slug: {
type: String,
index: true,
unique: true,
autoValue: function () {
var title = this.field("title");
if (title.isSet)
return Helpers.slugify(title.value);
}
}
每当我更新文档标题时,就会出现Access Denied
但是对于updated_at
字段,它同时适用于服务器和客户端:
updated_at: {
type: Date,
autoValue: function() {
return new Date();
}
}
知道为什么我不能在客户端上autoValue
鼻涕虫吗?
原来我刚刚更新了一个.deny()
。把它去掉就可以了