create own default_destination table to remove clutter; Fixes #646
This commit is contained in:
21
src/model/distance.rs
Normal file
21
src/model/distance.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use serde::Serialize;
|
||||
use sqlx::{FromRow, SqlitePool};
|
||||
|
||||
#[derive(FromRow, Serialize, Clone, Debug)]
|
||||
pub struct Distance {
|
||||
pub id: i64,
|
||||
pub destination: String,
|
||||
pub distance_in_km: i64,
|
||||
}
|
||||
|
||||
impl Distance {
|
||||
pub async fn all(db: &SqlitePool) -> Vec<Self> {
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"SELECT id, destination, distance_in_km FROM distance;"
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user