@@ -19,6 +19,7 @@ import (
1919 "go.mongodb.org/mongo-driver/v2/mongo"
2020 "go.mongodb.org/mongo-driver/v2/mongo/options"
2121 "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore"
22+ "go.mongodb.org/mongo-driver/v2/x/mongo/driver/xoptions"
2223)
2324
2425// This file contains helpers to execute collection operations.
@@ -75,6 +76,11 @@ func executeAggregate(ctx context.Context, operation *operation) (*operationResu
7576 pipeline = bsonutil .RawToInterfaces (bsonutil .RawArrayToDocuments (val .Array ())... )
7677 case "let" :
7778 opts .SetLet (val .Document ())
79+ case "rawData" :
80+ err = xoptions .SetInternalAggregateOptions (opts , key , val .Boolean ())
81+ if err != nil {
82+ return nil , err
83+ }
7884 default :
7985 return nil , fmt .Errorf ("unrecognized aggregate option %q" , key )
8086 }
@@ -125,6 +131,11 @@ func executeBulkWrite(ctx context.Context, operation *operation) (*operationResu
125131 }
126132 case "let" :
127133 opts .SetLet (val .Document ())
134+ case "rawData" :
135+ err = xoptions .SetInternalBulkWriteOptions (opts , key , val .Boolean ())
136+ if err != nil {
137+ return nil , err
138+ }
128139 default :
129140 return nil , fmt .Errorf ("unrecognized bulkWrite option %q" , key )
130141 }
@@ -202,6 +213,11 @@ func executeCountDocuments(ctx context.Context, operation *operation) (*operatio
202213 return nil , fmt .Errorf ("the maxTimeMS collection option is not supported" )
203214 case "skip" :
204215 opts .SetSkip (int64 (val .Int32 ()))
216+ case "rawData" :
217+ err = xoptions .SetInternalCountOptions (opts , key , val .Boolean ())
218+ if err != nil {
219+ return nil , err
220+ }
205221 default :
206222 return nil , fmt .Errorf ("unrecognized countDocuments option %q" , key )
207223 }
@@ -225,6 +241,7 @@ func executeCreateIndex(ctx context.Context, operation *operation) (*operationRe
225241
226242 var keys bson.Raw
227243 indexOpts := options .Index ()
244+ opts := options .CreateIndexes ()
228245
229246 elems , err := operation .Arguments .Elements ()
230247 if err != nil {
@@ -279,6 +296,11 @@ func executeCreateIndex(ctx context.Context, operation *operation) (*operationRe
279296 indexOpts .SetWeights (val .Document ())
280297 case "wildcardProjection" :
281298 indexOpts .SetWildcardProjection (val .Document ())
299+ case "rawData" :
300+ err = xoptions .SetInternalCreateIndexesOptions (opts , key , val .Boolean ())
301+ if err != nil {
302+ return nil , err
303+ }
282304 default :
283305 return nil , fmt .Errorf ("unrecognized createIndex option %q" , key )
284306 }
@@ -291,7 +313,8 @@ func executeCreateIndex(ctx context.Context, operation *operation) (*operationRe
291313 Keys : keys ,
292314 Options : indexOpts ,
293315 }
294- name , err := coll .Indexes ().CreateOne (ctx , model )
316+
317+ name , err := coll .Indexes ().CreateOne (ctx , model , opts )
295318 return newValueResult (bson .TypeString , bsoncore .AppendString (nil , name ), err ), nil
296319}
297320
@@ -433,6 +456,11 @@ func executeDeleteOne(ctx context.Context, operation *operation) (*operationResu
433456 opts .SetHint (hint )
434457 case "let" :
435458 opts .SetLet (val .Document ())
459+ case "rawData" :
460+ err = xoptions .SetInternalDeleteOneOptions (opts , key , val .Boolean ())
461+ if err != nil {
462+ return nil , err
463+ }
436464 default :
437465 return nil , fmt .Errorf ("unrecognized deleteOne option %q" , key )
438466 }
@@ -487,6 +515,11 @@ func executeDeleteMany(ctx context.Context, operation *operation) (*operationRes
487515 opts .SetHint (hint )
488516 case "let" :
489517 opts .SetLet (val .Document ())
518+ case "rawData" :
519+ err = xoptions .SetInternalDeleteManyOptions (opts , key , val .Boolean ())
520+ if err != nil {
521+ return nil , err
522+ }
490523 default :
491524 return nil , fmt .Errorf ("unrecognized deleteMany option %q" , key )
492525 }
@@ -545,6 +578,11 @@ func executeDistinct(ctx context.Context, operation *operation) (*operationResul
545578 // ensured an analogue exists, extend "skippedTestDescriptions" to avoid
546579 // this error.
547580 return nil , fmt .Errorf ("the maxTimeMS collection option is not supported" )
581+ case "rawData" :
582+ err = xoptions .SetInternalDistinctOptions (opts , key , val .Boolean ())
583+ if err != nil {
584+ return nil , err
585+ }
548586 default :
549587 return nil , fmt .Errorf ("unrecognized distinct option %q" , key )
550588 }
@@ -593,6 +631,11 @@ func executeDropIndex(ctx context.Context, operation *operation) (*operationResu
593631 // ensured an analogue exists, extend "skippedTestDescriptions" to avoid
594632 // this error.
595633 return nil , fmt .Errorf ("the maxTimeMS collection option is not supported" )
634+ case "rawData" :
635+ err = xoptions .SetInternalDropIndexesOptions (dropIndexOpts , key , val .Boolean ())
636+ if err != nil {
637+ return nil , err
638+ }
596639 default :
597640 return nil , fmt .Errorf ("unrecognized dropIndex option %q" , key )
598641 }
@@ -690,6 +733,11 @@ func executeEstimatedDocumentCount(ctx context.Context, operation *operation) (*
690733 // ensured an analogue exists, extend "skippedTestDescriptions" to avoid
691734 // this error.
692735 return nil , fmt .Errorf ("the maxTimeMS collection option is not supported" )
736+ case "rawData" :
737+ err = xoptions .SetInternalEstimatedDocumentCountOptions (opts , key , val .Boolean ())
738+ if err != nil {
739+ return nil , err
740+ }
693741 default :
694742 return nil , fmt .Errorf ("unrecognized estimatedDocumentCount option %q" , key )
695743 }
@@ -842,6 +890,11 @@ func executeFindOneAndDelete(ctx context.Context, operation *operation) (*operat
842890 opts .SetSort (val .Document ())
843891 case "let" :
844892 opts .SetLet (val .Document ())
893+ case "rawData" :
894+ err = xoptions .SetInternalFindOneAndDeleteOptions (opts , key , val .Boolean ())
895+ if err != nil {
896+ return nil , err
897+ }
845898 default :
846899 return nil , fmt .Errorf ("unrecognized findOneAndDelete option %q" , key )
847900 }
@@ -924,6 +977,11 @@ func executeFindOneAndReplace(ctx context.Context, operation *operation) (*opera
924977 opts .SetSort (val .Document ())
925978 case "upsert" :
926979 opts .SetUpsert (val .Boolean ())
980+ case "rawData" :
981+ err = xoptions .SetInternalFindOneAndReplaceOptions (opts , key , val .Boolean ())
982+ if err != nil {
983+ return nil , err
984+ }
927985 default :
928986 return nil , fmt .Errorf ("unrecognized findOneAndReplace option %q" , key )
929987 }
@@ -1016,6 +1074,11 @@ func executeFindOneAndUpdate(ctx context.Context, operation *operation) (*operat
10161074 }
10171075 case "upsert" :
10181076 opts .SetUpsert (val .Boolean ())
1077+ case "rawData" :
1078+ err = xoptions .SetInternalFindOneAndUpdateOptions (opts , key , val .Boolean ())
1079+ if err != nil {
1080+ return nil , err
1081+ }
10191082 default :
10201083 return nil , fmt .Errorf ("unrecognized findOneAndUpdate option %q" , key )
10211084 }
@@ -1062,6 +1125,11 @@ func executeInsertMany(ctx context.Context, operation *operation) (*operationRes
10621125 documents = bsonutil .RawToInterfaces (bsonutil .RawArrayToDocuments (val .Array ())... )
10631126 case "ordered" :
10641127 opts .SetOrdered (val .Boolean ())
1128+ case "rawData" :
1129+ err = xoptions .SetInternalInsertManyOptions (opts , key , val .Boolean ())
1130+ if err != nil {
1131+ return nil , err
1132+ }
10651133 default :
10661134 return nil , fmt .Errorf ("unrecognized insertMany option %q" , key )
10671135 }
@@ -1112,6 +1180,11 @@ func executeInsertOne(ctx context.Context, operation *operation) (*operationResu
11121180 opts .SetBypassDocumentValidation (val .Boolean ())
11131181 case "comment" :
11141182 opts .SetComment (val )
1183+ case "rawData" :
1184+ err = xoptions .SetInternalInsertOneOptions (opts , key , val .Boolean ())
1185+ if err != nil {
1186+ return nil , err
1187+ }
11151188 default :
11161189 return nil , fmt .Errorf ("unrecognized insertOne option %q" , key )
11171190 }
@@ -1156,6 +1229,11 @@ func executeListIndexes(ctx context.Context, operation *operation) (*operationRe
11561229 switch key {
11571230 case "batchSize" :
11581231 opts .SetBatchSize (val .Int32 ())
1232+ case "rawData" :
1233+ err = xoptions .SetInternalListIndexesOptions (opts , key , val .Boolean ())
1234+ if err != nil {
1235+ return nil , err
1236+ }
11591237 default :
11601238 return nil , fmt .Errorf ("unrecognized listIndexes option: %q" , key )
11611239 }
@@ -1302,6 +1380,11 @@ func executeReplaceOne(ctx context.Context, operation *operation) (*operationRes
13021380 opts .SetUpsert (val .Boolean ())
13031381 case "let" :
13041382 opts .SetLet (val .Document ())
1383+ case "rawData" :
1384+ err = xoptions .SetInternalReplaceOptions (opts , key , val .Boolean ())
1385+ if err != nil {
1386+ return nil , err
1387+ }
13051388 default :
13061389 return nil , fmt .Errorf ("unrecognized replaceOne option %q" , key )
13071390 }
@@ -1500,6 +1583,11 @@ func createFindCursor(ctx context.Context, operation *operation) (*cursorResult,
15001583 case "maxAwaitTimeMS" :
15011584 maxAwaitTimeMS := time .Duration (val .Int32 ()) * time .Millisecond
15021585 opts .SetMaxAwaitTime (maxAwaitTimeMS )
1586+ case "rawData" :
1587+ err = xoptions .SetInternalFindOptions (opts , key , val .Boolean ())
1588+ if err != nil {
1589+ return nil , err
1590+ }
15031591 default :
15041592 return nil , fmt .Errorf ("unrecognized find option %q" , key )
15051593 }
0 commit comments