From a492d6a82e7d4d71ff1acba270704e363431ab06 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 21 Mar 2024 16:08:38 +0700 Subject: [PATCH] fix: query order --- src/controllers/ProfileFamilyHistoryController.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/controllers/ProfileFamilyHistoryController.ts b/src/controllers/ProfileFamilyHistoryController.ts index aed19573..d0f0fe55 100644 --- a/src/controllers/ProfileFamilyHistoryController.ts +++ b/src/controllers/ProfileFamilyHistoryController.ts @@ -92,11 +92,11 @@ export class ProfileFamilyHistoryController extends Controller { public async getFamilyHistory(@Path() profileId: string) { const family = await this.familyHistoryRepo.find({ take: 1, - order: { createdAt: "DESC" }, + order: { lastUpdatedAt: "DESC" }, where: { profileId }, }); const children = await this.childrenRepo.find({ - order: { createdAt: "DESC" }, + order: { createdAt: "ASC" }, where: { profileId }, }); return new HttpSuccess( @@ -226,8 +226,9 @@ export class ProfileFamilyHistoryController extends Controller { const record = await Promise.all( family.map(async (v) => ({ ...v, - children: await this.childrenHistoryRepo.findBy({ - profileFamilyHistoryId: v.id, + children: await this.childrenHistoryRepo.find({ + order: { createdAt: "ASC" }, + where: { profileFamilyHistoryId: v.id }, }), })), );