Friday 24 August 2018

Refresh document before save

Hi, I have 2 functions running in a post request each of them saving the same document. The problem is that I always get a mongoose version error for one of them. This happens because the first function saves the document and therefore changes the version of it. The second one retrived the document before the first one saved so it has the old version of it, therefore when saving it throws a version error. What I tried doing is performing some operations and retrieving the document again right before saving it. Unfortunately this didn't solve the issue. I guess that both of the functions retrieve the document faster than one of them manages to save it. Is there any way to overcome this problem? Thanks on advance :)

Submitted August 24, 2018 at 03:49PM by everek123

No comments:

Post a Comment