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