rowt/src/model/usertrip.rs

28 lines
674 B
Rust
Raw Normal View History

2023-04-04 15:16:21 +02:00
use sqlx::SqlitePool;
pub struct UserTrip {}
impl UserTrip {
pub async fn new(db: &SqlitePool, user_id: i64, trip_details_id: i64) -> bool {
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();
}
}