@@ -2133,13 +2133,25 @@ Query.prototype._optionsForExec = function(model) {
21332133 }
21342134 }
21352135
2136- if ( this . _mongooseOptions . populate && options . readPreference ) {
2137- for ( const pop of Object . values ( this . _mongooseOptions . populate ) ) {
2138- if ( pop . options ?. readPreference === undefined ) {
2139- if ( ! pop . options ) {
2140- pop . options = { } ;
2136+ if ( this . _mongooseOptions . populate ) {
2137+ if ( options . readPreference ) {
2138+ for ( const pop of Object . values ( this . _mongooseOptions . populate ) ) {
2139+ if ( pop . options ?. readPreference === undefined ) {
2140+ if ( ! pop . options ) {
2141+ pop . options = { } ;
2142+ }
2143+ pop . options . readPreference = options . readPreference ;
2144+ }
2145+ }
2146+ }
2147+ if ( options . readConcern ) {
2148+ for ( const pop of Object . values ( this . _mongooseOptions . populate ) ) {
2149+ if ( pop . options ?. readConcern === undefined ) {
2150+ if ( ! pop . options ) {
2151+ pop . options = { } ;
2152+ }
2153+ pop . options . readConcern = options . readConcern ;
21412154 }
2142- pop . options . readPreference = options . readPreference ;
21432155 }
21442156 }
21452157 }
@@ -4929,18 +4941,6 @@ Query.prototype.populate = function() {
49294941
49304942 const res = utils . populate . apply ( null , args ) ;
49314943
4932- // Propagate readConcern from parent query, unless one already specified. Read pref propagated separately
4933- if ( this . options != null ) {
4934- const readConcern = this . options . readConcern ;
4935-
4936- for ( const populateOptions of res ) {
4937- if ( readConcern != null && ( populateOptions && populateOptions . options && populateOptions . options . readConcern ) == null ) {
4938- populateOptions . options = populateOptions . options || { } ;
4939- populateOptions . options . readConcern = readConcern ;
4940- }
4941- }
4942- }
4943-
49444944 const opts = this . _mongooseOptions ;
49454945
49464946 if ( opts . lean != null ) {
0 commit comments