Finding out if a mongodb instance is a replicaset without admin permissions

We have 3 envs, the lowest env is a single instance and the devs run a single instance mongodb as well.
On the higher envs we use replicasets

We have a feature that uses change streams, which are reliant on the server being a replicaset. We want to toggle the feature depending on MongoDBs capabilites dynamically on startup of the application.
To run replSet.getStatus the user needs admin permissions though, which we obviously dont want.

How can we find out if the server is a replicaset without having admin permissions on the user?

You’re looking for the hello command.

Although drivers would be aware of the topolgy and can provide information indicating a replicaset or not.

Also you can just create a replicaset of one.

1 Like

great answer, very helpful. Thanks.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.