com.mongodb.Mongo.addOption()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(1.3k)|赞(0)|评价(0)|浏览(218)

本文整理了Java中com.mongodb.Mongo.addOption()方法的一些代码示例,展示了Mongo.addOption()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mongo.addOption()方法的具体详情如下:
包路径:com.mongodb.Mongo
类名称:Mongo
方法名:addOption

Mongo.addOption介绍

[英]Add the default query option for reads operations executed on any DBCollection created indirectly from this instance, via a DB instance created from #getDB(String).

Note that changes to query options made via this method will NOT affect com.mongodb.client.MongoDatabase instances created via MongoClient#getDatabase(String)
[中]为通过#getDB(String)创建的DB实例间接从此实例创建的任何DBCollection上执行的读取操作添加默认查询选项。
请注意,通过此方法对查询选项所做的更改不会影响com。mongodb。客户通过MongoClient#getDatabase(字符串)创建的MongoDatabase实例

代码示例

代码示例来源:origin: org.mongodb/mongo-java-driver

/**
 * Makes it possible to run read queries on secondary nodes
 *
 * @see ReadPreference#secondaryPreferred()
 * @deprecated Replaced with {@code ReadPreference.secondaryPreferred()}
 */
@SuppressWarnings("deprecation")
@Deprecated
public void slaveOk() {
  addOption(Bytes.QUERYOPTION_SLAVEOK);
}

代码示例来源:origin: org.mongodb/mongodb-driver

/**
 * Makes it possible to run read queries on secondary nodes
 *
 * @see ReadPreference#secondaryPreferred()
 * @deprecated Replaced with {@code ReadPreference.secondaryPreferred()}
 */
@SuppressWarnings("deprecation")
@Deprecated
public void slaveOk() {
  addOption(Bytes.QUERYOPTION_SLAVEOK);
}

相关文章