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

Investigate NODE-3775 - Driver ignores in-uri provided database and uses test database

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • 2
    • Not Needed

      NODE-3775 Description

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

       

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            dbeng-pm-bot PM Bot
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: