Progressively publishing user data

In my app, by default, I’m publishing all of the users first and last names, but don’t want to reveal any of their other information.

Meteor.publish(null, function() {
  return Meteor.users.find({}, { fields: { 'profile.firstName': 1, 'profile.lastName': 1}});
});

At a later point in my app, once some criteria has been met, I want to publish the full user profile:

Meteor.publish('fullUserInfoWithId', function(id) {
  var aDoc = Docs.find(id);
  return Meteor.users.find({ _id: aDoc.userId }, { fields: { 'profile.street': 1, 'profile.city': 1, 'profile.state': 1}});
});

You can see in the second publish I’m trying to send the address info to the client.
This doesn’t seem to be merging with the existing mini-mongo data. Is there any way to do this with user data?

Edit One piece of information I forgot to include is that I’m publishing the email in that second publish:

{ fields: { emails: 1 }}

And the emails are getting sent to the client, so I know that publish is wired up. It’s just not merging or “joining” the profile data.

try using

Meteor.publish('fullUserInfoWithId', function(id) {
  return Meteor.users.find({ _id: id }, { fields: { 'profile.street': 1, 'profile.city': 1, 'profile.state': 1}});
});

I have never looked deeper into these publication overwritting rules. I would expect DDP just check if the _id is already in collection and expect it to be up to date.

So I would suggest publishing to client only collection with different name.
Or merge these 2 publications into 1.

It should work. But as you perform a join in the publish function, and because publish functions are not reactive in Meteor, I suspect you got a problem there. So, as @cottz said above, start by trying to do your join client-side (i.e. send the userId instead of the doc id).

I believe the issue you are having is due to a limitation with Meteor’s merge box only tracking changes to top level fields. Check https://meteorhacks.com/understanding-mergebox for more information.