Skip to content

Instantly share code, notes, and snippets.

@adomado
Created September 19, 2011 08:41
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save adomado/1226159 to your computer and use it in GitHub Desktop.
Save adomado/1226159 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