Skip to content

Instantly share code, notes, and snippets.

@dwilkins
Created January 27, 2014 20:58
Show Gist options
  • Save dwilkins/8657180 to your computer and use it in GitHub Desktop.
Save dwilkins/8657180 to your computer and use it in GitHub Desktop.
MongoDB aggregation / grouping
locs = Location.collection.aggregate({"$match" => {"counties" => "Jefferson"}},
{"$group" => {"_id" => "$city", "ids" => {"$addToSet" => "$_id"}}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment