async afterUpdate(event: UpdateEvent<Experience>) {
const old_pub = event.databaseEntity;
const new_pub = event.entity as Experience;
const statusJustChanged = old_pub.status != new_pub.status;
if (statusJustChanged) {
// ... MAKE SOME UPDATES
}
}
The Typeorm Subscribers system don’t really work the way i expected.
Some problems with my code above are:
- Sometimes the
event.databaseEntity
is null (eg: when the update is done without loading the enity first, i.e via theRepository.update
method for eg) - The
event.entity
is of typeObjectLiteral
. Sometimes it only holds a list of the specific updated columns.
So just to be short, my question is how can be sure to check old_pub.status != new_pub.status
afert every updates without my code crashing.