How to switch to secondary to run compact

Hi.
I want to run compact on my secondary. Hence I am trying to follow this -compact (database command) - Database Manual - MongoDB Docs.

However I am not able to find how to connect to the secondary.
My overall plan is to compact the secondary, then switch the secondary as primary. Then run compact on the old primary. I have a Muti region replica set with 3 nodes.

Thank you for the guidance.

-Sainath

Check this thread

Compacting a replica set

1 Like