문제

I'm doing two consecutive writes into the MongoDB (no shards, no replicas):

  1. insert data into db
  2. find and modify data inserted in 1.

when performing step 2), is it granted, that the command sees the data insertion from step 1)? What is the minimal WriteConcern I should use in step 1) to ensure this?

As for my use-case, I know, I could merge 1 and 2 into one simple step; however, my real use-case is much more complicated and cannot be solved such easily.

도움이 되었습니까?

해결책

Your use case will work given you are using a write concern of Acknowledged. This is the default write concern in MongoDB 2.2 or later given you are using a recent driver (see here for the minimum driver version required).

http://docs.mongodb.org/manual/release-notes/drivers-write-concern/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top