MongoDB中的交易支持 [英] Transaction support in MongoDB

查看:63
本文介绍了MongoDB中的交易支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是MongoDB的新手.我在MongoDB does not support multi-document transactions此处 http://docs.mongodb.org/manual/faq/fundamentals读过/.

I am new to MongoDB. I read that MongoDB does not support multi-document transactionshere http://docs.mongodb.org/manual/faq/fundamentals/.

如果我想以原子方式将数据保存在两个集合(A和B)中,那么我将无法使用MongoDB来执行此操作,即,如果在B情况下保存失败,则A仍将拥有数据.这不是一个很大的劣势吗?

If I want to save data in two collections(A and B) atomically, then i can't do that using MongoDB i.e. if save fails in case of B, still A will have the data. Isn't it a big disadvantage?

仍然,人们使用的是MongoDB而不是RDBMS.为什么?

Still, people are using MongoDB rather than RDBMS. Why?

推荐答案

MongoDB不支持多文档事务.

MongoDB does not support multi-document transactions.

但是, MongoDB确实在单个文档上提供了原子操作.通常,这些文档级原子操作足以解决需要在关系数据库中进行ACID事务的问题.

例如,在MongoDB中,您可以将相关数据嵌入到嵌套数组中,也可以将嵌套文档嵌入到单个文档中,并通过单个原子操作来更新整个文档.关系数据库可能表示具有多个表和行的相同类型的数据,这将需要事务支持来自动更新数据.

For example, in MongoDB, you can embed related data in nested arrays or nested documents within a single document and update the entire document in a single atomic operation. Relational databases might represent the same kind of data with multiple tables and rows, which would require transaction support to update the data atomically.

这篇关于MongoDB中的交易支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆