How to prevent data inconsistencies when database receives multiple request at once?

I’ve noticed that MongoDB doesn’t do well when multiple request target the same document for updating at once.

Let’s say I have a document that holds a number of quarters. If multiple requests “take a quarter” (decrementing the quarter count down by one), updating and saving the new update - then the end result after all requests are processed isn’t correct.

This is prob a terrible example but hopefully, this makes sense.

How can we make a document be handled by one request at a time?

Transactions