Last active
October 12, 2015 11:08
-
-
Save mrmarcondes/4017296 to your computer and use it in GitHub Desktop.
10gen: M101 MongoDB for Developers - Homework 2.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ruby | |
client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'm101') | |
grades = client[:grades].find("type" => "homework").sort({student_id:1, score:1}) | |
student_id = nil | |
grades.each do |grade| | |
if student_id != grade["student_id"] | |
student_id = grade["student_id"] | |
client[:grades].find(_id: grade[:_id]).delete_one | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment