[英]Meteor: Reactive joins exposes intermediate data
I'm using publish-composite to perform a reactive join (I'm sure the specific package does not matter). 我正在使用publish-composite来执行反应式连接(我确定特定的程序包无关紧要)。 And I am seeing that the intermediate data gets pushed to the client. 而且我看到中间数据被推送到客户端。
In the following example: 在以下示例中:
Meteor.publishComposite('messages', function(userId) {
return {
find: function() {
return Meteor.users.find(
{ 'profile.connections.$': userId }
);
},
children: [{
find: function(user) {
return Messages.find({author: user._id});
}
}]
}
});
All the users that has userId in profile.connections
get exposed to the client. 在profile.connections
中具有userId的所有用户都向客户端公开。 I know that can create a mongodb projection so the sensitive stuff is not exposed. 我知道可以创建一个mongodb投影,这样敏感的东西就不会暴露出来。 But I was wondering if I can just prevent the first find() query cursor from getting to the client at all. 但是我想知道是否可以完全阻止第一个find()查询游标到达客户端。
Are you trying to only publish messages for a particular user if that user is a connection with the logged on user? 您是否仅尝试为特定用户发布消息(如果该用户与登录用户有联系)? If so, maybe something like this would work: 如果是这样,也许这样的事情会起作用:
Meteor.publishComposite('messages', function(userId) {
return {
find: function() {
return Meteor.users.find(this.userId);
},
children: [{
find: function(user) {
return Meteor.users.find(
{ 'profile.connections.$': userid }
);
},
children: [{
find: function(connection, user) {
return Messages.find({author: connection._id});
}
}]
}]
};
});
That would be equivalent to something like : 那将相当于:
Meteor.publish('message',function(userId) {
var user = Meteor.users.find({_id : this.userId, 'profile.connections.$' : userId});
if (!!user) {
return Messages.find({author: userId});
}
this.ready();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.