From 0003c91f693e42dc1c281b9dc4a7362eb8ac2305 Mon Sep 17 00:00:00 2001 From: Divlo Date: Wed, 29 Dec 2021 18:33:12 +0000 Subject: [PATCH] fix(services): desc order for GET /channels/[channelId]/messages --- src/services/channels/[channelId]/messages/get.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/channels/[channelId]/messages/get.ts b/src/services/channels/[channelId]/messages/get.ts index 76ab81e..ab85b3d 100644 --- a/src/services/channels/[channelId]/messages/get.ts +++ b/src/services/channels/[channelId]/messages/get.ts @@ -80,11 +80,11 @@ export const getMessagesByChannelIdService: FastifyPluginAsync = async ( } const messagesRequest = await prisma.message.findMany({ ...getPaginationOptions(request.query), - orderBy: { createdAt: 'asc' }, + orderBy: { createdAt: 'desc' }, where: { channelId } }) const messages = await Promise.all( - messagesRequest.map(async (message) => { + messagesRequest.reverse().map(async (message) => { const member = await prisma.member.findFirst({ where: { id: message.memberId }, include: {