Are MongoDB bulk updates atomic if they apply to the same document?
For the following command where query
can only ever match one document (note that bulkWrite()
is ordered by default):
final BulkWriteResult res = db.getCollection("mycol").bulkWrite(Arrays.asList(
new UpdateOneModel<>(query,
new Document("$addToSet", new Document("some_things", things))),
new UpdateOneModel<>(query,
new Document("$pull", new Document("some_things", otherthings)))));
... I understand that if the first update succeeds and the second fails (which under normal circumstances should be impossible) the first update will still be applied to the document, which means the bulk write isn't strictly atomic. However, assuming both queries succeed, is the operation atomic? Eg can other writes interleave between the two operations or not?
链接地址: http://www.djcxy.com/p/61958.html上一篇: 更新处理重复项和增加运算符的查询