Reputation: 155
I have checked the official document many times, it dose has the rs.slaveOK()
function there and also the shell-help document.
I can't use rs.slaveOK()
even if the function really exist.(Error occur)
That is so weird. Why is that?
The shell try to indicate me that rs.slaveOK()
is not a function when I type it.
Upvotes: 3
Views: 8738
Reputation: 2332
Be careful! MongoDB functions are case sensitive:
rs.slaveOK() is not a function
rs.slaveOk() is the function you are looking for.
Upvotes: 7
Reputation: 5652
You would use rs.slaveOk() when your Mongodb is set up as a replicaset, and you wish to query one of the secondary nodes, rather than the primary. slaveOk is instructing the shell that its ok to return results from a secondary (rather than a primary) even though the results may not be entirely consistent with the primary.
I could be wrong, but it doesn't look like you are connected to a Mongodb which is configured as a replicaset, and if you are then I'm guessing that you are not connected to a secondary. Therefore the instruction to query a secondary makes no sense.
Upvotes: 1