I am using Python mongoengine and I would like to define callback, which will be called everytime document is updated.
from mongoengine import *
from mongoengine import signals
from time import time
class Item(Document):
name = StringField()
modified = LongField()
def update_modified(sender, document):
document.modified = time()
signals.pre_save.connect(update_modified)
However update_modified is not called, when I update document:
Item.collection.objects(name="First").update_one(name="Second")
Is there any way to fix it?