MongoDB async save parallel desync

I'm using mongoose to save an communicate with my mongo database. The question I have is: what happens if I load a document from a database, make changes to it, then asynchronously load the same document in another instance and change it there too before the first change has been saved? For example i might have a user with email and a name. In this case the first operation would change the name and the second would change the email. Will the name not be changed in the end as a result of this occurence?

Will the first operation be saved to the database and then be erased by the second or how does it work? And if it turns out to be a problem how does one manage it? I know the chance of this occurence is very slime but it's not non-existent right?

What's the best practice here?



from Recent Questions - Stack Overflow https://ift.tt/3u1CNjh
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations