I was working on a way to more easily keep track of data relationships.

I was looking at some great packages on atmosphere like collection helpers, collection hooks, minimongoid, etc. However, I stumbled upon this great documented feature built right into Meteor Collections.

It allows you to transform documents returned by findOne() or fetch().

@nwientge pointed out collection helpers uses the transform function under the hood.

So I was thinking, what if you could create a “relations” prototype to keep track of all relationships between Mongo collections, and at the same time be able to share that prototype (or “mapping”) between all Collections?

You could define all of your relationships in one file like relations.js.

And since every collection would share the same prototype, you could traverse through data more easily.

For example:

Note.findOne().related(‘personId’).related(‘notes’);

could return all of the notes written by a Person for the given Note. Let’s walk through what the above could do.

You can reference the code provided below to follow along with the step-by-step.