Last active
August 29, 2015 14:28
-
-
Save pkulev/42d43718e0a22b1eac9d to your computer and use it in GitHub Desktop.
pshoo
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
"""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