'Data consistency in mongodb, node.js

Interviewer asked me, there are 2 collections like debit and balance in my mongodb database, the debit operation was successful but balance update is being updated, meanwhile there is a new request to check balance made, how to make sure user gets updated balance even though the updating balance is still in progress?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source