Changes aren't reactive

Should this be reactive, that is, should changes be shown right away?
Because now i have to refresh the page to get this to show.

Template.x.helpers({ data: return Data.find() })

Template.x.events({
   'submit form': ... Data.insert(stuff)
})

<template x>
 {{data}}

</template

But when I duplicate a document with mongol it shows right away…

The subset of code that you have included should work as is. I suspect some part of your code that you aren’t including in your snippet is causing the problem.

Found the culprit:

Data.find({date:{$gte: startDate, $lt:storeDate}}, {sort: {date: -1}})

It’s the filters, how do i apply these filters so that this works?

When there are no filters it works

I guess what I’m trying to say is it’s very hard to help because the code you provided not only is not the code that doesn’t work for you, but is also not valid JavaScript code that I can try running on my computer.

Your code did not work as is for me. I had to change the helper definition to

Template.x.helpers({ data: function(){ return Data.find()} })

and iterate over data in the template

<template x>
 {{#each data}}
   {{this}}
 {{/each}}
</template

and then it works

Yeah sorry, I just typed up something fast, easier for me that way

I have updated my second post…

Are you sure that there is data that matches those filters in your collection? Are objects in the date field actually JS Date objects? Are startDate and storeDate Date objects?

Again, it is hard to tell you what is wrong without having enough code to look at. For future reference, the best way is to create an entire app and put it on GitHub so that someone can clone it and tell you what to change.

Thanks for the input, I’ve basically jumped from the codeacademy’s js and html/css course into meteor so I’m just on a huge learning spree. So sorry for the all bad practices I show.

Here is my date code:

var dateOffset = (24*60*60*1000) * 5;
var checkDate = new Date();
var storeDate = Date.now();
var startDate = checkDate.setTime(checkDate.getTime() - dateOffset);

I’ve tested it and the data older than 5 days doesnt show up so I guess it works…

Also I have to point out that I’m on windows if that means anything

Solution, when defining the date range I changed:

{date:{$gte: startDate, $lt:storeDate}}

into:

{date:{$gte: startDate}}

and now it works since the “time to” parameter is the now time I didn’t need the second parameter.

It probably has to do something with it being in milliseconds and the code can’t compare it fast enough.