MCPcopy Index your code
hub / github.com/dburles/meteor-collection-helpers

github.com/dburles/meteor-collection-helpers @v0.3.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.2 ↗ · + Follow
0 symbols 0 edges 3 files 0 documented · 0% updated 19mo ago★ 49511 open issues

Browse by type

Functions 0 Types & classes 0
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Meteor Collection Helpers

Collection helpers automatically sets up a transformation on your collections allowing for simple models, with an interface similar to template helpers.

Installation

$ meteor add dburles:collection-helpers

Usage

It's recommended to set up helpers to run on both server and client. This way your helpers can be accessed both server side and client side.

Some simple helpers:

Books = new Meteor.Collection('books');
Authors = new Meteor.Collection('authors');

Books.helpers({
  author: function() {
    return Authors.findOne(this.authorId);
  }
});

Authors.helpers({
  fullName: function() {
    return this.firstName + ' ' + this.lastName;
  },
  books: function() {
    return Books.find({ authorId: this._id });
  }
});

Example use within a template

Our relationships are resolved by the collection helper, avoiding unnecessary template helpers. So we can simply write:

Template.books.helpers({
  books: function() {
    return Books.find();
  }
});

...with the corresponding template:

<template name="books">
  <ul>
  {{#each books}}
    <li>{{name}} by {{author.fullName}}</li>
  {{/each}}
  </ul>
</template>

Use outside of templates

You can of course access helpers outside of your templates:

Books.findOne().author().firstName; // Charles
Books.findOne().author().fullName(); // Charles Darwin

Meteor.users

You can also apply helpers to the Meteor.users collection

Meteor.users.helpers({
  // ...
});

License

MIT

Core symbols most depended-on inside this repo

Shape

For agents

$ claude mcp add meteor-collection-helpers \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page