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(
"
select
messages.id as id,
content,
created_at,
users.name as author_name
from
messages
join
users
on messages.author_id = users.id
where
room_id = ?
*
from (
select
messages.id as id,
content,
created_at,
users.name as author_name
from
messages
join
users
on messages.author_id = users.id
where
room_id = ?
order by
messages.id desc
limit ?
)
order by
messages.id
limit ?;
id asc;
",
// todo: implement limit
)
.bind(room_id)
.bind(limit)