I have 3 node replicates and i am using all the host in my connection string.Once i execute my node.js script i want to see which particular host it got connected to.
I can fire the following command in mongo shell but same is not working in node.js script, mostly says like "function is not defined"
hostnamedb.hostInfo().system.hostnamers.status().members.find(r=>r.state===1).name
TypeError: db.hostInfo is not a function
ReferenceError: hostname is not defined
Can someone help me how i can find the connected mongo instance server name using the node.js script?