how to use conn.db.admin().command() on secondary in replica set?

26 views
Skip to first unread message

Vishal bheda

unread,
Feb 16, 2019, 3:56:02 AM2/16/19
to Mongoose Node.JS ODM

Trying to get results of command that I passed in admin command, but it throws me back a MongoError:not master and slaveOk=false


the commands work fine on shell after setting rs.slaveOk().

how to / where to set rs.slaveOk() using mongoose library, if it is?


conn = mongoose.createConnection(`mongodb://localhost:port`)
cmd = "someCommand"
conn.db.admin().command(cmd, (err, result)=>{
if(err){
console.error(err) 
}
resolve(result)
})
// MongoError: not master and slaveOk=false
Reply all
Reply to author
Forward
0 new messages