'Problem in Typeorm EventSubscriber & Postgres AfterInsert

I have a big problem with EventSubscribers of typeorm & PostgreSQL.

I need to set Notification for a newly created Entity inside the AfterInsert event on TypeormEventSubscriber but, when I try to set the relations there is nothing inserted into the database to do that.

# Output of event.entity

Entity: {
  id: 34,
}

# It seems everything is ok and the record inserted but it's not.

Typeorm runs every query including the event hooks query inside a transaction as it seems, until every query is not done correctly, nothing is inserted into the database, which means I can not create relations in events even in AfterInserted because nothing is written into tables.

there is no other solution for this use case?
I can write the code after entity saved within my service but, not what I'm looking for.

thanks...

TYPEORM:POSTGRESQL Set relations on event hooks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source