Hey guys,
I'm looking for something like the 'InsertFlags.ContinueOnError' for InsertBatch of previous c# mongo driver. Anyone knows here?
Using mongodb c# 2.0 driver, I wanted to insert multiple documents(index set on a key). I'm using the 'InsertManyAsync', but when a duplicate based on index occurs, I get an error "A bulk write operation resulted in one or more errors."
I can't find anything in documentation that will just continue inserting the rest of the documents, ignoring the duplicate/error.
sample json to insert:
[
]
//creating the index:
await collection.Indexes.CreateOneAsync(Builders<BsonDocument>.IndexKeys.Ascending("u"), new CreateIndexOptions { Unique = true});
//inserting
await collection.InsertManyAsync(xx /*the json above*/);