Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3775

Driver ignores in-uri provided database and uses test database

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: 4.2.0
    • Component/s: None
    • 1
    • Not Needed

      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();
      

       

        1. image12.png
          image12.png
          40 kB
        2. image-2021-11-19-17-18-53-782.png
          image-2021-11-19-17-18-53-782.png
          4 kB

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            catalinmarincia@gmail.com Cătălin Marincia
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: