Skip to content

Instantly share code, notes, and snippets.

@jesusangelm
Created November 5, 2012 17:30
Show Gist options
  • Save jesusangelm/4018638 to your computer and use it in GitHub Desktop.
Save jesusangelm/4018638 to your computer and use it in GitHub Desktop.
borrar el registro de la tarea con la nota mas baja de cada estudiante en la BD MongoDB
require "mongo"
connection = Mongo::Connection.new("localhost", 27017)
db = connection.db("students")
coll = db.collection("grades")
199.times do |n|
doc = coll.find("student_id" => n, "type" => "homework").sort(:score => :asc).limit(1)
doc.each { |i| coll.remove(i) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment