Docs Menu
Docs Home
/
MongoDB Manual
/ / /

Mongo.getReadPrefMode()

On this page

  • Compatibility
Mongo.getReadPrefMode()
Returns:The current read preference mode for the Mongo() connection object.

See Read Preference for an introduction to read preferences in MongoDB. Use getReadPrefMode() to return the current read preference mode, as in the following example:

db.getMongo().getReadPrefMode()

Use the following operation to return and print the current read preference mode:

print(db.getMongo().getReadPrefMode());

This operation will return one of the following read preference modes:

This method is available in deployments hosted in the following environments:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

Tip

See also:

Back

Mongo.getDBs

On this page