Skip to content

Commit

Permalink
fix(user): refactor #fetch_by_token query
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulrahman1s committed Jun 20, 2022
1 parent 1240d82 commit c7fbee7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/structures/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ impl User {

// pub async fn fetch_relations(&self) {}

#[sql(crate::database::DB, "SELECT * FROM users LEFT JOIN sessions ON sessions.user_id = users.id WHERE verified = TRUE AND sessions.token = $1 LIMIT 1")]
pub async fn fetch_by_token(_token: &str) -> Result<User, rbatis::Error> {}
pub async fn fetch_by_token(token: &str) -> Result<User, rbatis::Error> {
db.fetch("SELECT * FROM users WHERE id = ( SELECT user_id FROM sessions WHERE verified = TRUE AND token = $1 )", vec![token.into()]).await
}

pub fn to_public(&self) -> Self {
Self {
Expand Down

0 comments on commit c7fbee7

Please sign in to comment.