heynemann / motorengine

Motorengine is a port of MongoEngine for Tornado.
http://motorengine.readthedocs.org
204 stars 67 forks source link

update document via $set #90

Open Rey8d01 opened 9 years ago

Rey8d01 commented 9 years ago

class QuerySet method update have next code

        update_arguments = dict(
            spec=update_filters,
            document={'$set': definition},
            multi=True,
            callback=self.handle_update_documents(callback)
        )

everything is ok, but it works only when I update collection (not document). if I update document execute method save and then _indexes_saved_beforesave - this code

self.coll(alias).update({'_id': document._id}, doc, callback=self.handle_update(document, callback))

may be better this code

self.coll(alias).update({'_id': document._id}, {"$set":doc}, callback=self.handle_update(document, callback))

like as update method.

heynemann commented 9 years ago

Can you submit a Pull Request with a test that shows it working?