I'm trying to initialise a connection with MongoDB through mongoose (typescript) but it's just not showing any connectiong thingy; but it't not timing out so im lost af what i've done wrong
db connection code:
import mongoose from 'mongoose';
export async function connectToDatabase() {
const db = (await mongoose.connect(process.env.DB_URI as string, {
serverSelectionTimeoutMS: 5000,
})).connection;
db.on('error', console.error.bind(console, 'Connection Error'));
db.on('open', () => {
console.log(`Connected to DB - ${db.name}`);
})
return db;
}
please help me 😭
I've tried looking through documentation but to no avail. Weirdly enough I set up different users for me and the bot but I'm able to access the db through Robo 3T and the VS code UI but just can't do it through the code itself