Skip to content

Instantly share code, notes, and snippets.

@dburles
Created February 19, 2014 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dburles/9086087 to your computer and use it in GitHub Desktop.
Save dburles/9086087 to your computer and use it in GitHub Desktop.
if (Meteor.isClient) {
Meteor.subscribeReactive = function(name) {
// ...
};
}
Meteor.Collection.prototype.relations = function(relations) {
this._relations = relations;
};
if (Meteor.isServer) {
Cursor = Object.getPrototypeOf(new Meteor.Collection('_void').find()).constructor;
Cursor.prototype.join = function(name) {
this._joins = name;
return this;
};
Cursor.prototype.connection = function() {
return this;
};
var getCollection = function(name) {
for (var object in global)
if (global[object] instanceof Meteor.Collection)
if (global[object]._name === name)
return global[object];
};
Meteor.publishReactive = function(name, fn) {
var cursor = fn();
var collection = getCollection(cursor._cursorDescription.collectionName);
console.log(cursor._joins);
Meteor.publish(name + '_' + cursor._joins, function(key) {
return collection._relations[cursor._joins];
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment