node.js - how to set read Preference secondary using mongoclient in nodejs mongodb driver? -
i using mongodb replica set. have following config : { "members": [ { "host": "db1.example.com", "port": "27017" }, { "host": "db2.example.com", "port": "27017" } ] } i connecting db name myapplicationdb using following nodejs code : using mongodb driver version 1.4.38. var mongoclient = require('mongodb').mongoclient; var server = require('mongodb').server; var url = 'mongodb://'; var options = { server: { slaveok: true, readpreference: server.read_secondary, socketoptions: {"connecttimeoutms": 30000} }, db: { readpreference: server.read_secondary }, replset: { rs_name: "replicaname", readpreference: server.read_secondary } } members.fo...