Created
February 19, 2014 04:29
-
-
Save dburles/9086087 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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