-
Type: Bug
-
Resolution: Duplicate
-
Priority: Critical - P2
-
None
-
Affects Version/s: 4.2.0
-
Component/s: None
What problem are you facing?
When trying to connect with a mongo:4 instance using the driver 4.2.0 driver the in-uri provided database is ignored and a database named test is used.
What driver and relevant dependency versions are you using?
- mongo docker version 4 (mongo:4)
- mongo node js driver 4.2.0
- node v16.9.0
Steps to reproduce?
Code that shows the error:
import pkg from 'mongodb'; const { MongoClient } = pkg; async function main() { const client = new MongoClient( 'mongodb://main:password@localhost:27017/something?authSource=admin' ); try { await client.connect(); await client.db().collection('sunny').insertOne({ hehe: true }); // !!!! the document is in database test and collection sunny and not in database something } catch (e) { console.trace(new Date(), e); process.exit(1); } finally { await client.close(); } }main();