Skip to content

Commit 3655c7c

Browse files
author
Oleksandr Poliakov
committed
Missed options
1 parent 7bf05ad commit 3655c7c

File tree

5 files changed

+78
-16
lines changed

5 files changed

+78
-16
lines changed

src/MongoDB.Driver/DeleteOptions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
* limitations under the License.
1414
*/
1515

16+
using System;
1617
using MongoDB.Bson;
18+
using MongoDB.Driver.Core.Misc;
1719

1820
namespace MongoDB.Driver
1921
{
@@ -27,6 +29,7 @@ public sealed class DeleteOptions
2729
private BsonValue _comment;
2830
private BsonValue _hint;
2931
private BsonDocument _let;
32+
private TimeSpan? _timeout;
3033

3134
// properties
3235
/// <summary>
@@ -64,5 +67,14 @@ public BsonDocument Let
6467
get { return _let; }
6568
set { _let = value; }
6669
}
70+
71+
/// <summary>
72+
/// Gets or sets the operation timeout.
73+
/// </summary>
74+
public TimeSpan? Timeout
75+
{
76+
get => _timeout;
77+
set => _timeout = Ensure.IsNullOrValidTimeout(value, nameof(Timeout));
78+
}
6779
}
6880
}

src/MongoDB.Driver/InsertManyOptions.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
* See the License for the specific language governing permissions and
1313
* limitations under the License.
14-
*
14+
*
1515
*/
16+
17+
using System;
1618
using MongoDB.Bson;
19+
using MongoDB.Driver.Core.Misc;
1720

1821
namespace MongoDB.Driver
1922
{
@@ -26,6 +29,7 @@ public sealed class InsertManyOptions
2629
private bool? _bypassDocumentValidation;
2730
private BsonValue _comment;
2831
private bool _isOrdered;
32+
private TimeSpan? _timeout;
2933

3034
// constructors
3135
/// <summary>
@@ -63,5 +67,14 @@ public bool IsOrdered
6367
get { return _isOrdered; }
6468
set { _isOrdered = value; }
6569
}
70+
71+
/// <summary>
72+
/// Gets or sets the operation timeout.
73+
/// </summary>
74+
public TimeSpan? Timeout
75+
{
76+
get => _timeout;
77+
set => _timeout = Ensure.IsNullOrValidTimeout(value, nameof(Timeout));
78+
}
6679
}
6780
}

src/MongoDB.Driver/MongoCollectionBase.cs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ private DeleteResult DeleteMany(FilterDefinition<TDocument> filter, DeleteOption
164164
var bulkWriteOptions = new BulkWriteOptions
165165
{
166166
Comment = options.Comment,
167-
Let = options.Let
167+
Let = options.Let,
168+
Timeout = options.Timeout
168169
};
169170
var result = bulkWriteFunc(new[] { model }, bulkWriteOptions);
170171
return DeleteResult.FromCore(result);
@@ -205,7 +206,8 @@ private async Task<DeleteResult> DeleteManyAsync(FilterDefinition<TDocument> fil
205206
var bulkWriteOptions = new BulkWriteOptions
206207
{
207208
Comment = options.Comment,
208-
Let = options.Let
209+
Let = options.Let,
210+
Timeout = options.Timeout
209211
};
210212
var result = await bulkWriteFuncAsync(new[] { model }, bulkWriteOptions).ConfigureAwait(false);
211213
return DeleteResult.FromCore(result);
@@ -246,7 +248,8 @@ private DeleteResult DeleteOne(FilterDefinition<TDocument> filter, DeleteOptions
246248
var bulkWriteOptions = new BulkWriteOptions
247249
{
248250
Comment = options.Comment,
249-
Let = options.Let
251+
Let = options.Let,
252+
Timeout = options.Timeout
250253
};
251254
var result = bulkWrite(new[] { model }, bulkWriteOptions);
252255
return DeleteResult.FromCore(result);
@@ -287,7 +290,8 @@ private async Task<DeleteResult> DeleteOneAsync(FilterDefinition<TDocument> filt
287290
var bulkWriteOptions = new BulkWriteOptions
288291
{
289292
Comment = options.Comment,
290-
Let = options.Let
293+
Let = options.Let,
294+
Timeout = options.Timeout
291295
};
292296
var result = await bulkWriteAsync(new[] { model }, bulkWriteOptions).ConfigureAwait(false);
293297
return DeleteResult.FromCore(result);
@@ -436,7 +440,7 @@ private void InsertOne(TDocument document, InsertOneOptions options, Action<IEnu
436440
{
437441
BypassDocumentValidation = options.BypassDocumentValidation,
438442
Comment = options.Comment,
439-
Timeout = options.Timeout,
443+
Timeout = options.Timeout
440444
};
441445
bulkWrite(new[] { model }, bulkWriteOptions);
442446
}
@@ -472,7 +476,8 @@ private async Task InsertOneAsync(TDocument document, InsertOneOptions options,
472476
var bulkWriteOptions = options == null ? null : new BulkWriteOptions
473477
{
474478
BypassDocumentValidation = options.BypassDocumentValidation,
475-
Comment = options.Comment
479+
Comment = options.Comment,
480+
Timeout = options.Timeout
476481
};
477482
await bulkWriteAsync(new[] { model }, bulkWriteOptions).ConfigureAwait(false);
478483
}
@@ -501,7 +506,8 @@ private void InsertMany(IEnumerable<TDocument> documents, InsertManyOptions opti
501506
{
502507
BypassDocumentValidation = options.BypassDocumentValidation,
503508
Comment = options.Comment,
504-
IsOrdered = options.IsOrdered
509+
IsOrdered = options.IsOrdered,
510+
Timeout = options.Timeout
505511
};
506512
bulkWrite(models, bulkWriteOptions);
507513
}
@@ -525,7 +531,8 @@ private Task InsertManyAsync(IEnumerable<TDocument> documents, InsertManyOptions
525531
{
526532
BypassDocumentValidation = options.BypassDocumentValidation,
527533
Comment = options.Comment,
528-
IsOrdered = options.IsOrdered
534+
IsOrdered = options.IsOrdered,
535+
Timeout = options.Timeout
529536
};
530537
return bulkWriteAsync(models, bulkWriteOptions);
531538
}
@@ -599,7 +606,8 @@ private ReplaceOneResult ReplaceOne(FilterDefinition<TDocument> filter, TDocumen
599606
{
600607
BypassDocumentValidation = options.BypassDocumentValidation,
601608
Comment = options.Comment,
602-
Let = options.Let
609+
Let = options.Let,
610+
Timeout = options.Timeout
603611
};
604612
var result = bulkWrite(new[] { model }, bulkWriteOptions);
605613
return ReplaceOneResult.FromCore(result);
@@ -657,7 +665,8 @@ private async Task<ReplaceOneResult> ReplaceOneAsync(FilterDefinition<TDocument>
657665
{
658666
BypassDocumentValidation = options.BypassDocumentValidation,
659667
Comment = options.Comment,
660-
Let = options.Let
668+
Let = options.Let,
669+
Timeout = options.Timeout
661670
};
662671
var result = await bulkWriteAsync(new[] { model }, bulkWriteOptions).ConfigureAwait(false);
663672
return ReplaceOneResult.FromCore(result);
@@ -698,7 +707,8 @@ private UpdateResult UpdateMany(FilterDefinition<TDocument> filter, UpdateDefini
698707
{
699708
BypassDocumentValidation = options.BypassDocumentValidation,
700709
Comment = options.Comment,
701-
Let = options.Let
710+
Let = options.Let,
711+
Timeout = options.Timeout
702712
};
703713
var result = bulkWrite(new[] { model }, bulkWriteOptions);
704714
return UpdateResult.FromCore(result);
@@ -739,7 +749,8 @@ private async Task<UpdateResult> UpdateManyAsync(FilterDefinition<TDocument> fil
739749
{
740750
BypassDocumentValidation = options.BypassDocumentValidation,
741751
Comment = options.Comment,
742-
Let = options.Let
752+
Let = options.Let,
753+
Timeout = options.Timeout
743754
};
744755
var result = await bulkWriteAsync(new[] { model }, bulkWriteOptions).ConfigureAwait(false);
745756
return UpdateResult.FromCore(result);
@@ -785,7 +796,8 @@ private UpdateResult UpdateOne(FilterDefinition<TDocument> filter, UpdateDefinit
785796
{
786797
BypassDocumentValidation = options.BypassDocumentValidation,
787798
Comment = options.Comment,
788-
Let = options.Let
799+
Let = options.Let,
800+
Timeout = options.Timeout
789801
};
790802
var result = bulkWrite(new[] { model }, bulkWriteOptions);
791803
return UpdateResult.FromCore(result);
@@ -831,7 +843,8 @@ private async Task<UpdateResult> UpdateOneAsync(FilterDefinition<TDocument> filt
831843
{
832844
BypassDocumentValidation = options.BypassDocumentValidation,
833845
Comment = options.Comment,
834-
Let = options.Let
846+
Let = options.Let,
847+
Timeout = options.Timeout
835848
};
836849
var result = await bulkWriteAsync(new[] { model }, bulkWriteOptions).ConfigureAwait(false);
837850
return UpdateResult.FromCore(result);

src/MongoDB.Driver/ReplaceOptions.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
using System;
1717
using MongoDB.Bson;
18+
using MongoDB.Driver.Core.Misc;
1819

1920
namespace MongoDB.Driver
2021
{
@@ -49,7 +50,8 @@ internal static ReplaceOptions From(UpdateOptions updateOptions)
4950
Collation = updateOptions.Collation,
5051
Hint = updateOptions.Hint,
5152
IsUpsert = updateOptions.IsUpsert,
52-
Let = updateOptions.Let
53+
Let = updateOptions.Let,
54+
Timeout = updateOptions.Timeout
5355
};
5456
}
5557
}
@@ -62,6 +64,7 @@ internal static ReplaceOptions From(UpdateOptions updateOptions)
6264
private BsonValue _hint;
6365
private bool _isUpsert;
6466
private BsonDocument _let;
67+
private TimeSpan? _timeout;
6568

6669
// properties
6770
/// <summary>
@@ -117,6 +120,15 @@ public BsonDocument Let
117120
get { return _let; }
118121
set { _let = value; }
119122
}
123+
124+
/// <summary>
125+
/// Gets or sets the operation timeout.
126+
/// </summary>
127+
public TimeSpan? Timeout
128+
{
129+
get => _timeout;
130+
set => _timeout = Ensure.IsNullOrValidTimeout(value, nameof(Timeout));
131+
}
120132
}
121133

122134
/// <summary>

src/MongoDB.Driver/UpdateOptions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
* limitations under the License.
1414
*/
1515

16+
using System;
1617
using System.Collections.Generic;
1718
using MongoDB.Bson;
19+
using MongoDB.Driver.Core.Misc;
1820

1921
namespace MongoDB.Driver
2022
{
@@ -31,6 +33,7 @@ public class UpdateOptions
3133
private BsonValue _hint;
3234
private bool _isUpsert;
3335
private BsonDocument _let;
36+
private TimeSpan? _timeout;
3437

3538
// properties
3639
/// <summary>
@@ -98,6 +101,15 @@ public BsonDocument Let
98101
get { return _let; }
99102
set { _let = value; }
100103
}
104+
105+
/// <summary>
106+
/// Gets or sets the operation timeout.
107+
/// </summary>
108+
public TimeSpan? Timeout
109+
{
110+
get => _timeout;
111+
set => _timeout = Ensure.IsNullOrValidTimeout(value, nameof(Timeout));
112+
}
101113
}
102114

103115
/// <summary>

0 commit comments

Comments
 (0)