After using insertMany
I need to get the returned _ids from the new documents in the same order as they were inserted.
As stated by the documentation if the ordered
parameter is equal to true, mongoDB will perform an ordered insert, but that does not imply that the returned _ids are also ordered in the same way as the new inserted documents.
I did some quick tests to check this and it seems that the order is preserved, but I need to be 100% sure that this is always the behavior.