My task sounds simple, but I cannot nail how to write it ... I just want to find the last item inserted in the collection and display it in my meteor application.
I play with Collection.find () with no real results. This is the last line I tried: (remember that these names are placeholders. My collection is not called Collection in my code)
Template.tempname.tempitem = function () {
return Collection.find({}, {sort: {DateTime: -1, limit: 1,}});
};
I have feild in the collection, which is the result
Date.parse (Date ())
which should allow me to sort the latest ones. There are probably other ways to do this, but this was the first decision I came up with.
source
share