Does mongoose automatically detects PRIMARY in a replica set even when it's changed?
I'm pretty sure that's the case but I have to make sure b/c I can't find anything related to that in the docs.
Thanks!
Does mongoose automatically detects PRIMARY in a replica set even when it's changed?
I'm pretty sure that's the case but I have to make sure b/c I can't find anything related to that in the docs.
Thanks!
Mongoose underneath just uses the mongodb native nodejs driver to establish a connection. You should pass in your connection string to mongoose (which is then passed to mongodb's native node driver) all IP addresses in the replica set, so that it can switch to the new primary in the case of failover.
Format of the connection string from the docs
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]