perak / meteor-joins

Collection joins for Meteor
77 stars 7 forks source link

Cannot join Meteor.users if not logged in #15

Open Torone opened 7 years ago

Torone commented 7 years ago

Hi,

I have a collection called Messages and I'm trying to join it with Meteor.users to get the author name:

export const Messages = new Mongo.Collection('messages');

Messages.join(Meteor.users, '_author', 'author', ['profile']);

if (Meteor.isServer) {
  Meteor.publish('messages', function() {
    return Messages.find({}, {
      sort: { createdAt: -1 }
    });
  });
}

If I'm logged in I can see correctly the user name for my messages. If I logout I receive the following error:

Exception from Tracker recompute function:
TypeError: Cannot read property 'profile' of undefined
perak commented 7 years ago

Hi @Torone thanks for reporting issue, I'll check what's the problem and fix if possible