问题
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