public async Task InsertOneAsync(InsertOneModel <TDocument> model, TimeSpan?timeout, CancellationToken cancellationToken) { Ensure.IsNotNull(model, "model"); try { var bulkModel = new BulkWriteModel <TDocument>(new[] { model }); await BulkWriteAsync(bulkModel, timeout, cancellationToken); } catch (BulkWriteException <TDocument> ex) { throw WriteException.FromBulkWriteException(ex); } }
public async Task <UpdateResult> UpdateOneAsync(UpdateOneModel <TDocument> model, TimeSpan?timeout, CancellationToken cancellationToken) { Ensure.IsNotNull(model, "model"); try { var bulkModel = new BulkWriteModel <TDocument>(new[] { model }); var result = await BulkWriteAsync(bulkModel, timeout, cancellationToken); return(UpdateResult.FromCore(result)); } catch (BulkWriteException <TDocument> ex) { throw WriteException.FromBulkWriteException(ex); } }