- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
如何在 Mongoose 中查询时调用 SlaveOK?
例如,我有这个:
SiteModel.find({}, function(err, docs) { .... } );
我应该这样做吗???
SiteModel.slaveOK().find({}, function(err,docs) { ... } );
最佳答案
mongoose.Query.slaveOk
已被弃用,取而代之的是 mongoose.Query.read(readPreference)
。 docs
因此,迭代上面的示例:
Model
.where('age').gte(25)
.where('tags').in(['movie', 'music', 'art'])
.select('name', 'age', 'tags')
.skip(20)
.limit(10)
.asc('age')
.read('secondaryPreferred')
.hint({ age: 1, name: 1 })
.run(callback);
关于mongodb - 如何在 Mongoose 中运行 SlaveOk?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8364388/
假设我有 N 个服务器,每个服务器都作为 Web 服务器和副本集的 mongodb 成员运行。 我希望 slaveOk 读取首先由本地 mongodb 实例满足,而不是通过网络的远程机器。 文档说 s
如何在 Mongoose 中查询时调用 SlaveOK? 例如,我有这个: SiteModel.find({}, function(err, docs) { .... } ); 我应该这样做吗???
使用mongodb时,出现“not master and slaveok=false”错误,原因是secondary不允许读写。 因为系统中mongodb做了主备,主备切换了,也可能导致这个问题。
如何通过命令行在副本集中的辅助 mongodb 服务器中设置 rs.slaveOk()? 我尝试了以下方法: ${MONGO_HOME}/bin/mongo --port ${MONGO_PORT2}
官方文档我查了很多遍,里面有rs.slaveOK()函数,还有shell帮助文档。 rs.slaveOK()即使函数真的存在也无法使用。(发生错误) 这太奇怪了。这是为什么呢? 当我键入 rs.sla
我可以从“mongos”控制台发起查询,并查看读取命中初选。我可以成功执行 rs.slaveOk(); 然后触发相同的查询,并看到读取命中辅助节点。 问题是无论我尝试什么,我都无法在 Mongoid
我第一次尝试了 mongo 副本集。 我在 ec2 上使用 ubuntu 并启动了三个实例。 我使用了每个实例的私有(private) IP 地址。我选择了主要的,下面是代码。 mongo --hos
我第一次尝试了 mongo 副本集。 我在 ec2 上使用 ubuntu 并启动了三个实例。我使用了每个实例的私有(private) IP 地址。我选择了主要的,下面是代码。 mongo --host
我的 node.js 应用程序出现一个奇怪的错误 not master and slaveOk=false code 13435 我正在使用 mongoose 4.0.2 对 mongodb 3.0.
我正在运行一个复制的 mongoDB,我可以使用 mongo 毫无问题地连接到集合中的主数据库: bash-4.2$ mongo --port 25023 MongoDB shell version:
我是一名优秀的程序员,十分优秀!