Skip to content

Instantly share code, notes, and snippets.

@fakenickels
Last active October 7, 2015 02:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save fakenickels/82bdbc75e2017255dad5 to your computer and use it in GitHub Desktop.
// @locus: server
if(Meteor.isServer){
Tracker.autorun(() => {
CollectionObserved.find();
collectAndSaveData();
});
function collectAndSaveData(){
var aggregateData = CollectionObserved.aggregate(...);
var aggregateDocId = ...;
AggregateDataCollection.update(aggregateDocId, {
$set: aggregateData
});
}
// Publish
Meteor.publish('aggregateDataCol', function(){
return AggregateDataCollection.find();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment