What is "reload()" for in MongoEngine

Viewed 1810

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 Answers

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

Related