add planned_trip functionality
This commit is contained in:
33
src/model/tripdetails.rs
Normal file
33
src/model/tripdetails.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, SqlitePool};
|
||||
|
||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||
pub struct TripDetails {
|
||||
pub id: i64,
|
||||
planned_starting_time: String,
|
||||
max_people: i32,
|
||||
day: String,
|
||||
notes: Option<String>,
|
||||
}
|
||||
|
||||
impl TripDetails {
|
||||
pub async fn new(
|
||||
db: &SqlitePool,
|
||||
planned_starting_time: String,
|
||||
max_people: i32,
|
||||
day: String,
|
||||
notes: Option<String>,
|
||||
) -> i64 {
|
||||
let query = sqlx::query!(
|
||||
"INSERT INTO trip_details(planned_starting_time, max_people, day, notes) VALUES(?, ?, ?, ?)" ,
|
||||
planned_starting_time,
|
||||
max_people,
|
||||
day,
|
||||
notes
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap(); //TODO: fixme
|
||||
query.last_insert_rowid()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user