Final: Question 5 question

Hi @Kanika

In Final: Question 5, there is this sentence:

Which of the insert operations in requests will succeed?

requests is bolded, as if it has been defined before, but it is not defined. It looks like something is missing?

Furthermore, the code as it stands will not work, since insertOne is undefined. I am not sure if this is a trick question or not: as it stands no inserts would work. The code has a blocking error.

Agreed, the syntax is incorrect here and should be fixed.

BulkWrite accepts an array of objects. insertOne is not supposed to be a function.

Documentation:
http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#bulkWrite

That said I’m pretty sure the point of this question is to differentiate between ordered and unordered bulkWrites. I answered the question assuming the syntax was correct.

Nice catches! Hopefully someone that administers the course and get this corrected.

4 Likes

That said I’m pretty sure the point of this question is to differentiate between ordered and unordered bulkWrites. I answered the question assuming the syntax was correct.

I agree. I answered with the assumption that they meant to write:

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