4 ms·
Interesting. I haven't had a usecase where data integrity is critial yet. A project i'm working on now will have credits and accounts. To accomplish that in mo
by arnejenssen 6y ago
Interesting. I haven't had a usecase where data integrity is critial yet.
A project i'm working on now will have credits and accounts. To accomplish that in mongo. I create a transaction with with "pending" status. Then i try to debit the source account, and credit the destination account and I add the pending transaction to the accounts. If that works I set the transaction to "committed" and I remove the pending transactions from the accounts.
https://gist.github.com/exoer/eee2aa37c86c06190f12ef4e2c6bd1c6 https://gist.github.com/exoer/eee2aa37c86c06190f12ef4e2c6bd1...
- wlll 6y agoIf you haven't already I would absolutely read the Jepsen articles on MongoDB, at least so you are aware of the risks and failure states. There's some stuff about transactions that may be relevant too.