I am using meteor.js. I am having three collections boards,categories,users.
Boards :
{
\"_id\": ObjectId(\"su873u498i0900909sd\"),
\"locked\": NumberIn
Probably collection helpers.
Basic usage:
Boards.helpers({
creator: function () {
return Meteor.users.findOne(this.creatorId);
},
category: function () {
return Categories.findOne(this.categoryId);
}
});
Usage in template is pretty simple. Let's say you have your board:
{{#each boards}}
<div>
<h3>{{board_name}}</h3>
<p>Created by</p>: {{ creator.username }}
<p>Category</p>: {{ category.catname }}
</div>
{{/each}}
Added tip: use publish-composite to publish the relationships in a more manageable fashion.
Meteor.publishComposite('board', function (boardId) {
check(boardId, String);
return {
find: function () {
return Boards.find(boardId);
},
children: [{
find: function (board) {
return Meteor.users.find(board.creatorId);
}
}, {
find: function (board) {
return Categories.find(board.categoryId);
}
}]
}
});