@@ -12,7 +12,7 @@ const evaluate = require('./db_ops').evaluate;
1212const executeCommand = require ( './db_ops' ) . executeCommand ;
1313const executeDbAdminCommand = require ( './db_ops' ) . executeDbAdminCommand ;
1414const formattedOrderClause = require ( '../utils' ) . formattedOrderClause ;
15- const getReadPreference = require ( '../utils' ) . getReadPreference ;
15+ const resolveReadPreference = require ( '../utils' ) . resolveReadPreference ;
1616const handleCallback = require ( '../utils' ) . handleCallback ;
1717const indexInformationDb = require ( './db_ops' ) . indexInformation ;
1818const isObject = require ( '../utils' ) . isObject ;
@@ -195,7 +195,7 @@ function count(coll, query, options, callback) {
195195 if ( hint ) cmd . hint = hint ;
196196
197197 // Ensure we have the right read preference inheritance
198- options = getReadPreference ( coll , options , coll . s . db ) ;
198+ options . readPreference = resolveReadPreference ( options , { db : coll . s . db , collection : coll } ) ;
199199
200200 // Do we have a readConcern specified
201201 decorateWithReadConcern ( cmd , coll , options ) ;
@@ -359,7 +359,7 @@ function distinct(coll, key, query, options, callback) {
359359
360360 options = Object . assign ( { } , options ) ;
361361 // Ensure we have the right read preference inheritance
362- options = getReadPreference ( coll , options , coll . s . db , coll ) ;
362+ options . readPreference = resolveReadPreference ( options , { db : coll . s . db , collection : coll } ) ;
363363
364364 // Add maxTimeMS if defined
365365 if ( typeof maxTimeMS === 'number' ) cmd . maxTimeMS = maxTimeMS ;
@@ -634,7 +634,7 @@ function geoHaystackSearch(coll, x, y, options, callback) {
634634
635635 options = Object . assign ( { } , options ) ;
636636 // Ensure we have the right read preference inheritance
637- options = getReadPreference ( coll , options , coll . s . db , coll ) ;
637+ options . readPreference = resolveReadPreference ( options , { db : coll . s . db , collection : coll } ) ;
638638
639639 // Do we have a readConcern specified
640640 decorateWithReadConcern ( commandObject , coll , options ) ;
@@ -694,7 +694,7 @@ function group(coll, keys, condition, initial, reduce, finalize, command, option
694694
695695 options = Object . assign ( { } , options ) ;
696696 // Ensure we have the right read preference inheritance
697- options = getReadPreference ( coll , options , coll . s . db , coll ) ;
697+ options . readPreference = resolveReadPreference ( options , { db : coll . s . db , collection : coll } ) ;
698698
699699 // Do we have a readConcern specified
700700 decorateWithReadConcern ( selector , coll , options ) ;
@@ -891,7 +891,7 @@ function mapReduce(coll, map, reduce, options, callback) {
891891 options = Object . assign ( { } , options ) ;
892892
893893 // Ensure we have the right read preference inheritance
894- options = getReadPreference ( coll , options , coll . s . db , coll ) ;
894+ options . readPreference = resolveReadPreference ( options , { db : coll . s . db , collection : coll } ) ;
895895
896896 // If we have a read preference and inline is not set as output fail hard
897897 if (
@@ -1280,7 +1280,7 @@ function stats(coll, options, callback) {
12801280
12811281 options = Object . assign ( { } , options ) ;
12821282 // Ensure we have the right read preference inheritance
1283- options = getReadPreference ( coll , options , coll . s . db , coll ) ;
1283+ options . readPreference = resolveReadPreference ( options , { db : coll . s . db , collection : coll } ) ;
12841284
12851285 // Execute the command
12861286 executeCommand ( coll . s . db , commandObject , options , callback ) ;
0 commit comments