im trying to connect my node app to mongo cluster, and i have used this method
var options = {
useMongoClient: true,
autoIndex: false,
reconnectTries: Number.MAX_VALUE,
reconnectInterval: 500,
poolSize: 10,
bufferMaxEntries: 0
};
var cluster = "my cluster url XXX";
mongoose.connect(cluster, options);
but it throwing this error
(node:8701) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): MongoError: topology was destroyed (node:8701) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that a re not handled will terminate the Node.js process with a non-zero exit code.
I know this is not the right way to connect to a cluster. can anyone please tell me which is the best method and why (with an example) Thanks!!