show owner of boat in boat km list
All checks were successful
CI/CD Pipeline / test (push) Successful in 11m18s
CI/CD Pipeline / deploy-staging (push) Successful in 5m32s
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
2024-04-06 18:55:38 +02:00
parent 934795abd8
commit 8b07ace876
2 changed files with 19 additions and 2 deletions

View File

@ -343,6 +343,14 @@ ORDER BY amount_seats DESC
Ok(())
}
pub async fn owner(&self, db: &SqlitePool) -> Option<User> {
if let Some(owner_id) = self.owner {
Some(User::find_by_id(db, owner_id as i32).await.unwrap())
} else {
None
}
}
pub async fn delete(&self, db: &SqlitePool) {
sqlx::query!("DELETE FROM boat WHERE id=?", self.id)
.execute(db)