'Unable to update the same document inserted in same Mongodb transaction session

I have 2 collections of users and orders. I want to create a relation by inserting the documents for both collections and then updating the orders document with the _id of the user document. But when I do this in the same Mongodb transaction session, the order document is never updated! But if I disable the transaction, the code works perfectly fine!



Solution 1:[1]

Actually, I had to add the transaction session object in the options of the updateOne command of the MongoDB client.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Saif Ali Khan