-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version #9930
Comments
Only MongoClient will receive events not DB class in future |
how does this get fixed? |
The warning still exists in mongoose 5.11.18:
|
@vkarpov15 can this please be reopened until it's confirmed resolved? |
@lantw44 @troykelly do you have |
Yes, |
I'm unable to repro, the below script doesn't print any warnings for me. Can you please modify the below script to demonstrate your issue? 'use strict';
const mongoose = require('mongoose');
mongoose.set('useFindAndModify', false);
const { Schema } = mongoose;
run().catch(err => console.log(err));
async function run() {
await mongoose.createConnection('mongodb://localhost:27017/test', {
useNewUrlParser: true,
useUnifiedTopology: true
});
console.log('Done');
} |
@vkarpov15 just replacing your connection string from localhost to an instance of MongoDB Atlas in your script fires the warning like so :
So maybe the issue is not related to Mongoose ?! |
This happens to me connecting to new database ( Note: I am connected to a local, fresh database, therefore it is not only connected to Mongo Altas databases. |
@tukusejssirs the below script doesn't print any warnings. Please modify the below script to demonstrate your issue: 'use strict';
const mongoose = require('mongoose');
mongoose.set('useFindAndModify', false);
const { Schema } = mongoose;
run().catch(err => console.log(err));
async function run() {
await mongoose.createConnection('mongodb://localhost:27017/test', {
useNewUrlParser: true,
useUnifiedTopology: true
});
const newDb = await mongoose.connection.useDb('newDb');
console.log('Done');
} @FlorentinTh I tried with my Atlas cluster and I don't get any warning: await mongoose.createConnection('mongodb+srv://OMITTED:[email protected]/myFirstDatabase?retryWrites=true&w=majority', {
useNewUrlParser: true,
useUnifiedTopology: true
}); I'm going to close this issue. If you're still seeing this warning:
|
Do you want to request a feature or report a bug?
bug (deprecation warning)
What is the current behavior?
On start we have deprecation warning into console
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
No deprecation warning
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Latest 5.11.16
I digged in into warning and found why this happens:
The text was updated successfully, but these errors were encountered: