Throwing this out there but I know vitaly is such a hawk that he'll probably give me the answer or at least a solid hint ;)
I am basically uploading a batch of records and checking if the Company has already been added to a Company table. If not, I'll add the Company and then add all the records linking with the new CompanyID.
This isn't a pg-promise specific issue for sure but some of the dialogue here https://github.com/vitaly-t/pg-promise/blob/master/examples/select-insert.md show it's a true design concern and people are trying to come up with an elegant solution ... at least back in October.
I'm still new to asynchronous stuff but my gut says while I could insert a delay or possible chain promises together and process them in parallel (https://daveceddia.com/waiting-for-promises-in-a-loop/ or Resolve promises one after another (i.e. in sequence)?) but what vitaly mentions related to single query alternatives may be the real way to do this and not lock down the event loop
I'll hack on this today but I also want to do this in an elegant way since it's a common pattern
Thanks to vitaly in advance ;)
PS you rock vitaly