Connection Methods连接方法

Note注意

For details on specific methods, including syntax and examples, click on the specific method to go to its reference page.有关特定方法的详细信息,包括语法和示例,请单击特定方法以转到其参考页面。

Name名称Description描述
connect()Connects to a MongoDB instance and to a specified database on that instance.连接到MongoDB实例和该实例上的指定数据库。
Mongo()Creates a new connection object.创建新的连接对象。
Mongo.getDB()Returns a database object.返回数据库对象。
Mongo.getDBNames()Returns a list of databases.返回数据库列表。
Mongo.getDBs()Returns a document with a list of databases and metadata.返回包含数据库和元数据列表的文档。
Mongo.getReadPrefMode()Returns the current read preference mode for the MongoDB connection.返回MongoDB连接的当前读取首选项模式。
Mongo.getReadPrefTagSet()Returns the read preference tag set for the MongoDB connection.返回MongoDB连接的读取首选项标记集。
Mongo.setCausalConsistency()Enables or disables causal consistency on the connection object.启用或禁用连接对象上的因果一致性。
Mongo.setReadPref()Sets the read preference for the MongoDB connection.设置MongoDB连接的读取首选项
Mongo.startSession()Starts a session on the connection object.在连接对象上启动会话。
Mongo.watch()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.打开部署的更改流游标,以报告其所有数据库(不包括内部adminlocalconfig数据库)中的所有非system集合。
Session()The session object.会话对象。
SessionOptions()The options object for the session.会话的选项对象。
←  WriteResult.hasWriteConcernError()connect() →