using ver 6.3 of the mongodb package on node.js I get the error mentioned in the title when trying to access my database. I’ve gone through the docs and my code matches the example provided in the quickstart. So I don’t know why this issue could be occuring.
code for connecting:
async function connectToDatabase() {
try {
dbClient = new MongoClient(mongoURI);
console.log('Connected to MongoDB');
} catch (error) {
console.error('Error connecting to MongoDB:', error);
};
};
where the error occurs/where i call the database:
async function processEvent(event, dbClient) {
try {
const database = dbClient.db('BotServices');
const eventsCollection = database.collection('eventData');
const currentTime = new Date();
const eventTime = new Date(event.scheduledStartAt);
const eventData = {
id: event.id,
name: event.name,
startTime: event.scheduledStartAt,
endTime: event.scheduledEndAt,
server: event.guild.id,
// Add more fields as needed
};