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

Kritagya Khandelwal picture Kritagya Khandelwal · Feb 13, 2021 · Viewed 26.5k times · Source

I am using mongoose and mocha for MongoDB schema design and API development I am getting this warning... what does this mean, how it will affect me and what is the fix??

Below the actual warning text:

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

Answer

kmgt picture kmgt · Feb 14, 2021

UPDATE

[email protected] is out.

Just update mongodb driver and mongoose:

npm i mongodb mongoose

This is caused by the [email protected] native driver which is used by mongoose.

#1 You can downgrade mongodb to version 3.6.3 (described here).

#2 Or downgrade mongoose from 5.11.16 back to 5.11.15:

npm uninstall mongoose
npm install [email protected]

#3 Or just wait for the release of [email protected].