Hey guys,
Here is a little challenge I am facing… I have a collection which contains an array of 3 fields. I would like to show a table with this information, so I am trying to build a Template Helper and the appropriate {{ … }} on the html file.
Unfortunately, none of my approaches so far have worked. Here is my code:
collections.js
const PaymentsSchema = new SimpleSchema({
userId: {
type: String,
optional: true
},
months: {
type: Array,
optional: true
},
'months.$': {
type: String,
optional: true
},
'months.$.price': {
type: Number,
optional: true
},
'months.$.status': {
type: String,
optional: true
}
});
payments.js
Template.Payments.helpers({
'payment'(){
return Payments.findOne({
userId: userId
},{
fields:{
months: 1
}
});
}
});
payments.html
<template name="Payments">
<table class="highlight">
<thead>
<tr>
<th>Month</th>
<th>Price</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{{#each payment}}
<tr class="link-tabela">
<td>{{months}</td>
<td>{{price}}</td>
<td>{{status}}</td>
</tr>
{{/each}}
</tbody>
</table>
</template>
Any idea how I can accomplish this? Thanks!