pub async fn add_person(
    pool: &PgPool,
    pers: Person) -> sqlx::Result<Person> {

    let mut tx = pool.begin().await?;
    let person = sqlx::query(
        "INSERT INTO persons (full_name)
                VALUES ( $1 )
                RETURNING id, full_name;",
    )
        .bind(&pers.full_name)
        .map(|row: PgRow| Person {
            id: row.get(0),
            full_name: row.get(1),
        })
        .fetch_one(&mut tx)
        .await?;
    tx.commit().await?;

    tracing::info!("db : person added : {:?}", &person);
    Ok(person)
}
//*******************************************************************************************
// CRUD Operations on persons - musicians
//

CRUD Operations on persons - musicians
CRUD Operations on persons - musicians
pub async fn add_person(
    pool: &PgPool,
    pers: Person) -> sqlx::Result<Person> {
    let mut tx = pool.begin().await?;
    let person = sqlx::query(
        "INSERT INTO persons (full_name)
                VALUES ( $1 )
                RETURNING id, full_name;",
    )
        .bind(&pers.full_name)
        .map(|row: PgRow| Person {
            id: row.get(0),
            full_name: row.get(1),
        })
        .fetch_one(&mut tx)
        .await?;
    tx.commit().await?;
    tracing::info!("db : person added : {:?}", &person);
    Ok(person)
}
pub async fn add_person ( pool : & PgPool , pers : Person ) -> sqlx :: Result < Person > { let mut tx = pool . begin ( ) . await ? ; let person = sqlx :: query ( " " , ) . bind ( & pers . full_name ) . map ( | row : PgRow | Person { id : row . get ( 0 ) , full_name : row . get ( 1 ) , } ) . fetch_one ( & mut tx ) . await ? ; tx . commit ( ) . await ? ; tracing :: info ! ( " " person ) ; Ok ( person ) }
CRUD Operations on persons - musicians
CRUD Operations on persons - musicians
pool
&PgPool
pers
Person