Skip to content

Instantly share code, notes, and snippets.

@fakenickels
Last active October 7, 2015 02:56
Show Gist options
  • Save fakenickels/82bdbc75e2017255dad5 to your computer and use it in GitHub Desktop.
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