Optimistic concurrency is a better way to handle save conflict compare to the article I wrote previously.
https://scalaoncloud.blogspot.com/2021/03/how-to-avoid-save-conflict-in-mongoose.html
Optimistic concurrency tracks the version of the document and increments the version every time save(). If the version of the document in the database changed between when you loaded the document and when you save(), Mongoose will throw an error.
https://mongoosejs.com/docs/guide.html#optimisticConcurrency
https://thecodebarbarian.com/whats-new-in-mongoose-5-10-optimistic-concurrency.html
No comments:
Post a Comment