Replies: 1 comment 2 replies
-
I'm having the some in one of our projects, what we do there is overwrite the query service like this: @Injectable()
export class MyQueryService extends TypeOrmQueryService<MyEntity> {
public async deleteOne(id: number, opts?: DeleteOneOptions<MyEntity>): Promise<MyEntity> {
const record = await super.deleteOne(id, opts)
await this.otherRepoOne.delete({ parentId: id })
await this.otherRepoTwo.delete({ parentId: id })
// etc
return record
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
How do I create a "BeforeDeleteOneHook" hook where I will delete the child records? My legacy database does not have the cascade option configured and therefore it will be necessary to delete the children before deleting the parent record. I have noticed that the DeleteOneInputType is not generic and therefore I cannot access my child ID, which is an object composed of the key fields. Is there an example to perform this process, or any resource other than using the Hook?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions