Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在Meteor.user文档中添加顶级字段_Javascript_Meteor Accounts_Customizing - Fatal编程技术网

Javascript 在Meteor.user文档中添加顶级字段

Javascript 在Meteor.user文档中添加顶级字段,javascript,meteor-accounts,customizing,Javascript,Meteor Accounts,Customizing,我是一名流星新手,我正在按照流星指南的链接向meteor.user文档添加更多字段 Template.CustomDataForm.events({ "click [data-action='Customer/insert']": function (event) { event.preventDefault(); var name = $('[name=name]').val(); var email =

我是一名流星新手,我正在按照流星指南的链接向meteor.user文档添加更多字段

 Template.CustomDataForm.events({
        "click [data-action='Customer/insert']": function (event) {
            event.preventDefault();
            var name = $('[name=name]').val();
            var email = $('[name=email]').val();
            var phone = $('[name=phone]').val();
            var address = $('[name=address]').val();
            const personalInfo = {
                Name: name,
                Email: email,
                Phone: phone,
                Address: address,
            };
           // I want to add personalInfo as a top-level field onto the user document
            Meteor.call('updateInfo',personalInfo);
         }
    });
现在在服务器端编写了一个方法,用这个传递的信息执行Meteor.user.update

 Meteor.methods({
           'updateInfo': function (newpersonalInfo) {
            console.log("Updating Info ..."+newpersonalInfo.Name+"  "+newpersonalInfo.Address+" "+Meteor.userId()) ;

            const proInfo = {
                Name: newpersonalInfo.Name,
                Email: newpersonalInfo.Email,
                Phone: newpersonalInfo.Phone,
                Address: newpersonalInfo.Address,
            };
            console.log("Updating for user "+Meteor.userId());
            Meteor.users.update(Meteor.userId(), {
                $set: {
                     personaInfo: proInfo
                }
            });
            console.log("After Updating"+Meteor.user());
        }
    });
这是自定义数据的发布

Meteor.publish('Meteor.users.personalInfo', function ({ userIds }) {
  // Validate the arguments to be what we expect
  new SimpleSchema({
    userIds: { type: [String] }
  }).validate({ userIds });

  // Select only the users that match the array of IDs passed in
  const selector = {
    _id: { $in: userIds }
  };

  // Only return one field, `personalInfo`
  const options = {
    fields: { personalInfo: 1 }
  };

  return Meteor.users.find(selector, options);
});
这是订阅费

Template.profile.rendered = function () {
    Meteor.subscribe('Meteor.users.personalInfo',Meteor.userId());
    if (Meteor.user() && Meteor.user().personalInfo) {
        name = Meteor.user().profileInfo.Name;
        $('[id=profile-name]').val(name);
    }
}
但是在Javascript控制台上

Meteor.user()的输出;在Javascript控制台上,我希望personalInfo作为顶级字段,但没有

在服务器端,日志是

I20160528-11:04:27.725(5.5)?更新[对象]后

我好像找不到这里坏了什么

谢谢你阅读我的问题


更新:添加用于复制此问题

您好,我添加了github repo[link]()repo,它基本上遵循meteor指南添加自定义数据,但meteor.user文档中似乎没有更新自定义数据