(node:44612) DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version

Yep, you can ignore this one for now. It’s just warning you that this will be an issue when you upgrade to the next major version.

A little more info from one of the driver engineers:

Db is no longer the place to listen to events, you should listen to your MongoClient instead like so:

const client = new MongoClient(…)
client.on(‘Event name I want to listen too’, () => {…})
await client.connect()

The reason for this style is because by registering your listeners before connecting you can be sure that you’re able to capture every event that is triggered

3 Likes