Can someone please guide me in the right direction? I have an application that uploads a CSV file to MongoDB and then displays it within the Meteor framework. I am facing an issue where I am subscribing to the data in the Template.onCreated function, but I am unable to iterate through the MongoDB cursor in the Template.helper to display the values in a table.
Template.table.onCreated(function() {
Template.instance().subscribe('contacts');
});
Template.table.helpers({
contact() {
var contactCursor = Contacts.find();
return contactCursor;
}
});
I have attempted to use cursor.fetch() and map methods, but it either does not render anything or crashes Chrome. The table structure I have tried to implement is:
<tr>
<td>
{{#each contact}}
{{contact}}
{{/each}}
</td>
</tr>
However, all I see in the table is:
[object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object]
or sometimes nothing at all. I am struggling to understand how to iterate through the cursor properly. The structure of the MongoDB collection is as follows:
{ "_id" : "Mzb6a9uh3948vw", "contact" : [ { "emailAddress" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f89f949d96b89d80999588994">[email protected]</a>", "someContact" : "No", "creationDate" : "N/A", "bounceBack" : "N/A", "unsubscribed" : "N/A" } ] }
I am aiming to display the data in the table in the following format:
{{#each cursor}}
{{emailAddress}}
{{someContact}}
{{createdDate}}
{{bounceBack}}
{{unsubscribed}}
{{/each}}
Any assistance would be greatly appreciated. I am new to the Meteor/Blaze environment and struggling to figure out the correct way to iterate through the cursor. Thank you!