I have updated my user collection in my Meteor app with an array of objects named contacts
. This is how it looks now:
{
"_id" : "p6c4cSTb3cHWaJqpG",
"createdAt" : ISODate("2016-05-11T11:30:11.820Z"),
"services" : {
.....
},
"username" : "admin",
"emails" : [
{
"address" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="43262e222a2f03262e222a2f6d202c2e">[email protected]</a>",
"verified" : true
}
],
"points" : 28,
"contacts" : [
{
"when" : ISODate("2016-06-02T12:22:53.747Z"),
"who" : "4YBufbE9PByJBkasy"
},
{
"when" : ISODate("2016-06-02T12:00:41.833Z"),
"who" : "EvF7DbFazmiuG86mD"
},
{
"when" : ISODate("2016-06-02T12:21:41.415Z"),
"who" : "MNFTSzjjzmYWgDvey"
}
]
}
Although I can successfully display the contacts on my page, they are currently in the same order as they are in the collection. Is it possible to arrange them based on the date in the when
field?
This is my helper method:
Template.contacts.helpers({
'cont': function(){
var user = Meteor.user();
return user;
}
});
And this is my Template:
<template name="contacts">
{{#each cont.contacts}}
<h1><a href="/message/{{who}}">{{who}}</a></h1>
{{/each}}
</template>