Angular Meteor join collections


#1

Hi,

First of all I have to say I’m a Meteor newbie.

The tutorials and documentation is really great but there is one thing that really isn’t so clear to me how to solve: managing relationships between collections, or joining collections.

Is there a good example on how to achieve this with angular-meteor?

I felt quite comfortable doing this with some sort of image component. I just created a new component and though had all that was needed (mainly a scope to put all my stuff on). The component then has a subscription to the image, I guess this works “reactively”.

this.subscribe('images', () => [this.getReactively('imageid', true)]);

this.helpers({
  image() {
    let imageid = this.getReactively('imageid', true);
    if (imageid) {
      return Images.findOne(imageid);
    }
  }
});

On the template I had something like:
<ac-image imageid="someDocument.image"/>

This works great and I like it a lot, it feels clean. But how can I join the author name of a document, when I just have an id? I don’t feel like I should (and want) to create a component/directive for every join I need.

The most naive approach was to do something like this inside an ng-repeat:

<span class="text-muted">{{thread.lookupNickname(message.from)}}</span>

This works in conjunction with a subscription to all profiles, but Angular ususally calls the lookupNickname function faster than the subscription is ready. This just feels very bad to me and I really need some clean solution on this.How can I do this “reactively” without too much code?

Thank you very much