Skip to content

Commit

Permalink
feat: delete parentId whenever children become parent
Browse files Browse the repository at this point in the history
  • Loading branch information
stae1102 committed Mar 10, 2024
1 parent 97617f1 commit b480015
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/categories/category.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,12 @@ export class CategoryService {
// find children categories
const childrenCategories = await queryRunnerManager.find(Category, {
where: { parentId: categoryId },
order: { createdAt: 'DESC' },
});

await queryRunnerManager.save(
childrenCategories.map((childrenCategory) => {
childrenCategory.parentId = parentCategory?.id;
childrenCategory.parentId = parentCategory?.id ?? null;
return childrenCategory;
}),
);
Expand Down

0 comments on commit b480015

Please sign in to comment.