Skip to content

Instantly share code, notes, and snippets.

@puentesarrin
Created June 17, 2014 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puentesarrin/e07a4772b6b113ce83d4 to your computer and use it in GitHub Desktop.
Save puentesarrin/e07a4772b6b113ce83d4 to your computer and use it in GitHub Desktop.
import pymongo
db = pymongo.MongoClient().school
for student in db.students.find():
hws = {s['score']: i for i, s in enumerate(student['scores'])
if s['type']=='homework'}
index = hws[min(hws.keys())]
del student['scores'][index]
db.students.save(student)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment