Meteor 如何将post字段与用户电子邮件关联?[流星]
我有一个帖子模型,我已经发表,工作良好。但是,我通过simpleSchemas插件添加了以下字段:Meteor 如何将post字段与用户电子邮件关联?[流星],meteor,meteor-accounts,meteor-autoform,Meteor,Meteor Accounts,Meteor Autoform,我有一个帖子模型,我已经发表,工作良好。但是,我通过simpleSchemas插件添加了以下字段: userEmail: { type: String, autoValue: function() { if (this.isInsert) { return Meteor.user().email; } else if (this.isUpsert) { return {$setOnInsert: Meteor.user().email};
userEmail: {
type: String,
autoValue: function() {
if (this.isInsert) {
return Meteor.user().email;
} else if (this.isUpsert) {
return {$setOnInsert: Meteor.user().email};
} else {
this.unset();
}
}
}
启用此选项后,提交表单不起作用,但不会引发任何错误。我是否打错了Meteor.user.email?如何将userEmail字段与创建帖子的用户的电子邮件相关联 默认Meteor.users集合将电子邮件存储在一个数组中,以支持多封电子邮件。类似return Meteor.user.emails[0]的内容。地址应该有效。正确的语法是
Meteor.user().emails[0].address
您好@Curtis正确的语法是Meteor.user.email[0]。地址不是Meteor.user.email[0]您缺少电子邮件和.address