First I have updated the versions in my running app.
From nestjs version v-6 upgraded to nestjs v9.0.0 and "@nestjs/mongoose": "^9.2.2",
and monyour textgoose version from v5.6 to 7.1.1 "mongoose": "^7.1.1", "mongoose-unique-validator": "^4.0.0"
now i can make a db connection with same old working code.
then i created a fresh installation with a new project with updated versions.
but getting same errors.
MongooseModule.forRoot(
// `mongodb+srv://${process.env.MONGO_HOST}`,
// {
// user: process.env.MONGO_USER,
// pass: process.env.MONGO_PASSWORD,
// dbName: process.env.MONGO_DATABASE,
// w: 'majority',
// retryWrites: true
// },
`mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASSWORD}@${process.env.MONGO_HOST}/${process.env.MONGO_DATABASE}?retryWrites=true&w=majority`,
),
ERROR [MongooseModule] Unable to connect to the database. Retrying
MongooseServerSelectionError: getaddrinfo ENOTFOUND undefined
i have tried a making a new connection with mongoose and it worked
const conn = await mongoose.connect(mongodb+srv://${process.env.MONGO_USER}:${process.env.MONGO_PASSWORD}@${process.env.MONGO_HOST}/${process.env.MONGO_DATABASE}?retryWrites=true&w=majority
,options);
console.log('conn === ',conn);
but from MongooseModule its not creating a connection.
i just wanna a solution to make a db connection with updated version of mongoose and nestjs.
Thanks