Skip to content

Instantly share code, notes, and snippets.

@pkulev
Last active August 29, 2015 14:28
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 pkulev/42d43718e0a22b1eac9d to your computer and use it in GitHub Desktop.
Save pkulev/42d43718e0a22b1eac9d to your computer and use it in GitHub Desktop.
pshoo
"""School.students migration script."""
from pymongo import MongoClient
conn = MongoClient("mongodb://localhost:27017")
db = conn.school
students = db.students
for student in students.find():
scores = student["scores"][:]
scores.remove(min([el for el in student["scores"] if el["type"] == "homework"]))
students.update_one({"_id": student["_id"]}, {"$set": {"scores": scores}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment