Skip to content

Commit

Permalink
fix(dal): messages sort order by createdAt (novuhq#6319)
Browse files Browse the repository at this point in the history
jainpawan21 authored Sep 2, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 8fd2c8c commit 071cc7f
Showing 2 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ export class GetMessages {

const data = await this.messageRepository.getMessages(query, '', {
limit: LIMIT,
sort: { createdAt: -1 },
skip: command.page * LIMIT,
});

2 changes: 2 additions & 0 deletions libs/dal/src/repositories/message/message.repository.ts
Original file line number Diff line number Diff line change
@@ -713,13 +713,15 @@ export class MessageRepository extends BaseRepository<MessageDBModel, MessageEnt
options?: {
limit?: number;
skip?: number;
sort?: { [key: string]: number };
}
) {
const filterQuery: FilterQuery<MessageEntity> = { ...query };
if (query.transactionId) {
filterQuery.transactionId = { $in: query.transactionId };
}
const data = await this.MongooseModel.find(query, select, {
sort: options?.sort,
limit: options?.limit,
skip: options?.skip,
})

0 comments on commit 071cc7f

Please sign in to comment.