Skip to content

Instantly share code, notes, and snippets.

@outbounder
Created September 29, 2011 14:31
Show Gist options
  • Save outbounder/1250846 to your computer and use it in GitHub Desktop.
Save outbounder/1250846 to your computer and use it in GitHub Desktop.
var allCount = items.length;
var handleSave = function(err) {
if(err) {
allCount = 0; // this will prevent sending success: true if invoked again...
res.send({ success: false, msg: err}, 400);
return;
}
allCount -= 1;
if(allCount == 0) {
res.send({ success: true });
}
}
for(var item=0;item<items.length;item++)
{
var bundleTextItem = new global.BundleTextItem();
bundleTextItem.key = items[item].key;
bundleTextItem.value = "";
bundleTextItem.language = langForAdding;
bundleTextItem.bundlename = req.param("bundlename");
bundleTextItem.save(function(err, bundleTextItem){
handleSave(err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment