Wrong db name in mongo URI- created a new db

So in my MongoURI variable – i have mistakenly added a wrong db name for example it should be ‘trepdb’ but it was written as ‘tpredb’.

  1. First I tried running the following script to import some dummy data

Seeder script/import script

const importData =async() =>{   
 try{
   await Student.deleteMany()
     
     await Student.insertMany(students)
     console.log("Data imported".green.inverse)
     process.exit()
    
    }
    catch(error){
        console.error(`${error}`.red.inverse)
        process.exit(1)
    }
}

dummy data & SCHEMA
enter image description here

And I tried running it atleast 5 times but the students collection didnt have any data as I intended

  1. So i thought I may have made a mistake in adding the schema type. ‘classesEnrolled:Array’ So i deleted that from both studentSchema and dummy data and ran the seeder script (ie. import Students) and then i refreshed my cluster it showed me a new database with the mistaken name and the students collection in it with the data imported..

Is this the expected behavior-if so why so ? thanks for the help here – I would have expected an error saying that database doesnt exist or something but instead it created a database and added a brand new collection with the data in it,

Classes property removed from schema & dummy data - data import script at the right