Hey. I want to figure out a way to update my "main table's" updatedAt column whenever any insertions/updates/deletes happen in any of the other tables that have ManyToOne relations to it. I use type-graphql.Description is the name of the ManyToOne relation, the parent model is called DeliveryDescriptionModel.I've been trying to do something like this in the model:@BeforeInsert() updateParentUpdate() { this.description.updatedAt = new Date(); } @BeforeRemove() updateParentRemove() { this.description.updatedAt = new Date(); } @BeforeUpdate() updateParentUpdate() { this.description.updatedAt = new Date(); } Alternatively I could just update the DeliveryDescriptionModel's updatedAt in every type-graphql mutation that I have, but I have a lot of mutations, and this seems really bad.Does anyone have a way of doing this that works?
Submitted December 12, 2019 at 04:00PM by Xarnius
No comments:
Post a Comment