Skip to content

Instantly share code, notes, and snippets.

@nocubicles
Created May 20, 2015 17:32
Show Gist options
  • Select an option

  • Save nocubicles/f3669257d2d388a62303 to your computer and use it in GitHub Desktop.

Select an option

Save nocubicles/f3669257d2d388a62303 to your computer and use it in GitHub Desktop.
Meteor.setInterval( function () {
productDate = Products.findOne({isItReady: false}); ///Thats the query
var timeNow = Date();
var timeNow = timeNow.toString();
var timeCreated = productDate.createdAt;
var timeCreated = timeCreated.toString();
var productId = productDate._id;
if (timeCreated <= timeNow) {
console.log("check")
Products.update({_id: productId}, {$set: {isItReady: true}}, function(error, result) {
console.log(productId)
if (error){
console.log(error.reason) //check the error
} else{
console.log("File with the id: " + result + " just get update")
}
});
}
}, 5000);
@garrilla
Copy link
Copy Markdown

var interval = Meteor.setInterval( function () {
///blah

if (condition) Meteor.clearInterval(interval)
} , 5000);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment