What is “reload()” for in MongoEngine

情到浓时终转凉″ 提交于 2019-12-24 11:29:33

问题


I have a statement like: jsonify_ok(data=mytag.reload().as_dict())

What role does reload() play? what's the normal situation for us to use reload()?


回答1:


Document.reload() will check the database and update your data (I think in this case mytag but I can't see what this is) with any attributes that have been modified.

This could be useful if the data could or has changed before calling jsonify_ok.

Breaking down your data=mytag.reload() this says: "For document mytag, go to the database and fetch the latest version of this document, assigning this to variable data"

Relevant documentation link



来源:https://stackoverflow.com/questions/52419456/what-is-reload-for-in-mongoengine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!