Mongo.setReadPref(mode, tagSet) primaries and secondaries are treated equivalently. 读优先级策略
https://docs.mongodb.com/manual/reference/method/Mongo.setReadPref/#Mongo.setReadPref
Mongo.
setReadPref
(mode, tagSet)-
Call the
setReadPref()
method on aMongo
connection object to control how the client will route all queries to members of the replica set.Parameter Type Description mode
string One of the following read preference modes: primary
,primaryPreferred
,secondary
,secondaryPreferred
, ornearest
.tagSet
array Optional. A tag set used to specify custom read preference modes. For details, see Tag Sets.
https://docs.mongodb.com/manual/reference/read-preference/#nearest
The driver reads from a member whose network latency falls within the acceptable latency window. Reads in the nearest
mode do not consider whether a member is a primary or secondary when routing read operations: primaries and secondaries are treated equivalently. The read preference member selectiondocumentation describes the process in detail.