/// Update a zettel when notified of a file name change
Update a zettel when notified of a file name change
Update a zettel when notified of a file name change
pub async fn remove(conn: &mut SqliteConnection, old: &Path) -> Result<(), anyhow::Error> {
        let id = query::get_by_path(conn, old.to_str().unwrap())
            .await?
            .zettel_id;
        conn.execute(
            sqlx::query_as::<_, Zettel>("DROP FROM TABLE zettels WHERE zettel_id = ? ")
                .bind(old.file_name().unwrap().to_str())
                .bind(&id),
        )
        .await?;
        conn.execute(
            sqlx::query_as::<_, Zettel>("DROP FROM TABLE headers WHERE zettel_id = ?")
                .bind(old.file_name().unwrap().to_str())
                .bind(&id),
        )
        .await?;
        conn.execute(
            sqlx::query_as::<_, Zettel>("DROP FROM TABLE links WHERE zettel_id = ?")
                .bind(old.file_name().unwrap().to_str())
                .bind(&id),
        )
        .await?;
        conn.execute(
            sqlx::query_as::<_, Zettel>("DROP FROM TABLE tags WHERE zettel_id = ?")
                .bind(old.file_name().unwrap().to_str())
                .bind(&id),
        )
        .await?;
        conn.execute(
            sqlx::query_as::<_, Zettel>("DROP FROM TABLE full_text WHERE zettel_id = ?")
                .bind(old.file_name().unwrap().to_str())
                .bind(&id),
        )
        .await?;
        Ok(())
    }
pub async fn remove ( conn : & mut SqliteConnection , old : & Path ) -> Result < ( ) , anyhow :: Error > { let id = query :: get_by_path ( conn , old . to_str ( ) . unwrap ( ) ) . await ? . zettel_id ; conn . execute ( sqlx :: query_as :: < _ , Zettel > ( " " ) . bind ( old . file_name ( ) . unwrap ( ) . to_str ( ) ) . bind ( & id ) , ) . await ? ; conn . execute ( sqlx :: query_as :: < _ , Zettel > ( " " ) . bind ( old . file_name ( ) . unwrap ( ) . to_str ( ) ) . bind ( & id ) , ) . await ? ; conn . execute ( sqlx :: query_as :: < _ , Zettel > ( " " ) . bind ( old . file_name ( ) . unwrap ( ) . to_str ( ) ) . bind ( & id ) , ) . await ? ; conn . execute ( sqlx :: query_as :: < _ , Zettel > ( " " ) . bind ( old . file_name ( ) . unwrap ( ) . to_str ( ) ) . bind ( & id ) , ) . await ? ; conn . execute ( sqlx :: query_as :: < _ , Zettel > ( " " ) . bind ( old . file_name ( ) . unwrap ( ) . to_str ( ) ) . bind ( & id ) , ) . await ? ; Ok ( ( ) ) }
Update a zettel when notified of a file name change
Update a zettel when notified of a file name change
conn
&mut SqliteConnection
old
&Path