Browse Source

Checking what happens when a query doesn't return a value

master
Julio Biason 3 years ago
parent
commit
4520abd55e
  1. 9
      sqlxtest/src/main.rs

9
sqlxtest/src/main.rs

@ -83,11 +83,14 @@ async fn main() -> Result<(), sqlx::Error> {
repo.save(&record).await?;
} else if command == "remove" {
println!("Should remove \"{}\"", value);
if let Ok(record) = repo.find_by_description(&value).await {
match repo.find_by_description(&value).await {
Ok(record) => {
repo.delete(&record).await?;
println!("Removed");
} else {
println!("Label does not exist");
}
Err(err) => {
println!("Label does not exist: {:?}", err);
}
}
}
Ok(())

Loading…
Cancel
Save