insertMany inserts nome when had repeated records

When I tried to use the insertMany from insertMany-ordered.js it inserts none, then I took off the two repeated records then it insert all in the string, the mongodb should not just insert the unrepeated ones and ignore the repeated ones?

Hi @Emerson_Alves_00326,

I would recommend you to watch the Lecture: Creating Documents: insertMany() again.

Here, we have discussed the concept of ordered and unordered inserts. We specify this additional field in the form of a document in the insertMany() function. When this field is set to true then we stop inserting documents as soon as we encounter a duplicate entry or an error is thrown. However, when this field is set to false then we continue inserting documents by skipping the documents which has thrown some error.

For additional information please refer this post. Hope it helps!

If you have any other issue please feel free to get back to us. Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

1 Like