です。コレクションのデータを数えるためにjavascriptコードを作成しました。の結果はNaNです。このコードを宣言してNaNではなく、真の結果(int)を得る方法。金額結果はNaN
Template.laporankategori.helpers({
profilcount: function() {
var subs = {};
Profil.find().forEach(function(e) {
if (subs[e.kategori] == null)
subs[e.kategori] = 0;
subs[e.kategori] += e.amount;
});
var results = [];
_.each(subs, function (value, key) {
results.push({category: key, amount: value});
});
return results;
}
});
//html
{{#each profilcount}}
<tr>
<td>{{category}}</td>
<td>{{ amount}}</td>
</tr>
{{/each}}
//
Profil = new Mongo.Collection ('profil');
Meteor.subscribe ('profil');
Template.laporankategori.helpers({
profilcount: function() {
return Profil.find({});
}
});
私はシェルでコマンドをするとき私はこのような結果が欲しいです。 Result 結果はまだこれと似ています。 Result
は、あなたがこれを使用しているHTMLの一部を表示することができます結果。ありがとう。 – JamiDer
また、 'Profil'コレクション – JamiDer
のサンプル文書も入れました。 – nurul