/// Insert new user in db as part of new user registration.
Insert new user in db as part of new user registration.
Insert new user in db as part of new user registration .
pub fn insert_new_user(
    first_n: &str,
    last_n: &str,
    email_str: &str,
    passwd: &str,
    conn: &PgConnection,
) -> Result<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 new_user = models::User {
        user_id: Uuid::new_v4(),
        first_name: first_n.to_owned(),
        last_name: last_n.to_owned(),
        email: email_str.to_owned(),
        password: passwd.to_owned(),
        created_at: chrono::offset::Utc::now().naive_utc(),
    };
    diesel::insert_into(users).values(&new_user).execute(conn).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
    Ok(new_user)
}
pub fn insert_new_user ( first_n : & str , last_n : & str , email_str : & str , passwd : & str , conn : & PgConnection , ) -> Result < 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 new_user = models :: User { user_id : Uuid :: new_v4 ( ) , first_name : first_n . to_owned ( ) , last_name : last_n . to_owned ( ) , email : email_str . to_owned ( ) , password : passwd . to_owned ( ) , created_at : chrono :: offset :: Utc :: now ( ) . naive_utc ( ) , } ; diesel :: insert_into ( users ) . values ( & new_user ) . execute ( conn ) . map_err ( | _ | StatusCode :: INTERNAL_SERVER_ERROR ) ? ; Ok ( new_user ) }
Insert new user in db as part of new user registration.
Insert new user in db as part of new user registration .
first_n
&str
last_n
&str
email_str
&str
passwd
&str
conn
&PgConnection