I have thousands of users and each user has a inbox document. Now, users send messages to each other which updates their inbox document and I get this below error:
VersionError: No matching document found for id
I search this on google and now I understand why this error occurs. It is because mongoose try to update a user inbox document, which is already updated to a newer version. In other words, when a user receives messages from multiple users at a same time.
So, my question is that how to deal with this problem for a NodeJs app so that if multiple users send message to same user at a same time, all the messages should be updated.
Thanks in advance.