mirror of
https://github.com/13hannes11/ics-proxy.git
synced 2024-09-06 08:01:41 +02:00
updating link from edit page works now
This commit is contained in:
11
src/model.rs
11
src/model.rs
@@ -30,6 +30,17 @@ impl Link {
|
||||
destination: rec.DESTINATION,
|
||||
})
|
||||
}
|
||||
pub async fn update(link: Link, pool: web::Data<Pool<Sqlite>>) -> Result<Link, sqlx::Error> {
|
||||
let mut tx = pool.begin().await?;
|
||||
sqlx::query("UPDATE links SET destination = $2 WHERE uuid = $1;")
|
||||
.bind(&link.uuid)
|
||||
.bind(&link.destination)
|
||||
.execute(&mut tx)
|
||||
.await?;
|
||||
|
||||
tx.commit().await?;
|
||||
Ok(link)
|
||||
}
|
||||
pub async fn create(link: Link, pool: web::Data<Pool<Sqlite>>) -> Result<Link, sqlx::Error> {
|
||||
let mut tx = pool.begin().await?;
|
||||
sqlx::query("INSERT INTO links (uuid, destination) VALUES ($1, $2);")
|
||||
|
||||
Reference in New Issue
Block a user