Implement limit

This commit is contained in:
Mikhail 2024-05-28 20:59:42 +02:00
parent b0789d5457
commit 1e8a183d6c
1 changed files with 19 additions and 14 deletions

View File

@ -35,22 +35,27 @@ impl Storage {
let res = sqlx::query_as( let res = sqlx::query_as(
" "
select select
messages.id as id, *
content, from (
created_at, select
users.name as author_name messages.id as id,
from content,
messages created_at,
join users.name as author_name
users from
on messages.author_id = users.id messages
where join
room_id = ? users
on messages.author_id = users.id
where
room_id = ?
order by
messages.id desc
limit ?
)
order by order by
messages.id id asc;
limit ?;
", ",
// todo: implement limit
) )
.bind(room_id) .bind(room_id)
.bind(limit) .bind(limit)