javascript - Meteor: Reactive joins exposes intermediate data -
i'm using publish-composite perform reactive join (i'm sure specific package not matter). , seeing intermediate data gets pushed client.
in 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 users has userid in profile.connections
exposed client. know can create mongodb projection sensitive stuff not exposed. wondering if can prevent first find() query cursor getting client @ all.
are trying publish messages particular user if user connection logged on user? if so, maybe 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 equivalent :
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(); });
Comments
Post a Comment