@@ -610,6 +610,7 @@ func (coll *Collection) updateOrReplace(
610610 multi bool ,
611611 expectedRr returnResult ,
612612 checkDollarKey bool ,
613+ sort interface {},
613614 args * options.UpdateManyOptions ,
614615) (* UpdateResult , error ) {
615616
@@ -623,6 +624,7 @@ func (coll *Collection) updateOrReplace(
623624 filter : filter ,
624625 update : update ,
625626 hint : args .Hint ,
627+ sort : sort ,
626628 arrayFilters : args .ArrayFilters ,
627629 collation : args .Collation ,
628630 upsert : args .Upsert ,
@@ -775,7 +777,7 @@ func (coll *Collection) UpdateOne(
775777 Let : args .Let ,
776778 }
777779
778- return coll .updateOrReplace (ctx , f , update , false , rrOne , true , updateOptions )
780+ return coll .updateOrReplace (ctx , f , update , false , rrOne , true , args . Sort , updateOptions )
779781}
780782
781783// UpdateMany executes an update command to update documents in the collection.
@@ -811,7 +813,7 @@ func (coll *Collection) UpdateMany(
811813 return nil , fmt .Errorf ("failed to construct options from builder: %w" , err )
812814 }
813815
814- return coll .updateOrReplace (ctx , f , update , true , rrMany , true , args )
816+ return coll .updateOrReplace (ctx , f , update , true , rrMany , true , nil , args )
815817}
816818
817819// ReplaceOne executes an update command to replace at most one document in the collection.
@@ -865,7 +867,7 @@ func (coll *Collection) ReplaceOne(
865867 Comment : args .Comment ,
866868 }
867869
868- return coll .updateOrReplace (ctx , f , r , false , rrOne , false , updateOptions )
870+ return coll .updateOrReplace (ctx , f , r , false , rrOne , false , args . Sort , updateOptions )
869871}
870872
871873// Aggregate executes an aggregate command against the collection and returns a cursor over the resulting documents.
0 commit comments