MongoDB。交易?

MongoDB. Transaction?

我想知道 MongoDB 中的多文档事务中是否有 ACID 保证。目前情况如何,现有资料很旧。现在升级了什么?

我们如何模拟以表明它不能(如果不能)或可以(如果可以)?

使多文档写入过程原子化您可以使用$isolated Operator

Using the $isolated operator, a write operation that affects multiple documents can prevent other processes from interleaving once the write operation modifies the first document. This ensures that no client sees the changes until the write operation completes or errors out.

您可以执行 Two Phase Commits 类似事务的语义。

查看 MongoDB 3.2 documentation 了解更多详情。

MongoDB 将从 4.0 版开始添加对 multi-document 事务的支持,因此您将在 multi-document 事务中获得 ACID 保证。 有关详细信息,请访问此 link:

https://www.mongodb.com/blog/post/multi-document-transactions-in-mongodb?jmp=community