Skip to content

Instantly share code, notes, and snippets.

@ciwolsey
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save ciwolsey/053ccb308b617628184e to your computer and use it in GitHub Desktop.

Select an option

Save ciwolsey/053ccb308b617628184e to your computer and use it in GitHub Desktop.
----------- CONSOLE OUTPUT FROM console.log(results) --------------------------
I20141128-21:47:41.373(0)? { numberAffected: 1 }
I20141128-21:47:41.376(0)? { numberAffected: 1 }
I20141128-21:47:41.378(0)? { numberAffected: 1 }
--------------------------------------------------------------------------------
It's the result of a mongodb update. It seems to return one "{numberAffected: 1}"
for each document I affected. I'm trying to count the number of affected documents
but I'm not sure how to iterate over this to count them..
----------- COMEDY ROUND ---------------
Meteor.setInterval(function(){
targets = HostLogs.find().fetch();
scanres = scan(targets);
console.log("Scan completed (" + scanres.duration + "ms)");
_.each(scanres.res, function(host){
var count = HostLogs.upsert({ip: host.ip, port: host.port}, {$set: {ip: host.ip, port: host.port, status: host.status}});
console.log(count);
});
// Log the last time MegaMon went mega
date = new Date(moment().format());
Stats.upsert({name: "stats"}, {name: "stats", lastWentMega: date });
}, 4000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment