@@ -142,8 +142,9 @@ func (coll *Collection) Database() *Database {
142
142
return coll .db
143
143
}
144
144
145
- // BulkWrite performs a bulk write operation. A custom context can be supplied to this method or nil to default to
146
- // context.Background().
145
+ // BulkWrite performs a bulk write operation.
146
+ //
147
+ // See https://docs.mongodb.com/manual/core/bulk-write-operations/.
147
148
func (coll * Collection ) BulkWrite (ctx context.Context , models []WriteModel ,
148
149
opts ... * options.BulkWriteOptions ) (* BulkWriteResult , error ) {
149
150
@@ -204,15 +205,7 @@ func (coll *Collection) BulkWrite(ctx context.Context, models []WriteModel,
204
205
}, nil
205
206
}
206
207
207
- // InsertOne inserts a single document into the collection. A user can supply
208
- // a custom context to this method, or nil to default to context.Background().
209
- //
210
- // This method uses TransformDocument to turn the document parameter into a
211
- // *bsonx.Document. See TransformDocument for the list of valid types for
212
- // document.
213
- //
214
- // TODO(skriptble): Determine if we should unwrap the value for the
215
- // InsertOneResult or just return the bsonx.Element or a bsonx.Value.
208
+ // InsertOne inserts a single document into the collection.
216
209
func (coll * Collection ) InsertOne (ctx context.Context , document interface {},
217
210
opts ... * options.InsertOneOptions ) (* InsertOneResult , error ) {
218
211
@@ -272,16 +265,7 @@ func (coll *Collection) InsertOne(ctx context.Context, document interface{},
272
265
return & InsertOneResult {InsertedID : insertedID }, err
273
266
}
274
267
275
- // InsertMany inserts the provided documents. A user can supply a custom context to this
276
- // method.
277
- //
278
- // Currently, batching is not implemented for this operation. Because of this, extremely large
279
- // sets of documents will not fit into a single BSON document to be sent to the server, so the
280
- // operation will fail.
281
- //
282
- // This method uses TransformDocument to turn the documents parameter into a
283
- // *bsonx.Document. See TransformDocument for the list of valid types for
284
- // documents.
268
+ // InsertMany inserts the provided documents.
285
269
func (coll * Collection ) InsertMany (ctx context.Context , documents []interface {},
286
270
opts ... * options.InsertManyOptions ) (* InsertManyResult , error ) {
287
271
@@ -363,12 +347,7 @@ func (coll *Collection) InsertMany(ctx context.Context, documents []interface{},
363
347
return & InsertManyResult {InsertedIDs : result }, err
364
348
}
365
349
366
- // DeleteOne deletes a single document from the collection. A user can supply
367
- // a custom context to this method, or nil to default to context.Background().
368
- //
369
- // This method uses TransformDocument to turn the filter parameter into a
370
- // *bsonx.Document. See TransformDocument for the list of valid types for
371
- // filter.
350
+ // DeleteOne deletes a single document from the collection.
372
351
func (coll * Collection ) DeleteOne (ctx context.Context , filter interface {},
373
352
opts ... * options.DeleteOptions ) (* DeleteResult , error ) {
374
353
@@ -425,13 +404,7 @@ func (coll *Collection) DeleteOne(ctx context.Context, filter interface{},
425
404
return & DeleteResult {DeletedCount : int64 (res .N )}, err
426
405
}
427
406
428
- // DeleteMany deletes multiple documents from the collection. A user can
429
- // supply a custom context to this method, or nil to default to
430
- // context.Background().
431
- //
432
- // This method uses TransformDocument to turn the filter parameter into a
433
- // *bsonx.Document. See TransformDocument for the list of valid types for
434
- // filter.
407
+ // DeleteMany deletes multiple documents from the collection.
435
408
func (coll * Collection ) DeleteMany (ctx context.Context , filter interface {},
436
409
opts ... * options.DeleteOptions ) (* DeleteResult , error ) {
437
410
@@ -542,12 +515,7 @@ func (coll *Collection) updateOrReplaceOne(ctx context.Context, filter,
542
515
return res , err
543
516
}
544
517
545
- // UpdateOne updates a single document in the collection. A user can supply a
546
- // custom context to this method, or nil to default to context.Background().
547
- //
548
- // This method uses TransformDocument to turn the filter and update parameter
549
- // into a *bsonx.Document. See TransformDocument for the list of valid types for
550
- // filter and update.
518
+ // UpdateOne updates a single document in the collection.
551
519
func (coll * Collection ) UpdateOne (ctx context.Context , filter interface {}, update interface {},
552
520
opts ... * options.UpdateOptions ) (* UpdateResult , error ) {
553
521
@@ -579,12 +547,7 @@ func (coll *Collection) UpdateOne(ctx context.Context, filter interface{}, updat
579
547
return coll .updateOrReplaceOne (ctx , f , u , sess , opts ... )
580
548
}
581
549
582
- // UpdateMany updates multiple documents in the collection. A user can supply
583
- // a custom context to this method, or nil to default to context.Background().
584
- //
585
- // This method uses TransformDocument to turn the filter and update parameter
586
- // into a *bsonx.Document. See TransformDocument for the list of valid types for
587
- // filter and update.
550
+ // UpdateMany updates multiple documents in the collection.
588
551
func (coll * Collection ) UpdateMany (ctx context.Context , filter interface {}, update interface {},
589
552
opts ... * options.UpdateOptions ) (* UpdateResult , error ) {
590
553
@@ -664,12 +627,7 @@ func (coll *Collection) UpdateMany(ctx context.Context, filter interface{}, upda
664
627
return res , err
665
628
}
666
629
667
- // ReplaceOne replaces a single document in the collection. A user can supply
668
- // a custom context to this method, or nil to default to context.Background().
669
- //
670
- // This method uses TransformDocument to turn the filter and replacement
671
- // parameter into a *bsonx.Document. See TransformDocument for the list of
672
- // valid types for filter and replacement.
630
+ // ReplaceOne replaces a single document in the collection.
673
631
func (coll * Collection ) ReplaceOne (ctx context.Context , filter interface {},
674
632
replacement interface {}, opts ... * options.ReplaceOptions ) (* UpdateResult , error ) {
675
633
@@ -710,14 +668,9 @@ func (coll *Collection) ReplaceOne(ctx context.Context, filter interface{},
710
668
return coll .updateOrReplaceOne (ctx , f , r , sess , updateOptions ... )
711
669
}
712
670
713
- // Aggregate runs an aggregation framework pipeline. A user can supply a custom context to
714
- // this method.
671
+ // Aggregate runs an aggregation framework pipeline.
715
672
//
716
673
// See https://docs.mongodb.com/manual/aggregation/.
717
- //
718
- // This method uses TransformDocument to turn the pipeline parameter into a
719
- // *bsonx.Document. See TransformDocument for the list of valid types for
720
- // pipeline.
721
674
func (coll * Collection ) Aggregate (ctx context.Context , pipeline interface {},
722
675
opts ... * options.AggregateOptions ) (Cursor , error ) {
723
676
@@ -774,12 +727,7 @@ func (coll *Collection) Aggregate(ctx context.Context, pipeline interface{},
774
727
return cursor , replaceTopologyErr (err )
775
728
}
776
729
777
- // Count gets the number of documents matching the filter. A user can supply a
778
- // custom context to this method, or nil to default to context.Background().
779
- //
780
- // This method uses TransformDocument to turn the filter parameter into a
781
- // *bsonx.Document. See TransformDocument for the list of valid types for
782
- // filter.
730
+ // Count gets the number of documents matching the filter.
783
731
func (coll * Collection ) Count (ctx context.Context , filter interface {},
784
732
opts ... * options.CountOptions ) (int64 , error ) {
785
733
@@ -827,11 +775,7 @@ func (coll *Collection) Count(ctx context.Context, filter interface{},
827
775
return count , replaceTopologyErr (err )
828
776
}
829
777
830
- // CountDocuments gets the number of documents matching the filter. A user can supply a
831
- // custom context to this method, or nil to default to context.Background().
832
- //
833
- // This method uses countDocumentsAggregatePipeline to turn the filter parameter and options
834
- // into aggregate pipeline.
778
+ // CountDocuments gets the number of documents matching the filter.
835
779
func (coll * Collection ) CountDocuments (ctx context.Context , filter interface {},
836
780
opts ... * options.CountOptions ) (int64 , error ) {
837
781
@@ -930,12 +874,7 @@ func (coll *Collection) EstimatedDocumentCount(ctx context.Context,
930
874
}
931
875
932
876
// Distinct finds the distinct values for a specified field across a single
933
- // collection. A user can supply a custom context to this method, or nil to
934
- // default to context.Background().
935
- //
936
- // This method uses TransformDocument to turn the filter parameter into a
937
- // *bsonx.Document. See TransformDocument for the list of valid types for
938
- // filter.
877
+ // collection.
939
878
func (coll * Collection ) Distinct (ctx context.Context , fieldName string , filter interface {},
940
879
opts ... * options.DistinctOptions ) ([]interface {}, error ) {
941
880
@@ -990,12 +929,7 @@ func (coll *Collection) Distinct(ctx context.Context, fieldName string, filter i
990
929
return res .Values , nil
991
930
}
992
931
993
- // Find finds the documents matching a model. A user can supply a custom context to this
994
- // method.
995
- //
996
- // This method uses TransformDocument to turn the filter parameter into a
997
- // *bsonx.Document. See TransformDocument for the list of valid types for
998
- // filter.
932
+ // Find finds the documents matching a model.
999
933
func (coll * Collection ) Find (ctx context.Context , filter interface {},
1000
934
opts ... * options.FindOptions ) (Cursor , error ) {
1001
935
@@ -1047,13 +981,7 @@ func (coll *Collection) Find(ctx context.Context, filter interface{},
1047
981
return cursor , replaceTopologyErr (err )
1048
982
}
1049
983
1050
- // FindOne returns up to one document that matches the model. A user can
1051
- // supply a custom context to this method, or nil to default to
1052
- // context.Background().
1053
- //
1054
- // This method uses TransformDocument to turn the filter parameter into a
1055
- // *bsonx.Document. See TransformDocument for the list of valid types for
1056
- // filter.
984
+ // FindOne returns up to one document that matches the model.
1057
985
func (coll * Collection ) FindOne (ctx context.Context , filter interface {},
1058
986
opts ... * options.FindOneOptions ) * DocumentResult {
1059
987
@@ -1132,14 +1060,7 @@ func (coll *Collection) FindOne(ctx context.Context, filter interface{},
1132
1060
}
1133
1061
1134
1062
// FindOneAndDelete find a single document and deletes it, returning the
1135
- // original in result. The document to return may be nil.
1136
- //
1137
- // A user can supply a custom context to this method, or nil to default to
1138
- // context.Background().
1139
- //
1140
- // This method uses TransformDocument to turn the filter parameter into a
1141
- // *bsonx.Document. See TransformDocument for the list of valid types for
1142
- // filter.
1063
+ // original in result.
1143
1064
func (coll * Collection ) FindOneAndDelete (ctx context.Context , filter interface {},
1144
1065
opts ... * options.FindOneAndDeleteOptions ) * DocumentResult {
1145
1066
@@ -1195,14 +1116,7 @@ func (coll *Collection) FindOneAndDelete(ctx context.Context, filter interface{}
1195
1116
}
1196
1117
1197
1118
// FindOneAndReplace finds a single document and replaces it, returning either
1198
- // the original or the replaced document. The document to return may be nil.
1199
- //
1200
- // A user can supply a custom context to this method, or nil to default to
1201
- // context.Background().
1202
- //
1203
- // This method uses TransformDocument to turn the filter and replacement
1204
- // parameter into a *bsonx.Document. See TransformDocument for the list of
1205
- // valid types for filter and replacement.
1119
+ // the original or the replaced document.
1206
1120
func (coll * Collection ) FindOneAndReplace (ctx context.Context , filter interface {},
1207
1121
replacement interface {}, opts ... * options.FindOneAndReplaceOptions ) * DocumentResult {
1208
1122
@@ -1264,14 +1178,7 @@ func (coll *Collection) FindOneAndReplace(ctx context.Context, filter interface{
1264
1178
}
1265
1179
1266
1180
// FindOneAndUpdate finds a single document and updates it, returning either
1267
- // the original or the updated. The document to return may be nil.
1268
- //
1269
- // A user can supply a custom context to this method, or nil to default to
1270
- // context.Background().
1271
- //
1272
- // This method uses TransformDocument to turn the filter and update parameter
1273
- // into a *bsonx.Document. See TransformDocument for the list of valid types for
1274
- // filter and update.
1181
+ // the original or the updated.
1275
1182
func (coll * Collection ) FindOneAndUpdate (ctx context.Context , filter interface {},
1276
1183
update interface {}, opts ... * options.FindOneAndUpdateOptions ) * DocumentResult {
1277
1184
@@ -1333,6 +1240,7 @@ func (coll *Collection) FindOneAndUpdate(ctx context.Context, filter interface{}
1333
1240
}
1334
1241
1335
1242
// Watch returns a change stream cursor used to receive notifications of changes to the collection.
1243
+ //
1336
1244
// This method is preferred to running a raw aggregation with a $changeStream stage because it
1337
1245
// supports resumability in the case of some errors.
1338
1246
func (coll * Collection ) Watch (ctx context.Context , pipeline interface {},
0 commit comments