MongoDb c# driver update multiple documents in one atomic operation-Collection of common programming errors
I want to ask you if the following code will be executed in one atomic operation. I’m using mongodb c# driver.
The input to the method is list of id of the objects I want to update.
public void Update(IEnumerable ids)
{
var query = Query.Where(t => ids.Contains(t.Id));
var update = Update.Set("Modified", DateTime.Now); //this is just example of update
var options = new MongoUpdateOptions {Flags = UpdateFlags.Multi};
Collection.Update(query, update, options);
}
I’m interesting about the case, when I have milions of documents to update. What will happen if there will be a fail (power or hardware problem) during this update? Will be the database in a consistent state?
thanks.