MongoDB.live, free & fully virtual. June 9th - 10th. Register Now MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Is it okay to use MongoDB transactions for financial transactions

Hello.

Now that MongoDB supports multi-document ACID transactions, is okay to use them to model financial transactions, like when transferring funds from one account to another?

Yes, you can use MongoDB transactions for financial applications.

From the documentation on Transactions and Atomicity

For situations that require atomicity of reads and writes to multiple documents (in a single or multiple collections), MongoDB supports multi-document transactions:

  • In version 4.0 , MongoDB supports multi-document transactions on replica sets.
  • In version 4.2 , MongoDB introduces distributed transactions, which adds support for multi-document transactions on sharded clusters and incorporates the existing support for multi-document transactions on replica sets.

To use transactions on MongoDB 4.2 deployments (replica sets and sharded clusters), clients must use MongoDB drivers updated for MongoDB 4.2