Docs Menu

Connection Methods


For details on specific methods, including syntax and examples, click on the specific method to go to its reference page.

Connects to a MongoDB instance and to a specified database on that instance.
Creates a new connection object.
Returns a database object.
Returns the current read preference mode for the MongoDB connection.
Returns the read preference tag set for the MongoDB connection.

Indicates whether the MongoDB connection allows read operations on secondary members.

Indicates whether causal consistency is enabled on the connection object.
Enables or disables causal consistency on the connection object.
Sets the read preference for the MongoDB connection.

Allows read operations on secondary members for the MongoDB connection.

Starts a session on the connection object.
Opens a change stream cursor for a deployment to report on all its non-system collections across all its databases, excluding the internal admin, local, and config databases.
The session object.
The options object for the session.
Give Feedback
MongoDB logo
© 2021 MongoDB, Inc.


  • Careers
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.