Skip to content
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

Can't run Backend Redbus #34

Open
airlangga2377 opened this issue Aug 13, 2022 · 1 comment · May be fixed by #36
Open

Can't run Backend Redbus #34

airlangga2377 opened this issue Aug 13, 2022 · 1 comment · May be fixed by #36

Comments

@airlangga2377
Copy link

MongoParseError: options usecreateindex, usefindandmodify are not supported
at parseOptions (C:\Users\Intel\Downloads\redbus\back-end-redbus\node_modules\mongodb\lib\connection_string.js:290:15)
at new MongoClient (C:\Users\Intel\Downloads\redbus\back-end-redbus\node_modules\mongodb\lib\mongo_client.js:64:63)
at C:\Users\Intel\Downloads\redbus\back-end-redbus\node_modules\mongoose\lib\connection.js:801:16
at new Promise ()
at NativeConnection.Connection.openUri (C:\Users\Intel\Downloads\redbus\back-end-redbus\node_modules\mongoose\lib\connection.js:798:19)
at C:\Users\Intel\Downloads\redbus\back-end-redbus\node_modules\mongoose\lib\index.js:380:10
at C:\Users\Intel\Downloads\redbus\back-end-redbus\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5
at new Promise ()
at promiseOrCallback (C:\Users\Intel\Downloads\redbus\back-end-redbus\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10)
at Mongoose._promiseOrCallback (C:\Users\Intel\Downloads\redbus\back-end-redbus\node_modules\mongoose\lib\index.js:1225:10) {
[Symbol(errorLabels)]: Set(0) {}
}

@rohity20
Copy link

We can modify the code for connecting the server with the backend i.e connect function as :
const connect = () => {
const db = mongoose.connection;

db.on('error', (error) => {
console.error('MongoDB connection error:', error);
});

db.once('open', () => {
console.log('MongoDB connection established.');
});

return mongoose.connect(
"mongodb+srv://redbus_db_user_1:[email protected]/redbus?retryWrites=true&w=majority",
{
useCreateIndex: true,
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
}
);
};
These changes allow you to handle MongoDB connection events correctly and avoid the errors related to listening to events on the Db class.

@rohity20 rohity20 linked a pull request Oct 1, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants