Created
November 2, 2015 20:34
-
-
Save zachariahtimothy/4e150b3931e4f299138e to your computer and use it in GitHub Desktop.
Sets up context for using CollectionsFS with FlowRouterSSR. Allows the .url() function to work server side.
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
//Hack to make CollectionFS work with FlowRouter. | |
if (Meteor.isServer) { | |
let originalFind = Collections.Media.find; | |
let originalFindOne = Collections.Media.findOne; | |
Collections.Media.__proto__.findOne = function (selector, options) { | |
let self = this; | |
return FlowRouter.ssrContext.withValue(null, function() { | |
return originalFindOne.call(self, selector, options); | |
}); | |
}; | |
Collections.Media.__proto__.find = function (selector, options) { | |
let self = this; | |
return FlowRouter.ssrContext.withValue(null, function() { | |
return originalFind.call(self, selector, options); | |
}); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment