Skip to content

Instantly share code, notes, and snippets.

@ermst4r
Created September 2, 2016 07:28
Show Gist options
  • Save ermst4r/9af6088fed74f1a64f48d4af9497cc2c to your computer and use it in GitHub Desktop.
Save ermst4r/9af6088fed74f1a64f48d4af9497cc2c to your computer and use it in GitHub Desktop.
psuodo code
var counter = 0 // count when the foreach is done
retailers.forEach(function(retailer) {
retailer.siteid=siteid;
retailer.month=month;
retailer.year=year;
prim_id =md5(siteid+month+year+retailer.storeid);
retailer.prim_id=prim_id;
//sails.log(retailer);
Retailers.updateOrCreate({prim_id:prim_id},retailer,function createFindCB(error, createdOrFoundRecords){
console.log('Store Updated'+retailer.storeid+'?');
counter++; // count where the foreach is done..
});
});
if(counter == retailers.length) {
resolve(true);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment