pub fn find_user_by_email(
    email_str: &str,
    conn: &PgConnection,
) -> Result<Option<models::User>, StatusCode> {
    // It is common when using Diesel with Actix web to import schema-related
    // modules inside a function's scope (rather than the normal module's scope)
    // to prevent import collisions and namespace pollution.
    use crate::schema::users::dsl::*;

    let user = users
        .filter(email.eq(email_str))
        .first::<models::User>(conn)
        .optional()
        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;

    Ok(user)
}
/// Find user by email. If not found then return None.
Find user by email. If not found then return None.
Find user by email . If not found then return None .
pub fn find_user_by_email(
    email_str: &str,
    conn: &PgConnection,
) -> Result<Option<models::User>, StatusCode> {
    // It is common when using Diesel with Actix web to import schema-related
    // modules inside a function's scope (rather than the normal module's scope)
    // to prevent import collisions and namespace pollution.
    use crate::schema::users::dsl::*;
    let user = users
        .filter(email.eq(email_str))
        .first::<models::User>(conn)
        .optional()
        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
    Ok(user)
}
pub fn find_user_by_email ( email_str : & str , conn : & PgConnection , ) -> Result < Option < models :: User > , StatusCode > { // It is common when using Diesel with Actix web to import schema-related // modules inside a function's scope (rather than the normal module's scope) // to prevent import collisions and namespace pollution. use crate :: schema :: users :: dsl :: * ; let user = users . filter ( email . eq ( email_str ) ) . first :: < models :: User > ( conn ) . optional ( ) . map_err ( | _ | StatusCode :: INTERNAL_SERVER_ERROR ) ? ; Ok ( user ) }
Find user by email.
Find user by email .
email_str
&str
conn
&PgConnection
email_str
&str
conn
&PgConnection