Skip to content

Instantly share code, notes, and snippets.

@puentesarrin
Last active October 12, 2015 11:48
Show Gist options
  • Save puentesarrin/4022294 to your computer and use it in GitHub Desktop.
Save puentesarrin/4022294 to your computer and use it in GitHub Desktop.
Course M101 - Help to solve Homework 2.2
db.grades.aggregate({
'$group': {'_id': '$student_id'}}).forEach(function(i) {
var x = db.grades.find({ student_id: i._id, type: 'homework' }).sort({ score: 1 })[0];
db.grades.remove({ _id: x._id });
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment