Jac*_*eid 1 meteor meteor-accounts
使用accounts-password和accounts-ui模块创建用户后,当我Meteor.user()在控制台中调用时,我没有获得完整的配置文件,只有_id和username,即使文档上有更多内容,如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>
Run Code Online (Sandbox Code Playgroud)
......由这个助手支持:
Template.user_list.helpers({
allUsers: function () {
return Meteor.users.find({});
}
});
Run Code Online (Sandbox Code Playgroud)
在这种情况下,user_list模板很好地迭代用户,并显示用户名,但createdAt帮助程序失败,即使我通过meteor mongo记录确实存在.我没有删除自动发布; 我的设置仍然完全打开.为什么我无法访问其余的用户记录?
默认情况下,accounts包仅发布id,username和profile字段.要发布更多内容,请将此"通用"发布添加到服务器:
Meteor.publish(null, function() {
if (this.userId != null) {
return Meteor.users.find({
_id: this.userId
}, {
fields: {
'createdAt': 1,
}
});
} else {
return this.ready();
}
});
Run Code Online (Sandbox Code Playgroud)
注意:this.ready()即使没有用户确保与Spiderable包的兼容性,它也会返回.
| 归档时间: |
|
| 查看次数: |
1600 次 |
| 最近记录: |