Google News
logo
Meteor.js - Interview Questions
Association helpers in Meteor.
Now we can attach helpers to documents, we can define a helper that fetches related documents
Lists.helpers({
  todos() {
    return Todos.find({listId: this._id}, {sort: {createdAt: -1}});
  }
});
Now we can find all the todos for a list :
const list = Lists.findOne();
console.log(`The first list has ${list.todos().count()} todos`);
Advertisement