I have a contact
postgres table, with a contacted_date
column. I recently created a contact_date
table, which is meant to store each date a contact was contacted.
Because the codebase frequently refers to the contact
table for the most recent contacted date
, I haven't migrated all the data out of that table. Instead, contact_date
contains each date a given contact was contacted, and a trigger on that table updates contact
with the latest date for each contact.
If I use Sequelize to make a change to contact_date
, does the promise await the successful completion of the trigger? Or does it only await the successful completion of the change to contact_date
?
In most of my code, this isn't a big concern - if I persist a new contact date, then my code already has access to that date, and I can use that date in other calculations if I need it. But I'm running into difficulties with my tests, and it may be because of a race condition. In my tests, I'm creating new contacts with contact dates, and some of my tests are failing, perhaps because the promise is resolving before the trigger has finished doing its work.
Update: This SO post indicates that the trigger is part of the same transaction, implying that the Sequelize promise wouldn't resolve until the trigger had completed, but if someone knows for sure, I'd still like to hear dis/confirmation.