users为方便起见,我在集合中定义了一些有用的字段.允许客户访问相应字段的正确方法是什么?我正在使用该autopublish包,但是Meteor.user()从客户端只显示该emails数组.
在查询用户集合时,您必须明确告诉Meteor用户要包含哪些字段.
例如,在客户端上发布自定义"头像"字段:
// Client only code
if (Meteor.isClient) {
Meteor.subscribe("currentUserData");
...
}
// Server-only code
if (Meteor.isServer) {
Meteor.publish("currentUserData", function() {
return Meteor.users.find({}, {
fields : {
'avatar' : 1
}
});
});
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3152 次 |
| 最近记录: |