| 203 | } |
| 204 | |
| 205 | pub async fn get_account(self, email: String) -> Result<Account, Error> { |
| 206 | match sqlx::query("SELECT * from accounts where email = $1") |
| 207 | .bind(email) |
| 208 | .map(|row: PgRow| Account { |
| 209 | id: Some(AccountId(row.get("id"))), |
| 210 | email: row.get("email"), |
| 211 | password: row.get("password"), |
| 212 | }) |
| 213 | .fetch_one(&self.connection) |
| 214 | .await |
| 215 | { |
| 216 | Ok(account) => Ok(account), |
| 217 | Err(error) => { |
| 218 | tracing::event!(tracing::Level::ERROR, "{:?}", error); |
| 219 | Err(Error::DatabaseQueryError(error)) |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | } |