Final: Question 5 syntax for bulkWrite insert

I just had a doubt about whether the syntax in Question 5 for each insert operation was correct. I could be wrong, however.
The mongodb documentation shows the following bulkWrite performing few insert operations on a characters collection:

db.characters.bulkWrite([
{ insertOne: { "document": { "_id": 4, "char": "Dithras", "class": "barbarian", "lvl": 4 } } },
{ insertOne: { "document": { "_id": 5, "char": "Taeln", "class": "fighter", "lvl": 3 } } }
])`

The array containing the insert operations in the final is:

const baseballPlayers = [
insertOne({ _id: 11, name: 'Edgar Martinez', salary: "8.5M" }),
insertOne({ _id: 3, name: 'Alex Rodriguez', salary: "18.3M" }),
insertOne({ _id: 24, name: 'Ken Griffey Jr.', salary: "12.4M" }),
insertOne({ _id: 11, name: 'David Bell', salary: "2.5M" }),
insertOne({ _id: 19, name: 'Jay Buhner', salary: "5.1M" })
]

When I tried performing the above bulk operation on another cluster, it didn’t work and gave me a reference error stating insertOne is not defined. As a result, I could not verify my results.

Hi @sathya_s,

You are right! There is an issue with the syntax. Thank you so much for notifying the issue.

I will make sure it gets corrected soon! :slight_smile:
Thanks again!

Kanika

Thank you @Kanika. Would there be any way students can get credit for this question, given that it was incorrect?!

Hi @sathya_s,

Sorry, but even with the syntax issue, the purpose of the question is to evaluate their understanding of the bulk writes, not the actual command.
This should not have prevented you from getting the correct answer.

I hope it helps.

Kanika

It’s hard to notice that bulk write has duplicate key. Would be great to have some hint that there is a duplicate.