定义文档、创建实例并在该实例上调用 save 方法后,确保文档保存成功的最佳方法是什么?
我应该实现post_save方法,使用 try/except 块,还是有更好的方法?
save()
是一个同步调用:
Save the :class:`~mongoengine.Document` to the database. If the
document already exists, it will be updated, otherwise it will be
created. Returns the saved object instance.
使用try/except
块来处理错误。