fix(services): desc order for GET /channels/[channelId]/messages

This commit is contained in:
Divlo 2021-12-29 18:33:12 +00:00
parent 712a92b25f
commit 0003c91f69
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9

View File

@ -80,11 +80,11 @@ export const getMessagesByChannelIdService: FastifyPluginAsync = async (
} }
const messagesRequest = await prisma.message.findMany({ const messagesRequest = await prisma.message.findMany({
...getPaginationOptions(request.query), ...getPaginationOptions(request.query),
orderBy: { createdAt: 'asc' }, orderBy: { createdAt: 'desc' },
where: { channelId } where: { channelId }
}) })
const messages = await Promise.all( const messages = await Promise.all(
messagesRequest.map(async (message) => { messagesRequest.reverse().map(async (message) => {
const member = await prisma.member.findFirst({ const member = await prisma.member.findFirst({
where: { id: message.memberId }, where: { id: message.memberId },
include: { include: {