Skip to content

Instantly share code, notes, and snippets.

@fbiville
Created March 26, 2015 19:42
Show Gist options
  • Save fbiville/87f7f181fe622edda1e7 to your computer and use it in GitHub Desktop.
Save fbiville/87f7f181fe622edda1e7 to your computer and use it in GitHub Desktop.
M101J-HW2.2 - using yet-to-be-taught aggregation framework
var cursor = db.grades.aggregate([{$group: {_id: "$student_id", minScore: {$min:"$score"}}}]);
while (cursor.hasNext()) {
var doc = cursor.next();
db.grades.remove({student_id: doc["_id"], score: doc["minScore"]});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment