Created
May 4, 2012 13:43
-
-
Save mitsuhiko/2594874 to your computer and use it in GitHub Desktop.
This destroys data :-(
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
class Model(object): | |
... | |
def save(self, ops=None): | |
ops = dict(ops or ()) | |
for column in self.modified_columns: | |
ops.setdefault('$set', {})[column] = self.data[column] | |
rv = self.collection.find_and_modify({'_id': self.id}, ops) | |
self.data.update(rv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment