Hello,
While reviewing a question I posted last week, I came across the following code snippet. Wouldn’t it make more sense to trigger the afterUpdate hook after the update action and before fetching the entity again? This way, any updates made in the afterUpdate lifecycle would be reflected in the administration panel.
When I move the afterUpdate before the findOne my changes are reflected in the admin panel and it works great…
try {
await this.updateRelations(uid, id, data, { transaction: trx.get() });
await trx.commit();
} catch (e) {
await trx.rollback();
await this.createQueryBuilder(uid).where({ id }).update(entity).execute();
throw e;
}
const result = await this.findOne(uid, {
where: { id },
select: params.select,
populate: params.populate
});
await db.lifecycles.run("afterUpdate", uid, { params, result }, states);
This topic has been created from a Discord post (1229425350216253547) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord