I expect Promise.all() to run the code for each passed item in parallel. Unfortunately, there is a "pause" after "MAPPING DATA" is done logging all items to the console and before "CHECKED DB" starts logging the progress made for all items.
It seems that instead of const snap = await global.db.collection("Prompts").doc(id).get(); being processed in parallel, they all need to finish before the rest of the code can continue executing.
Why is that the case considering I am also awaiting global.db.collection("collection").doc(id).set(data); but that line doesn't seem to "block" the process (console.log("WRITE FOR: "+id)is continuously being executed) ?
How would I execute in parallel those requests while keeping the order in which they are made for each data item ? (first check DB, then write if needed)
N.B.: Testing with 10K docs to write.
async function parallelIndividualWrites(datas) {
try {
  let mapped = 1;
  let dbcheck = 1;
  let counter = 1;
  await Promise.all(datas.map(async (data) =>  {
       // ...
    console.log("MAPPING DATA: "+(mapped++)+"/"+datas.length);
    const snap = await global.db.collection("Prompts").doc(id).get();
    console.log("CHECKED DB: "+(dbcheck++)+"/"+datas.length);
    if (snap.data()) {
        console.log("NO WRITE FOR: "+id);
        console.log("COUNT: "+counter++);
    }
    else {
        await global.db.collection("collection").doc(id).set(data);
        console.log("WRITE FOR: "+id)
        console.log("COUNT: "+counter++);
    }
  }));
}
catch(err) {
  console.log("WRITING TO DB ERROR: "+err);
}   
}
 
    