Hello everyone,
I am very sorry, somehow the MongoDB forum and I don’t get along :wink: The email notification about your replies got stuck in the Spam folder…

Thank you very much! Your responses were very helpful.

I understand, this is a weakness of MongoDB, working with nested arrays is harder then it could be - Thank you, for clarifying, that I did not miss something!

The workaround with a bulk write is a great idea, thanks for that. It does simplify the update a lot. But this raises another question:

If I understood correctly, updates do a document are atomic, even if they come from an aggregation pipeline (https://www.mongodb.com/docs/manual/core/write-operations-atomicity/#atomicity-and-transactions).

Would we loose this property with the bulk-write solution? Because albeit being only one round-trip, it would be to update operations? Giving us a very very small time window, where another write could happen, that then updates the wrong element? Probably more of a theoretical problem, than a real one, as I assume the writes should be executed in direct sequence.

Best regards
Aiko

2 Likes