mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-28 12:11:53 +01:00
Updating environments!
This commit is contained in:
@@ -252,6 +252,27 @@ pub async fn create_environment(
|
||||
get_environment(&id, pool).await
|
||||
}
|
||||
|
||||
pub async fn update_environment(
|
||||
id: &str,
|
||||
data: HashMap<String, JsonValue>,
|
||||
pool: &Pool<Sqlite>,
|
||||
) -> Result<Environment, sqlx::Error> {
|
||||
println!("DATA: {}", data.clone().len());
|
||||
let json_data = Json(data);
|
||||
sqlx::query!(
|
||||
r#"
|
||||
UPDATE environments
|
||||
SET (data, updated_at) = (?, CURRENT_TIMESTAMP)
|
||||
WHERE id = ?;
|
||||
"#,
|
||||
json_data,
|
||||
id,
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
get_environment(id, pool).await
|
||||
}
|
||||
|
||||
pub async fn get_environment(id: &str, pool: &Pool<Sqlite>) -> Result<Environment, sqlx::Error> {
|
||||
sqlx::query_as!(
|
||||
Environment,
|
||||
|
||||
Reference in New Issue
Block a user