jemand bitte ich brauche Sie helfen. davor habe ich eine Frage gestellt, aber ich kann diese Lösung nicht finden. Ich habe Code zum Zählen der Variablen in der Sammlung erstellt. Ich kann das Ergebnis erhalten, wenn man einzeln, aber nicht nach Gruppen zählt. Das ist mein Code, ich möchte das hier zählen, aber der Code hat mir keine Antwort gegeben. Ich möchte das Ergebnis wie folgt aus:Meteor: Zählen Sie Daten aus der Sammlung
PTR 1 KOM 4
This my code:
<template name="laporankategori">
<table class="table">
<thead>
<tr>
<th>Jenis Peralatan</th>
<th>Kuantiti</th>
</tr>
</thead>
<tbody>
{{#each profil}}
<tr>
<td>{{PTR}}</td>
<td>{{KOM}}</td>
</tr>
{{/each}}
</tbody>
</table>
</template>
// js
Template.laporankategori.helpers({
profil: function() {
return Profil.find({kategori: { $in: ['PTR', 'KOM'] } }).count();
}
});
Wo sind deine 'PTR' und' KOM' Helfer/Kontextvariablen? –
bedeutet? weil ich diesen Code bereits verwende wie 'profil: function() { return Profil.find ({kategorie: 'PTR'}). count(); } 'und es funktioniert. Jetzt versuche ich für diesen Code profile: function() { return Profil.find ({kategorie: {$ in: ['PTR', 'KOM']}}). Count(); } 'und es funktioniert nicht. Ich bin mir nicht sicher, wo das Problem ist. – nurul