Db.collection.find().count() need to still run rs.secondaryOk()

Hi,

I know it is not possible to initially query to a secondary node without executing rs.secondaryOk().

I already have a mongorc.js that contains “rs.secondaryOk()” and it is already pointing it on my connection.

When I try to db.collection.find() it is working fine. But when I try the count, the shell is still needing the “rs.secondaryOk()” script.

Hi there! Welcome to the forum!

Can you please try db.collection.countDocuments()

Please do let us know how this goes!

sorry for the late reply. it still encounters the same error

Are there any fix on the updated versions?

Hi there, apologies for the delay in reply. We’ve looked into this, and it seems like the mongorc.js gets loaded before IntelliShell has connected to the MongoDB server

We’ve created a ticket to improve this behaviour, but until it is released, we recommend you instead manually run the command. I apologise if this is rather inconvenient.