File tree Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -262,3 +262,4 @@ that much better:
262262 * Jan Stein (https://github.com/janste63)
263263 * Timothé Perez (https://github.com/AchilleAsh)
264264 * oleksandr-l5 (https://github.com/oleksandr-l5)
265+ * Ido Shraga (https://github.com/idoshr)
Original file line number Diff line number Diff line change @@ -543,7 +543,10 @@ Documents may be updated atomically by using the
543543There are several different "modifiers" that you may use with these methods:
544544
545545* ``set `` -- set a particular value
546+ * ``set_on_insert `` -- set only if this is new document `need to add upsert=True `_
546547* ``unset `` -- delete a particular value (since MongoDB v1.3)
548+ * ``max `` -- update only if value is bigger
549+ * ``min `` -- update only if value is smaller
547550* ``inc `` -- increment a value by a given amount
548551* ``dec `` -- decrement a value by a given amount
549552* ``push `` -- append a value to a list
@@ -552,6 +555,7 @@ There are several different "modifiers" that you may use with these methods:
552555* ``pull `` -- remove a value from a list
553556* ``pull_all `` -- remove several values from a list
554557* ``add_to_set `` -- add value to a list only if its not in the list already
558+ * ``rename `` -- rename the key name
555559
556560.. _depending on the value : http://docs.mongodb.org/manual/reference/operator/update/pop/
557561
Original file line number Diff line number Diff line change @@ -720,7 +720,7 @@ def with_id(self, object_id):
720720 return queryset .filter (pk = object_id ).first ()
721721
722722 def in_bulk (self , object_ids ):
723- """ " Retrieve a set of documents by their ids.
723+ """Retrieve a set of documents by their ids.
724724
725725 :param object_ids: a list or tuple of ObjectId's
726726 :rtype: dict of ObjectId's as keys and collection-specific
Original file line number Diff line number Diff line change @@ -867,6 +867,21 @@ def test_set_on_insert(self):
867867 assert "Bob" == bob .name
868868 assert 30 == bob .age
869869
870+ def test_rename (self ):
871+ self .Person .drop_collection ()
872+ self .Person .objects .create (name = "Foo" , age = 11 )
873+
874+ bob = self .Person .objects .as_pymongo ().first ()
875+ assert "age" in bob
876+ assert bob ["age" ] == 11
877+
878+ self .Person .objects (name = "Foo" ).update (rename__age = "person_age" )
879+
880+ bob = self .Person .objects .as_pymongo ().first ()
881+ assert "age" not in bob
882+ assert "person_age" in bob
883+ assert bob ["person_age" ] == 11
884+
870885 def test_save_and_only_on_fields_with_default (self ):
871886 class Embed (EmbeddedDocument ):
872887 field = IntField ()
You can’t perform that action at this time.
0 commit comments