diff --git a/src/categories/category.service.ts b/src/categories/category.service.ts index 03db16d..d7698ec 100644 --- a/src/categories/category.service.ts +++ b/src/categories/category.service.ts @@ -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; }), );