Meteor newb here. The reactivity of the Meteor puzzles me. I can update the collection from the Mongo console and it will instantly update the user interface. But not with a mango aggregate?
I use meteorhacks: aggregate to get mongo aggregate () loaded into the meteor.
Aggregation works great. I can immediately see the data update in the mongo console. However, if I show it in the user interface, there is no update even when updating the client.
db.collection:
{a:1,b:2}
{a:1,b:2}
The code:
inputCollection = new Meteor.Collection('input_collection')
outputCollection = new Meteor.Collection('output_collection')
Meteor.methods({
pleaseAggregate: function() {
inputCollection.aggregate([{
$group : {
_id : "$a",
count: { $sum: 1}
}
},
{$out : "output_collection"}
]);
}
});
HTML
<p>Aggregates: {{agg.count}}</p>
Client.js
Template.debug.helpers({
agg: function() {
return outputCollection.find().fetch()[0]
}
});
By the way, it is published, I have "unsafe" installed.
I'm missing something obvious for a meteor, I think. What is it?
source
share