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’.
- 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)
}
}
And I tried running it atleast 5 times but the students collection didnt have any data as I intended
- 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,