Why do you think this new db M001 created?

Hello team support and students,
When I try to insert a document using insertOne() function, I see my document get updated under db video. However when I used the insertMany(), I didn’t see any inserted document but a new M001 just like a video? What do you think about it?

Screenshot (58) Screenshot (60)

Because you forgot to run

use video

while your connection string specify M001 as the default database.

It is still behaving the same… But it works fine with single documents insertion.

Hi @Medhanie_Gebru,

In the output, it says WriteError due to duplicate key.

You already have a document in your collection with the same _id value. _id value must be unique for every document in the collection.

~ Shubham

Hi Shubham_Ranjan,
I understand what you mentioned-the “duplicate key error” with “Star Trek II: The Wrath of Khan” as I already have this documents . However, I was expecting to see two documents “Star Trek” and of course the duplicated one that been there already in my Compass . As you can see:

I was wondering if you could help me to figure it out what’s really goin on?

There is a lesson where the difference between ordered and non-ordered bulk operations. You should revise it. I do not remember which one exactly but the document for insertMany is at

Hi @Medhanie_Gebru,

If you check the values of the _id field in both the documents that you are referring here, they are different.

One of them is tt0084726 and another one is an ObjectId(). MongoDB uses _id field as the Primary key.

Hope it helps~

~ Shubham

Okay, I got it thank you so much!