One of the projects I am working on is using MongoDB as the database solution. And the project makes use of the nifty ORM mongoose to do the heavy lifting of data orchestration. It was high time I implemented transactions to the equation but because of a time crunch I was not able to start with one and the situation merely demands it at times. But come with an architectural change and the way the project was heading it was high time I implemented transactions by using MongoDB. According to MongoDB documentation, transactions are used when the situation requires, “atomicity of reads and writes to multiple documents (in single or multiple collections)”. MongoDB supports multi-document transactions. With distributed transactions, transactions can be used across multiple operations, collections, databases, documents, and shards. Now the piece of code to implement the same was pretty straightforward. // For a replica set, include the replica set name and a seedlist of the members in the URI...
My personal workaround to many of the issues we see around us and other stories