Meteor 客户端上的Collection2 autoValue:访问被拒绝
在服务器上定义autoValue时,它可以正常工作:Meteor 客户端上的Collection2 autoValue:访问被拒绝,meteor,schema,Meteor,Schema,在服务器上定义autoValue时,它可以正常工作: slug: { type: String, index: true, unique: true, autoValue: function () { var title = this.field("title"); if (Meteor.isServer && title.isSet) return Helpers.slugify(titl
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);
}
}
每当我更新文档标题时,访问被拒绝
但是,对于更新的_at字段,它同时适用于服务器和客户端:
updated_at: {
type: Date,
autoValue: function() {
return new Date();
}
}
你知道为什么我不能在客户端自动计算slug的值吗?结果是我在更新时遇到了一个.deny。拆下它就可以修复它了