mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-12-18 05:56:35 +00:00
Remove Row
.
This commit is contained in:
parent
d54f33858d
commit
9e75751b6b
1 changed files with 8 additions and 14 deletions
|
@ -79,12 +79,7 @@ struct ConfirmedSubscriber {
|
||||||
async fn get_confirmed_subscribers(
|
async fn get_confirmed_subscribers(
|
||||||
pool: &PgPool,
|
pool: &PgPool,
|
||||||
) -> Result<Vec<Result<ConfirmedSubscriber, anyhow::Error>>, anyhow::Error> {
|
) -> Result<Vec<Result<ConfirmedSubscriber, anyhow::Error>>, anyhow::Error> {
|
||||||
struct Row {
|
let confirmed_subscribers = sqlx::query!(
|
||||||
email: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
let rows = sqlx::query_as!(
|
|
||||||
Row,
|
|
||||||
r#"
|
r#"
|
||||||
SELECT email
|
SELECT email
|
||||||
FROM subscriptions
|
FROM subscriptions
|
||||||
|
@ -92,13 +87,12 @@ async fn get_confirmed_subscribers(
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.fetch_all(pool)
|
.fetch_all(pool)
|
||||||
.await?;
|
.await?
|
||||||
let confirmed_subscribers = rows
|
.into_iter()
|
||||||
.into_iter()
|
.map(|r| match SubscriberEmail::parse(r.email) {
|
||||||
.map(|r| match SubscriberEmail::parse(r.email) {
|
Ok(email) => Ok(ConfirmedSubscriber { email }),
|
||||||
Ok(email) => Ok(ConfirmedSubscriber { email }),
|
Err(error) => Err(anyhow::anyhow!(error)),
|
||||||
Err(error) => Err(anyhow::anyhow!(error)),
|
})
|
||||||
})
|
.collect();
|
||||||
.collect();
|
|
||||||
Ok(confirmed_subscribers)
|
Ok(confirmed_subscribers)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue