Ordered: false question

I understand why the insertMany function will fail if there are duplicate documents. I’m curious as to why the ordered: false function actually works when it’s listed after the documents that would have thrown the error. It seems to me that the duplicates will (by default) throw an error and not be added, THEN the ordered: false document is run.

I see in the lesson that all documents will be added, but I keep thinking the ordered: false document should be at the top, rather than the bottom

I understand your confusion, but this is for API consistency. We always structure the query in MongoDB in this form:

 command ( document, options )

The documents are always listed as the first parameter and options will come second.

And as mentioned in the docs:

A boolean specifying whether the mongod instance should perform an ordered or unordered insert.

The mongod instance will first check the options and then execute the command on documents. This will also explain the behaviour of writeConcern etc.