为了方便起见,我在users
集合中定义了一些有用的字段。允许客户访问相应字段的正确方法是什么?我正在使用autopublish
包,但从Meteor.user()
客户端只显示emails
数组。
问问题
3166 次
1 回答
7
在查询用户集合时,您必须明确告诉 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
}
});
});
...
}
于 2013-01-30T11:58:14.380 回答