Skip to content

Instantly share code, notes, and snippets.

@gokycat
Forked from adomado/gist:1226159
Last active August 26, 2015 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gokycat/0e37b79a189399872f4b to your computer and use it in GitHub Desktop.
Save gokycat/0e37b79a189399872f4b to your computer and use it in GitHub Desktop.
Example mongodb script
db = connect("localhost:27017/test");
var cursor = db.unicorns.find({gender : "m"});
var total = 0;
while(cursor.hasNext()) {
var obj = cursor.next();
total += (obj.hits || 0);
}
print(total);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment