The MongoDB Driver System provides automatic MongoDB version detection and driver selection to support MongoDB versions 3.0 through 8.0 with compatible Node.js drivers. This system eliminates the need for manual driver configuration and provides seamless compatibility across all supported MongoDB versions.
MongoDB Version | Node.js Driver | Driver Version | Package Name |
---|---|---|---|
3.0 - 3.6 | mongodb@3.7.4 | 3.7.4 | mongodb3legacy |
4.0 - 4.4 | mongodb@4.17.2 | 4.17.2 | mongodb4legacy |
5.0 | mongodb@5.9.2 | 5.9.2 | mongodb5legacy |
6.0 | mongodb@6.3.0 | 6.3.0 | mongodb6legacy |
7.0 | mongodb@7.0.1 | 7.0.1 | mongodb7legacy |
8.0 | mongodb@6.9.0 | 6.9.0 | mongodb8legacy |
MongoDBDriverManager (models/lib/mongodbDriverManager.js
)
MongoDBConnectionManager (models/lib/mongodbConnectionManager.js
)
MeteorMongoIntegration (models/lib/meteorMongoIntegration.js
)
MongoDB Driver Startup (server/mongodb-driver-startup.js
)
The MongoDB driver system is automatically installed when you install Wekan dependencies:
npm install
All required driver packages are included in package.json
:
{
"dependencies": {
"mongodb3legacy": "npm:mongodb@3.7.4",
"mongodb4legacy": "npm:mongodb@4.17.2",
"mongodb5legacy": "npm:mongodb@5.9.2",
"mongodb6legacy": "npm:mongodb@6.3.0",
"mongodb7legacy": "npm:mongodb@7.0.1",
"mongodb8legacy": "npm:mongodb@6.9.0"
}
}
The system works automatically without any configuration required:
You can test the system using the provided test script:
node test-mongodb-drivers.js
The system provides several ways to monitor its operation:
// Get connection statistics
Meteor.call('mongodb-driver-stats', (error, result) => {
console.log('Connection Stats:', result);
});
// Test connection
Meteor.call('mongodb-driver-test-connection', (error, result) => {
console.log('Connection Test:', result);
});
// Get supported versions
Meteor.call('mongodb-driver-supported-versions', (error, result) => {
console.log('Supported Versions:', result);
});
// Reset system
Meteor.call('mongodb-driver-reset', (error, result) => {
console.log('Reset Result:', result);
});
Subscribe to the monitoring publication:
Meteor.subscribe('mongodb-driver-monitor');
Access the data in your template:
Template.yourTemplate.helpers({
driverStats() {
return MongoDBDriverMonitor.findOne('stats');
}
});
The system detects MongoDB versions by analyzing wire protocol errors. Here are the error patterns used:
unsupported wire protocol version
wire protocol version 0/1/2/3
protocol version 0/1/2/3
wire protocol version 4/5/6
protocol version 4/5/6
wire protocol version 7
protocol version 7
wire protocol version 8
protocol version 8
wire protocol version 9
protocol version 9
wire protocol version 10
protocol version 10
The system uses the standard MongoDB environment variables:
MONGO_URL
: MongoDB connection stringMONGO_OPLOG_URL
: MongoDB oplog connection string (optional)You can customize connection options by modifying the default options in mongodbConnectionManager.js
:
const defaultOptions = {
useNewUrlParser: true,
useUnifiedTopology: true,
maxPoolSize: 10,
serverSelectionTimeoutMS: 5000,
socketTimeoutMS: 45000,
// Add your custom options here
};
Driver Not Found
npm install
Connection Failures
Version Detection Issues
Enable debug logging by setting the DEBUG environment variable:
DEBUG=mongodb-driver* node main.js
The system provides detailed logging:
=== MongoDB Driver System Startup ===
MONGO_URL found, initializing MongoDB driver system...
Connection string: mongodb://***:***@localhost:27017/wekan
Initializing Meteor MongoDB Integration...
Testing MongoDB connection...
✅ MongoDB connection test successful
Driver: mongodb6legacy
Version: 6.0
MongoDB Driver System Statistics:
Initialized: true
Custom Connection: true
Supported Versions: 3.0, 3.2, 3.4, 3.6, 4.0, 4.2, 4.4, 5.0, 6.0, 7.0, 8.0
=== MongoDB Driver System Ready ===
If you're migrating from standard MongoDB connections:
For issues or questions:
This MongoDB Driver System is part of Wekan and is licensed under the MIT License.