Skip to content

Commit 6baf957

Browse files
committed
fix: make sure comments are ordered by created timestamp
1 parent 7dfab63 commit 6baf957

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

plugins/qeta-backend/src/database/DatabaseQetaStore.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,11 +2580,9 @@ export class DatabaseQetaStore implements QetaStore {
25802580
postId: number,
25812581
commentsFilter?: PermissionCriteria<QetaFilters>,
25822582
): Promise<RawCommentEntity[]> {
2583-
const query = this.db<RawCommentEntity>('comments').where(
2584-
'comments.postId',
2585-
'=',
2586-
postId,
2587-
);
2583+
const query = this.db<RawCommentEntity>('comments')
2584+
.where('comments.postId', '=', postId)
2585+
.orderBy('created');
25882586
if (commentsFilter) {
25892587
parseFilter(commentsFilter, query, this.db, 'comments');
25902588
}
@@ -2595,11 +2593,9 @@ export class DatabaseQetaStore implements QetaStore {
25952593
answerId: number,
25962594
commentsFilter?: PermissionCriteria<QetaFilters>,
25972595
): Promise<RawCommentEntity[]> {
2598-
const query = this.db<RawCommentEntity>('comments').where(
2599-
'comments.answerId',
2600-
'=',
2601-
answerId,
2602-
);
2596+
const query = this.db<RawCommentEntity>('comments')
2597+
.where('comments.answerId', '=', answerId)
2598+
.orderBy('created');
26032599
if (commentsFilter) {
26042600
parseFilter(commentsFilter, query, this.db, 'comments');
26052601
}

0 commit comments

Comments
 (0)