Reference documentation
Question 1. The preferredcms_db_name and cms_db_collection options are not supported
throw new error_1.MongoParseError(`${optionWord} ${Array.from(unsupportedOptions).join(', ')} ${isOrAre} not supported`);
^
MongoParseError: options preferredcms_db_name, cms_db_collection are not supported
problem solved:
- step1: Delete the preferredcms_db_name and cms_db_collection option configurations in the connection string
- step2: Reconnect
问题2:MongoServerSelectionError: Server at hkdbspwv601:27017 reports maximum wire version 5, but this version of the Node.js Driver requires at least 6 (MongoDB 3.6)
version in my current code
{
"dependencies": {
"mongodb": "^5.1.0"
}
}
The mongod version of the server
solution:
If you are like me, you are using mongodb
const { MongoClient } = require('mongodb');
const url = 'mongodb://XXXXXXX';
const client = new MongoClient(url);
const dbName = 'AAAAA';
async function main() {
await client.connect();
console.log('Connected successfully to server');
const db = client.db(dbName);
const collection = db.collection('XXXXXX');
const findResult = await collection.find({}).project({ _id: 'XXXXXXX' }).toArray()
console.log('Found documents =>', findResult);
// the following code examples can be pasted here...
return 'done.';
}
main()
.then(console.log('Connected.'))
.catch(console.error)
.finally(() => client.close());
- Documentation: mongodb
- step1: Go to the official website to compare the version. Click here to go directly to the official website link.
- step2: Update the local code and use the comparison version (after comparison, the maximum version number I should use is 4.1)
- step3: Re-download dependencies and run the code
- step4: Run the code and connect successfully~
If you are using mongoose, the solution steps are as follows:
const mongoose = require('mongoose')
mongoose.connect('mongodb://127.0.0.1:27017/ele-admin')
.then(() => console.log('数据库连接成功'))
.catch(err => console.log('数据库连接失败', err));
-
step1: Go to the official website to compare the version. Click here to go directly to the official website link.
-
step2: Update the local code and use the comparison version (after comparison, the maximum version number I should use is 5.0.0)
-
step3: Re-download dependencies and run the code
-
step4: Run the code and connect successfully~
-
That’s all for today~
-
Friends, ( ̄ω ̄( ̄ω ̄〃 ( ̄ω ̄〃)ゝSee you tomorrow~~
-
Everyone, please be happy every day
Everyone is welcome to point out what needs to be corrected in the article ~
there is no end to learning and win-win cooperation