Use setTimeout for query Collection in Meteor -
i defined collection in model.js this:
people = new meteor.collection("people");
here's code in main.js:
function test2(){ console.log(json.stringify(people.find().fetch())); settimeout(test2,5000) } if (meteor.isserver) { if(people.find().fetch().length === 0){ var tom = {name:"tom",age:18}; people.insert(tom); } meteor.startup(function () { test2(); }); }
here errors get:
i want meteor execute crud on collection automatically @ set intervals. i'm using settimeout
, seems difficult.
any idea doing wrong?
use meteor.settimeout instead:
meteor.settimeout(test2,5000)
on server meteor code run using fibers let write synchronous code, javascript's timeout has let callback fire in fiber too, if contains meteor code.
Comments
Post a Comment