push
This commit is contained in:
27
src/model/usertrip.rs
Normal file
27
src/model/usertrip.rs
Normal file
@ -0,0 +1,27 @@
|
||||
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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user