@@ -95,6 +95,7 @@ pub enum CursorType {
95
95
96
96
/// Specifies the options to a
97
97
/// [`Collection::insert_one`](../struct.Collection.html#method.insert_one) operation.
98
+ #[ skip_serializing_none]
98
99
#[ derive( Clone , Debug , Default , Deserialize , TypedBuilder ) ]
99
100
#[ serde( rename_all = "camelCase" ) ]
100
101
#[ builder( field_defaults( default , setter( into) ) ) ]
@@ -105,6 +106,12 @@ pub struct InsertOneOptions {
105
106
106
107
/// The write concern for the operation.
107
108
pub write_concern : Option < WriteConcern > ,
109
+
110
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
111
+ /// database profiler, currentOp and logs.
112
+ ///
113
+ /// This option is only available on server versions 4.4+.
114
+ pub comment : Option < Bson > ,
108
115
}
109
116
110
117
/// Specifies the options to a
@@ -127,6 +134,12 @@ pub struct InsertManyOptions {
127
134
/// The write concern for the operation.
128
135
#[ serde( skip_deserializing) ]
129
136
pub write_concern : Option < WriteConcern > ,
137
+
138
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
139
+ /// database profiler, currentOp and logs.
140
+ ///
141
+ /// This option is only available on server versions 4.4+.
142
+ pub comment : Option < Bson > ,
130
143
}
131
144
132
145
impl InsertManyOptions {
@@ -135,6 +148,7 @@ impl InsertManyOptions {
135
148
bypass_document_validation : options. bypass_document_validation ,
136
149
ordered : None ,
137
150
write_concern : options. write_concern ,
151
+ comment : options. comment ,
138
152
}
139
153
}
140
154
}
@@ -180,6 +194,7 @@ impl From<Vec<Document>> for UpdateModifications {
180
194
/// Specifies the options to a
181
195
/// [`Collection::update_one`](../struct.Collection.html#method.update_one) or
182
196
/// [`Collection::update_many`](../struct.Collection.html#method.update_many) operation.
197
+ #[ skip_serializing_none]
183
198
#[ derive( Clone , Debug , Default , Deserialize , TypedBuilder ) ]
184
199
#[ serde( rename_all = "camelCase" ) ]
185
200
#[ builder( field_defaults( default , setter( into) ) ) ]
@@ -219,6 +234,12 @@ pub struct UpdateOptions {
219
234
/// Only available in MongoDB 5.0+.
220
235
#[ serde( rename = "let" ) ]
221
236
pub let_vars : Option < Document > ,
237
+
238
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
239
+ /// database profiler, currentOp and logs.
240
+ ///
241
+ /// This option is only available on server versions 4.4+.
242
+ pub comment : Option < Bson > ,
222
243
}
223
244
224
245
impl UpdateOptions {
@@ -230,13 +251,15 @@ impl UpdateOptions {
230
251
write_concern : options. write_concern ,
231
252
collation : options. collation ,
232
253
let_vars : options. let_vars ,
254
+ comment : options. comment ,
233
255
..Default :: default ( )
234
256
}
235
257
}
236
258
}
237
259
238
260
/// Specifies the options to a
239
261
/// [`Collection::replace_one`](../struct.Collection.html#method.replace_one) operation.
262
+ #[ skip_serializing_none]
240
263
#[ derive( Clone , Debug , Default , Deserialize , TypedBuilder ) ]
241
264
#[ serde( rename_all = "camelCase" ) ]
242
265
#[ builder( field_defaults( default , setter( into) ) ) ]
@@ -270,6 +293,12 @@ pub struct ReplaceOptions {
270
293
/// Only available in MongoDB 5.0+.
271
294
#[ serde( rename = "let" ) ]
272
295
pub let_vars : Option < Document > ,
296
+
297
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
298
+ /// database profiler, currentOp and logs.
299
+ ///
300
+ /// This option is only available on server versions 4.4+.
301
+ pub comment : Option < Bson > ,
273
302
}
274
303
275
304
/// Specifies the options to a
@@ -301,11 +330,18 @@ pub struct DeleteOptions {
301
330
/// Only available in MongoDB 5.0+.
302
331
#[ serde( rename = "let" ) ]
303
332
pub let_vars : Option < Document > ,
333
+
334
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
335
+ /// database profiler, currentOp and logs.
336
+ ///
337
+ /// This option is only available on server versions 4.4+.
338
+ pub comment : Option < Bson > ,
304
339
}
305
340
306
341
/// Specifies the options to a
307
342
/// [`Collection::find_one_and_delete`](../struct.Collection.html#method.find_one_and_delete)
308
343
/// operation.
344
+ #[ skip_serializing_none]
309
345
#[ derive( Clone , Debug , Default , Deserialize , TypedBuilder ) ]
310
346
#[ serde( rename_all = "camelCase" ) ]
311
347
#[ builder( field_defaults( default , setter( into) ) ) ]
@@ -343,11 +379,18 @@ pub struct FindOneAndDeleteOptions {
343
379
/// Only available in MongoDB 5.0+.
344
380
#[ serde( rename = "let" ) ]
345
381
pub let_vars : Option < Document > ,
382
+
383
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
384
+ /// database profiler, currentOp and logs.
385
+ ///
386
+ /// This option is only available on server versions 4.4+.
387
+ pub comment : Option < Bson > ,
346
388
}
347
389
348
390
/// Specifies the options to a
349
391
/// [`Collection::find_one_and_replace`](../struct.Collection.html#method.find_one_and_replace)
350
392
/// operation.
393
+ #[ skip_serializing_none]
351
394
#[ derive( Clone , Debug , Default , Deserialize , TypedBuilder ) ]
352
395
#[ builder( field_defaults( default , setter( into) ) ) ]
353
396
#[ serde( rename_all = "camelCase" ) ]
@@ -394,11 +437,18 @@ pub struct FindOneAndReplaceOptions {
394
437
/// Only available in MongoDB 5.0+.
395
438
#[ serde( rename = "let" ) ]
396
439
pub let_vars : Option < Document > ,
440
+
441
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
442
+ /// database profiler, currentOp and logs.
443
+ ///
444
+ /// This option is only available on server versions 4.4+.
445
+ pub comment : Option < Bson > ,
397
446
}
398
447
399
448
/// Specifies the options to a
400
449
/// [`Collection::find_one_and_update`](../struct.Collection.html#method.find_one_and_update)
401
450
/// operation.
451
+ #[ skip_serializing_none]
402
452
#[ derive( Clone , Debug , Default , Deserialize , TypedBuilder ) ]
403
453
#[ serde( rename_all = "camelCase" ) ]
404
454
#[ builder( field_defaults( default , setter( into) ) ) ]
@@ -451,6 +501,12 @@ pub struct FindOneAndUpdateOptions {
451
501
/// Only available in MongoDB 5.0+.
452
502
#[ serde( rename = "let" ) ]
453
503
pub let_vars : Option < Document > ,
504
+
505
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
506
+ /// database profiler, currentOp and logs.
507
+ ///
508
+ /// This option is only available on server versions 4.4+.
509
+ pub comment : Option < Bson > ,
454
510
}
455
511
456
512
/// Specifies the options to a [`Collection::aggregate`](../struct.Collection.html#method.aggregate)
@@ -486,10 +542,23 @@ pub struct AggregateOptions {
486
542
/// information on how to use this option.
487
543
pub collation : Option < Collation > ,
488
544
489
- /// Tags the query with an arbitrary string to help trace the operation through the database
490
- /// profiler, currentOp and logs.
545
+ /// Tags the query with an arbitrary string to help trace the operation through the
546
+ /// database profiler, currentOp and logs.
547
+ ///
548
+ /// If both this option and `comment_bson` are specified, `comment_bson` will take precedence.
549
+ // TODO RUST-1364: Update this field to be of type Option<Bson>
550
+ #[ serde( skip_serializing) ]
491
551
pub comment : Option < String > ,
492
552
553
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
554
+ /// database profiler, currentOp and logs.
555
+ ///
556
+ /// This option is only supported on server versions 4.4+. Use the `comment` option on
557
+ /// older server versions.
558
+ // TODO RUST-1364: Remove this field
559
+ #[ serde( rename( serialize = "comment" ) ) ]
560
+ pub comment_bson : Option < Bson > ,
561
+
493
562
/// The index to use for the operation.
494
563
pub hint : Option < Hint > ,
495
564
@@ -549,6 +618,7 @@ pub struct AggregateOptions {
549
618
550
619
/// Specifies the options to a
551
620
/// [`Collection::count_documents`](../struct.Collection.html#method.count_documents) operation.
621
+ #[ skip_serializing_none]
552
622
#[ derive( Clone , Debug , Default , Deserialize , TypedBuilder ) ]
553
623
#[ serde( rename_all = "camelCase" ) ]
554
624
#[ builder( field_defaults( default , setter( into) ) ) ]
@@ -587,6 +657,12 @@ pub struct CountOptions {
587
657
/// The level of the read concern.
588
658
#[ serde( skip_serializing) ]
589
659
pub read_concern : Option < ReadConcern > ,
660
+
661
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
662
+ /// database profiler, currentOp and logs.
663
+ ///
664
+ /// This option is only available on server versions 4.4+.
665
+ pub comment : Option < Bson > ,
590
666
}
591
667
592
668
// rustfmt tries to split the link up when it's all on one line, which breaks the link, so we wrap
@@ -624,10 +700,12 @@ pub struct EstimatedDocumentCountOptions {
624
700
#[ serde( skip_serializing) ]
625
701
pub read_concern : Option < ReadConcern > ,
626
702
627
- /// Tags the query with an arbitrary BSON object to help trace the operation through the
703
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
628
704
/// database profiler, currentOp and logs.
629
705
///
630
- /// This option is only available on server versions 4.4+.
706
+ /// This option is only supported on server versions 4.4+. The comment can be any [`Bson`]
707
+ /// value on server versions 4.4.14+. On server versions between 4.4.0 and 4.4.14, only
708
+ /// [`Bson::String`] values are supported.
631
709
pub comment : Option < Bson > ,
632
710
}
633
711
@@ -666,6 +744,12 @@ pub struct DistinctOptions {
666
744
/// See the [documentation](https://www.mongodb.com/docs/manual/reference/collation/) for more
667
745
/// information on how to use this option.
668
746
pub collation : Option < Collation > ,
747
+
748
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
749
+ /// database profiler, currentOp and logs.
750
+ ///
751
+ /// This option is only available on server versions 4.4+.
752
+ pub comment : Option < Bson > ,
669
753
}
670
754
671
755
/// Specifies the options to a [`Collection::find`](../struct.Collection.html#method.find)
@@ -694,10 +778,23 @@ pub struct FindOptions {
694
778
#[ serde( serialize_with = "bson_util::serialize_u32_option_as_i32" ) ]
695
779
pub batch_size : Option < u32 > ,
696
780
697
- /// Tags the query with an arbitrary string to help trace the operation through the database
698
- /// profiler, currentOp and logs.
781
+ /// Tags the query with an arbitrary string to help trace the operation through the
782
+ /// database profiler, currentOp and logs.
783
+ ///
784
+ /// If both this option and `comment_bson` are specified, `comment_bson` will take precedence.
785
+ // TODO RUST-1364: Update this field to be of type Option<Bson>
786
+ #[ serde( skip_serializing) ]
699
787
pub comment : Option < String > ,
700
788
789
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
790
+ /// database profiler, currentOp and logs.
791
+ ///
792
+ /// This option is only supported on server versions 4.4+. Use the `comment` option on
793
+ /// older server versions.
794
+ // TODO RUST-1364: Remove this field
795
+ #[ serde( rename( serialize = "comment" ) ) ]
796
+ pub comment_bson : Option < Bson > ,
797
+
701
798
/// The type of cursor to return.
702
799
#[ serde( skip) ]
703
800
pub cursor_type : Option < CursorType > ,
@@ -792,6 +889,7 @@ impl From<FindOneOptions> for FindOptions {
792
889
allow_partial_results : options. allow_partial_results ,
793
890
collation : options. collation ,
794
891
comment : options. comment ,
892
+ comment_bson : options. comment_bson ,
795
893
hint : options. hint ,
796
894
max : options. max ,
797
895
max_scan : options. max_scan ,
@@ -845,10 +943,21 @@ pub struct FindOneOptions {
845
943
/// information on how to use this option.
846
944
pub collation : Option < Collation > ,
847
945
848
- /// Tags the query with an arbitrary string to help trace the operation through the database
849
- /// profiler, currentOp and logs.
946
+ /// Tags the query with an arbitrary string value to help trace the operation through the
947
+ /// database profiler, currentOp and logs.
948
+ ///
949
+ /// If both this option and `comment_bson` are specified, `comment_bson` will take precedence.
950
+ // TODO RUST-1364: Update this field to be of type Option<Bson>
850
951
pub comment : Option < String > ,
851
952
953
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
954
+ /// database profiler, currentOp and logs.
955
+ ///
956
+ /// This option is only supported on server versions 4.4+. Use the `comment` option on
957
+ /// older server versions.
958
+ // TODO RUST-1364: Remove this field
959
+ pub comment_bson : Option < Bson > ,
960
+
852
961
/// The index to use for the operation.
853
962
pub hint : Option < Hint > ,
854
963
@@ -936,6 +1045,12 @@ pub struct CreateIndexOptions {
936
1045
937
1046
/// The write concern for the operation.
938
1047
pub write_concern : Option < WriteConcern > ,
1048
+
1049
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
1050
+ /// database profiler, currentOp and logs.
1051
+ ///
1052
+ /// This option is only available on server versions 4.4+.
1053
+ pub comment : Option < Bson > ,
939
1054
}
940
1055
941
1056
/// Specifies the options to a [`Collection::drop`](../struct.Collection.html#method.drop)
@@ -978,6 +1093,12 @@ pub struct DropIndexOptions {
978
1093
979
1094
/// The write concern for the operation.
980
1095
pub write_concern : Option < WriteConcern > ,
1096
+
1097
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
1098
+ /// database profiler, currentOp and logs.
1099
+ ///
1100
+ /// This option is only available on server versions 4.4+.
1101
+ pub comment : Option < Bson > ,
981
1102
}
982
1103
983
1104
/// Specifies the options to a
@@ -1003,6 +1124,12 @@ pub struct ListIndexesOptions {
1003
1124
/// The number of indexes the server should return per cursor batch.
1004
1125
#[ serde( default , skip_serializing) ]
1005
1126
pub batch_size : Option < u32 > ,
1127
+
1128
+ /// Tags the query with an arbitrary [`Bson`] value to help trace the operation through the
1129
+ /// database profiler, currentOp and logs.
1130
+ ///
1131
+ /// This option is only available on server versions 4.4+.
1132
+ pub comment : Option < Bson > ,
1006
1133
}
1007
1134
1008
1135
/// The minimum number of data-bearing voting replica set members (i.e. commit quorum), including
0 commit comments