2023-04-04 15:16:21 +02:00
|
|
|
use sqlx::SqlitePool;
|
|
|
|
|
|
|
|
pub struct UserTrip {}
|
|
|
|
|
|
|
|
impl UserTrip {
|
2023-04-04 19:49:27 +02:00
|
|
|
pub async fn create(db: &SqlitePool, user_id: i64, trip_details_id: i64) -> bool {
|
2023-04-04 15:16:21 +02:00
|
|
|
sqlx::query!(
|
|
|
|
"INSERT INTO user_trip (user_id, trip_details_id) VALUES(?, ?)",
|
|
|
|
user_id,
|
|
|
|
trip_details_id
|
|
|
|
)
|
|
|
|
.execute(db)
|
|
|
|
.await
|
|
|
|
.is_ok()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn delete(db: &SqlitePool, user_id: i64, trip_details_id: i64) {
|
|
|
|
let _ = sqlx::query!(
|
|
|
|
"DELETE FROM user_trip WHERE user_id = ? AND trip_details_id = ?",
|
|
|
|
user_id,
|
|
|
|
trip_details_id
|
|
|
|
)
|
|
|
|
.execute(db)
|
|
|
|
.await
|
|
|
|
.is_ok();
|
|
|
|
}
|
|
|
|
}
|