Skip to content

Instantly share code, notes, and snippets.

@jdsiddon
Created January 22, 2014 05:20
Show Gist options
  • Save jdsiddon/8553839 to your computer and use it in GitHub Desktop.
Save jdsiddon/8553839 to your computer and use it in GitHub Desktop.
saveGunListings: function(arrayOfAuctionItems, callback) {
if (err) {
console.log("Error connecting to DB: " + err);
} else {
(itr = function() {
if (arrayOfAuctionItems.length > 0) {
var temp = arrayOfAuctionItems.pop();
console.log(temp);
/* Add back when dont with looping
gun.find({ id: temp }, function (err, guns) {
if (err) {
console.log("Can't find document: " + err);
}
if (Object.keys(guns).length > 0) { // If any gun documents already exist
console.log("+++ Gun listing aleady entered! +++");
} else { // No gun documents exist for that id, save to db.
console.log("New Auction Item! Saving to DB...");
}
itr();
}); /*end find */
})();
} else {
}
callback(null, "new guns saved!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment