Last active
April 5, 2016 17:51
-
-
Save merlinstardust/b4ee7b735dce56c911b086185b378ba0 to your computer and use it in GitHub Desktop.
Goes through all collections and attaches association helpers to them
This file contains 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
var collections = []; | |
_.each(collections, function (collection) { | |
var helpers = {}; | |
var fields = window[relation].simpleSchema().objectKeys(); | |
_.each(fields, function (field) { | |
var key = field.replace(/Id$/, ''); | |
helpers[key] = function () { | |
var entity = capitalize(key) + 's'; | |
return window[entity].findOne({_id: this[field]}); | |
}; | |
}); | |
window[relation].helpers(helpers); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment