Skip to content

Instantly share code, notes, and snippets.

@BinRoot
Created January 9, 2013 06:27
Show Gist options
  • Select an option

  • Save BinRoot/4491117 to your computer and use it in GitHub Desktop.

Select an option

Save BinRoot/4491117 to your computer and use it in GitHub Desktop.
MongoDB: groups a search by type with number of results
db.codes.group({key:{'type':1}, cond:{type:{$regex:'.*hi.*'}}, initial:{sum:0}, reduce:function(doc, prev){prev.sum++}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment