forked from lavina/lavina
Fix query
This commit is contained in:
parent
660794c1dd
commit
775f43a1f3
|
@ -7,24 +7,21 @@ impl Storage {
|
||||||
#[tracing::instrument(skip(self), name = "Storage::is_room_member")]
|
#[tracing::instrument(skip(self), name = "Storage::is_room_member")]
|
||||||
pub async fn is_room_member(&self, room_id: u32, player_id: u32) -> Result<bool> {
|
pub async fn is_room_member(&self, room_id: u32, player_id: u32) -> Result<bool> {
|
||||||
let mut executor = self.conn.lock().await;
|
let mut executor = self.conn.lock().await;
|
||||||
let res: (bool,) = sqlx::query_as(
|
let res: (u32,) = sqlx::query_as(
|
||||||
"
|
"
|
||||||
select
|
select
|
||||||
exists (
|
count(*)
|
||||||
select
|
from
|
||||||
count(*)
|
memberships
|
||||||
from
|
where
|
||||||
memberships
|
user_id = ? and room_id = ?;
|
||||||
where
|
|
||||||
user_id = ? and room_id = ?
|
|
||||||
);
|
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
.bind(player_id)
|
.bind(player_id)
|
||||||
.bind(room_id)
|
.bind(room_id)
|
||||||
.fetch_one(&mut *executor)
|
.fetch_one(&mut *executor)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(res.0)
|
Ok(res.0 > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self), name = "Storage::add_room_member")]
|
#[tracing::instrument(skip(self), name = "Storage::add_room_member")]
|
||||||
|
|
Loading…
Reference in New Issue