Meteor.user() 仅 returns _id 和用户名

Meteor.user() only returns _id and username

使用 accounts-passwordaccounts-ui 模块创建用户后,当我在控制台中调用 Meteor.user() 时,我没有得到完整的配置文件,只有 _idusername,尽管文档中还有更多内容,例如 createdAt 记录。

如果我使用这些模板会出现同样的问题:

<template name="user_list">
    <div class="user-list">
    <h1>Users</h1>
        <ul>
        {{#each allUsers}}
            {{> user_item}}
        {{/each}}
        </ul>
    </div>
</template>

<template name="user_item">
    <li class="user-item">
        <p><b>{{username}}</b></p>
        <p>Created: {{createdAt}}</p>
    </li>
</template>

... 由这个助手支持:

Template.user_list.helpers({
  allUsers: function () {
    return Meteor.users.find({});
  }
});

在这种情况下,user_list 模板可以很好地遍历用户,并显示用户名,但是 createdAt 助手失败,即使我遍历 meteor mongo 记录是肯定有。我没有删除自动发布;我的设置仍然完全打开。为什么我不能访问其余的用户记录?

默认情况下,accounts 包只发布 id、username 和 profile 字段。要发布更多内容,请将此 'universal' 发布添加到服务器:

Meteor.publish(null, function() {

  if (this.userId != null) {
    return Meteor.users.find({
      _id: this.userId
    }, {
      fields: {
        'createdAt': 1,
      }
    });
  } else {
    return this.ready();
  }
});

注意:returns this.ready() 即使没有用户确保与 Spiderable 包的兼容性。