Google News
logo
Meteor.js - Interview Questions
Collection helpers in Meteor.
We can use the dburles:collection-helpers package to easily attach such methods (or “helpers”) to documents. For instance:
Lists.helpers({
  // A list is considered to be private if it has a userId set
  isPrivate() {
    return !!this.userId;
  }
});
Once we’ve attached this helper to the Lists collection, every time we fetch a list from the database (on the client or server), it will have a .isPrivate() function available :
const list = Lists.findOne();
if (list.isPrivate()) {
  console.log('The first list is private!');
}
Advertisement