Skip to content

Commit a40a3b6

Browse files
committed
fix: db sorting past 200 messages
1 parent 9042015 commit a40a3b6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

package/src/store/apis/queries/selectMessagesForChannels.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,19 @@ export const selectMessagesForChannels = async (
3030
*,
3131
ROW_NUMBER() OVER (
3232
PARTITION BY cid
33-
ORDER BY cast(strftime('%s', createdAt) AS INTEGER) ASC
33+
ORDER BY cast(strftime('%s', createdAt) AS INTEGER) DESC
3434
) RowNum
3535
FROM messages
3636
WHERE cid in (${questionMarks})
3737
) a
3838
LEFT JOIN
3939
users b
4040
ON b.id = a.userId
41-
WHERE RowNum < 200`,
41+
WHERE RowNum < 200
42+
ORDER BY cast(strftime('%s', a.createdAt) AS INTEGER) ASC`,
4243
cids,
4344
);
45+
console.log(result);
4446

4547
return result.map((r) => JSON.parse(r.value));
4648
};

0 commit comments

Comments
 (0)