Javascript 如何让SimpleSchema更新当前的Meteor.user?
我正在使用帐户用户界面和自动表单包。当用户登录时,会有一个表单来完成基本用户配置文件 我从SimpleSchema那里得到了这个:Javascript 如何让SimpleSchema更新当前的Meteor.user?,javascript,meteor,Javascript,Meteor,我正在使用帐户用户界面和自动表单包。当用户登录时,会有一个表单来完成基本用户配置文件 我从SimpleSchema那里得到了这个: SimpleSchema invalid keys for "signupForm" context: [Object { name="_id", type="required", value=null}, Object { name="email", type="required", value=null}, Object { name="createdAt",
SimpleSchema invalid keys for "signupForm" context: [Object { name="_id", type="required", value=null}, Object { name="email", type="required", value=null}, Object { name="createdAt", type="required", value=null}]
_id应该是Meteor.userId(),并且电子邮件应该已经在用户对象中可用,createdAt不会出现在表单的任何地方
如何告诉SimpleSchema _id应该是Meteor.userId(),电子邮件应该是Meteor.user中已经存储的值,createdAt值应该是服务器上的当前时间
这是我的模式:
Schema.UserProfile = new SimpleSchema({
firstName: {
type: String,
regEx: /^[a-zA-Z-]{2,25}$/
},
lastName: {
type: String,
regEx: /^[a-zA-Z]{2,25}$/
},
gender: {
type: String,
allowedValues: ['Male', 'Female']
},
bio: {
type: String,
},
avatar: {
type: String,
},
pinCode: {
type: Number,
min: 7,
max: 7
},
phoneNumber: {
type: Number,
min: 9,
max: 10
}
});
Schema.User = new SimpleSchema({
_id: {
type: String,
regEx: SimpleSchema.RegEx.Id
},
email: {
type: String,
regEx: SimpleSchema.RegEx.Email
},
createdAt: {
type: Date
},
profile: {
type: Schema.UserProfile,
},
services: {
type: Object,
optional: true,
blackbox: false
}
});
SimpleSchema.debug = true;
Meteor.users.attachSchema(Schema.User);
以下是相关的帮助人员:
Template.signupForm.helpers({
users: function () {
return Meteor.users;
},
userSchema: function () {
return Schema.User;
}
});
Template.signupForm.editingDoc = function () {
return Meteor.users.findOne({_id: Meteor.userId()});
};
我的模板:
<template name="signupForm">
<div class="panel-body">
{{#autoForm collection=users schema=userSchema id="signupForm" type="insert"}}
<fieldset>
{{> afObjectField name='profile'}}
</fieldset>
<button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}
</div>
</template>
{{{#autoForm collection=users schema=userSchema id=“signupForm”type=“insert”}
{{>a对象字段名='profile'}
插入
{{/autoForm}
我在SimpleSchema文档中没有看到任何解释这一点的内容
谢谢:)您的要求已在collection2文档中解释,如下所示:
在collection2文档中解释了您的要求,如下所示:
在collection2文档中解释了您的要求,如下所示:
在collection2文档中解释了您的要求,如下所示: