-
-
Save tmeasday/9086145 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) { | |
// ... | |
}; | |
} | |
var relations = {}; | |
Meteor.Collection.prototype.relations = function(relations) { | |
relations[this._name] = 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 collectionName = cursor._cursorDescription.collectionName; | |
// var collection = getCollection(cursor._cursorDescription.collectionName); | |
console.log(cursor._joins); | |
Meteor.publish(name + '_' + cursor._joins, function(key) { | |
return relations[collectionName][cursor._joins]; | |
}); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment