2

Let's say I have two collections A and B. In my C# program I'm trying to get data from them. Currently I get data from collection A first and save the documents into a container. And then get data from collection B. But theoretically speaking, the data may be changed after getting from A and before getting from B. So that I get incorrect results. Is there a safe way?

0

2 Answers 2

4

Mongodb does not support transactions. Because of mongodb was designed to be scalable (it means sharding, replication), and distributed transactions can be very expensive and make database slower in general. So you can't block collection A for writes, while you getting/updating it, loading from B.

There is some kind of transactions in mongodb -- it is atomic updates on single document. So you can update part of document without loading of it.

Sign up to request clarification or add additional context in comments.

Comments

0

Whilst Mongo doesn't explicitly support locking tables like SQL systems do, you might want to take a look at the fsync function. If I'm reading the docs correctly, you should be able to use it as a hack to temporarily prevent data writes.

http://www.mongodb.org/display/DOCS/fsync+Command

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.