Final Question 5 MS220JS

The bulkwrite function call seems to have incorrect syntax.

insertOne is not a function.

Why are you trying to use it as a function?



Yes, it’s actually “Python Syntax” and therefore lifted directly from material from that original course. Most things related to language API typically get updated/presented for Python and Java before the “love an attention” is given to other languages.

Basically just take the presented statements to read as:

var baseballPlayers = [
  { insertOne: { document: { _id: 11, name: 'Edgar Martinez', salary: "8.5M" } } },    // Insert #1
  { insertOne: { document: { _id: 3, name: 'Alex Rodriguez', salary: "18.3M" } } },    // Insert #2
  { insertOne: { document: { _id: 24, name: 'Ken Griffey Jr.', salary: "12.4M" } } },  // Insert #3
  { insertOne: { document: { _id: 11, name: 'David Bell', salary: "2.5M" } } },        // Insert #4
  { insertOne: { document: { _id: 19, name: 'Jay Buhner', salary: "5.1M" } } }         // Insert #5

As from the context of how this would be written with perspective of either the mongo shell or the NodeJS driver.

The question of course is related to sequence and the default handling of bulkWrite() operations without any other options specified explicitly.


So, it seems quite silly (or worse) to retain code using Python syntax IN A JAVASCRIPT COURSE. If the possible answers included “none of the above”, THAT would be correct, not the answer(s) which is(are) expected by implication through examination of the code provided.