Compatibility Changes with Legacy
The following behaviors in
mongosh affect compatibility with
operations performed in the legacy
The following shell methods are deprecated in
mongosh. Instead, use
the methods listed in the Alternative Resources column.
No longer required. See Read Operations on a Secondary Node.
Read Preference Behavior¶
Read Operations on a Secondary Node¶
mongosh to connect directly to a secondary
replica set member, you do not have to explicitly enable secondary
You can read from a secondary member if you specify a read preference of either:
To specify a read preference, you can use either:
readPreferenceconnection string option when connecting to the node.
mongo shell required running
enable secondary reads.
show Helper Methods¶
show helper methods always use a read preference of
primaryPreferred, even when a different read preference has been
specified for the operation:
In the legacy
mongo shell, these operations use the specified read
mongo shell stored numerical values as
mongosh numbers are stored as 32 bit integers,
Int32, or else as
Double if the value cannot be stored as an
MongoDB Shell continues to support the numeric types that are supported
mongo shell. However, the preferred types have been updated to
better align with the MongoDB drivers. See
mongosh Data Types for more information.
The preferred types for numeric variables are different in MongoDB
Shell than the types suggested in the legacy
mongo shell. The types
mongosh better align with the types used by the MongoDB Drivers.
Data types may be stored inconsistently if you connect to the same
collection using both
mongosh and the legacy
For more information on managing types, refer to the schema validation overview.