| 230 | } |
| 231 | |
| 232 | pub async fn get_account( |
| 233 | self, |
| 234 | email: String, |
| 235 | ) -> Result<Account, Error> { |
| 236 | match sqlx::query("SELECT * from accounts where email = $1") |
| 237 | .bind(email) |
| 238 | .map(|row: PgRow| Account { |
| 239 | id: Some(AccountId(row.get("id"))), |
| 240 | email: row.get("email"), |
| 241 | password: row.get("password"), |
| 242 | }) |
| 243 | .fetch_one(&self.connection) |
| 244 | .await |
| 245 | { |
| 246 | Ok(account) => Ok(account), |
| 247 | Err(error) => { |
| 248 | tracing::event!(tracing::Level::ERROR, "{:?}", error); |
| 249 | Err(Error::DatabaseQueryError(error)) |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | } |