fix: query order

This commit is contained in:
Methapon2001 2024-03-21 16:08:38 +07:00
parent 380a32fabf
commit a492d6a82e

View file

@ -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 },
}),
})),
);