Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "reload()" for in MongoEngine

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()?

like image 360
CandyCrusher Avatar asked Sep 19 '25 19:09

CandyCrusher


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

like image 96
Ewan Avatar answered Sep 21 '25 12:09

Ewan