When it comes to removing a user from my site, I find myself having to execute multiple database queries to delete the user's ID across approximately 10 different tables.
Currently, I am resorting to what I consider a messy workaround where I have multiple (click) events on the same button triggering various functions. These functions then go through my service layer to interact with the database. In my service, I have separate functions for each table that needs to be accessed in order to delete the user's ID.
Here is an example of the code structure:
<button (click)="deleteCandidateInCompanies(Item.owner)"(click)="deleteCandidateInOrganizations(Item.owner)"
In the component.ts file:
deleteCandidateInCompanies(owner: string): void {
// Function logic for deleting candidate from companies
}
deleteCandidateInOrganizations(owner: string): void {
// Function logic for deleting candidate from organizations
}
In the service.ts file:
// Functions to handle deletion logic for companies and organizations
When attempting to combine these functions into one in the component.ts file, an error occurs stating "Promise returned from deleteCandidateFromCompanies is ignored." This prompts me to search for a more efficient way to consolidate these functions and reduce both the amount of code and number of database calls made.