insertMany ordered: false, get successful inserted ids

How would you go about getting the insertedIds when insertMany throws due to duplicate key error.
I know there is the insertedIds property assigned to the error object, but that includes all the ids, and not just the ids of successful inserts. The only thing that comes to find is to loop through the writeErrors and filter my docs array accordingly to get the successful inserts.

try {
   let res = await collection.insertMany(docs , { ordered: false });
} catch (e) {
   console.log(e.insertedIds); //displays all ids of attempted inserts

Thank you.