Client side joins are fairly straight-forward, however for newcomers it's often unclear how exactly to go about it. So let's illustrate how it's done.
Example data
We have two collections named: Books
& Authors
; and here's how our documents look:
Book
{
_id: 'vJSWRcJATAPyCj9nq',
authorId: 'YzP8SX8x8GsDD3DQj',
name: 'On the Origin of Species'
}
Author
{
_id: '6ciawd8J7mvxPdKFg',
name: 'Charles Darwin'
}
Templates
<template name="books">
<ol>
{{#each books}}
{{> book}}
{{/each}}
</ol>
</template>
<template name="book">
<li>{{name}} by {{author.name}}</li>
</template>
Helpers
Template.books.helpers({
books: function() {
return Books.find();
}
});
Template.book.helpers({
author: function() {
return Authors.findOne(this.authorId);
}
});
More
https://atmospherejs.com/package/collection-helpers
Collection helpers allows you to create helper functions against your collections.