ANNOUNCEMENT: Voyage AI joins MongoDB to power more accurate and trustworthy AI applications on Atlas.
Learn more
Docs 菜单

配置自定义增删改查设置

在此页面上

In this guide, you can learn about how the Java driver configures CRUD operations for MongoDatabase and MongoCollection instances.

读取偏好读关注写关注可控制驱动程序如何路由读操作,以及在连接 MongoDB 副本集时如何等待读写操作的确认。读取偏好和读关注适用于所有读操作;写关注适用于所有写操作。

有关更多信息,请参阅有关读取偏好读关注写关注的服务器文档。

By default, MongoDatabase and MongoCollection instances inherit their preferences and concerns from the MongoClient that accesses them. See the 配置客户端级增删改查设置 page for more information. However, you can apply custom settings to your individual databases and collections by using the following methods:

提示

withReadConcern()withReadPreference()withWriteConcern 方法创建具有所需偏好或关注的 MongoDatabaseMongoCollection 的新实例。调用该方法的 MongoDatabaseMongoCollection 将保留其原有的偏好和关注设置。

在此页面上