Dropped the nuke on the backend folder (new trait too :D)
This commit is contained in:
@@ -6,10 +6,14 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
diesel = { version = "2.0.0",features = ["postgres","r2d2","chrono"] }
|
|
||||||
dotenv = "0.15"
|
dotenv = "0.15"
|
||||||
chrono = "0.2.25"
|
chrono = "0.2.25"
|
||||||
common = { path = "../common"}
|
common = { path = "../common"}
|
||||||
actix-web = "4.0.0-rc.1"
|
|
||||||
tokio = { version = "1.17.0", features = ["full"] }
|
|
||||||
yew = { version = "0.20.0", features = ["csr"] }
|
yew = { version = "0.20.0", features = ["csr"] }
|
||||||
|
anyhow = "1.0"
|
||||||
|
futures = "0.3"
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
serde_json = "1"
|
||||||
|
sqlx = {features = ["postgres", "json", "runtime-actix-rustls", "chrono", "decimal", "uuid"] }
|
||||||
|
async-trait = {}
|
||||||
|
tokio = { version = "1.20.0", features = ["macros"]}
|
||||||
|
|||||||
@@ -1,55 +1 @@
|
|||||||
use crate::models::{Admin, AdminEmail, NewAdmin, NewAdminEmail};
|
|
||||||
use common::CommonAdmin;
|
use common::CommonAdmin;
|
||||||
use diesel::prelude::*;
|
|
||||||
|
|
||||||
pub fn listadmins(connection: &mut PgConnection) -> String {
|
|
||||||
use crate::schema::admins::dsl::*;
|
|
||||||
let query = admins.load::<Admin>(connection).expect("KANKER");
|
|
||||||
let admin_list = query
|
|
||||||
.iter()
|
|
||||||
.map(|admin| format!("{} {}\n", admin.name, admin.address))
|
|
||||||
.collect();
|
|
||||||
return admin_list;
|
|
||||||
}
|
|
||||||
pub fn addmin(connection: &mut PgConnection, new_admin: NewAdmin) {
|
|
||||||
use crate::schema::admins::dsl::*;
|
|
||||||
diesel::insert_into(admins)
|
|
||||||
.values(&new_admin)
|
|
||||||
.execute(connection)
|
|
||||||
.expect("LOL DEAD NOT WORKING INSERTION");
|
|
||||||
}
|
|
||||||
pub fn addmail(connection: &mut PgConnection, admin_email: String, inserted_id: i32) {
|
|
||||||
use crate::schema::admin_emails::dsl::*;
|
|
||||||
let inserted_email = NewAdminEmail {
|
|
||||||
admin_id: &inserted_id,
|
|
||||||
email: &admin_email,
|
|
||||||
};
|
|
||||||
diesel::insert_into(admin_emails)
|
|
||||||
.values(inserted_email)
|
|
||||||
.execute(connection)
|
|
||||||
.expect("You FOOL! You didn't put an email in there");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn listadminmails(connection: &mut PgConnection) {
|
|
||||||
use crate::schema::admin_emails::dsl::*;
|
|
||||||
let results = admin_emails
|
|
||||||
.load::<AdminEmail>(connection)
|
|
||||||
.expect("hecc D:");
|
|
||||||
for addmail in results {
|
|
||||||
println!("{} {}", addmail.email, addmail.admin_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_admin(connection: &mut PgConnection, admin_id: i32) -> CommonAdmin {
|
|
||||||
use crate::schema::admins::dsl::*;
|
|
||||||
let admin = &mut admins
|
|
||||||
.filter(id.eq(admin_id))
|
|
||||||
.limit(1)
|
|
||||||
.load::<Admin>(connection)
|
|
||||||
.expect("no admins :(")[0];
|
|
||||||
return CommonAdmin {
|
|
||||||
id: admin.id,
|
|
||||||
name: String::from(&admin.name),
|
|
||||||
address: String::from(&admin.address),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,38 +1,2 @@
|
|||||||
use crate::models::{Driver, NewDriver};
|
|
||||||
use common::CommonDriver;
|
|
||||||
use diesel::{prelude::*, query_builder::SqlQuery, sql_query};
|
|
||||||
|
|
||||||
pub fn listdrivers(connection: &mut PgConnection) -> Vec<CommonDriver> {
|
|
||||||
let query = sql_query("SELECT * FROM drivers WHERE id = 10").load::<Driver>(connection);
|
|
||||||
let mut drivers: Vec<CommonDriver> = Vec::new();
|
|
||||||
for driver in query.unwrap() {
|
|
||||||
drivers.push(CommonDriver {
|
|
||||||
id: driver.id,
|
|
||||||
name: driver.name,
|
|
||||||
address: driver.address,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return drivers;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn addriver(connection: &mut PgConnection, new_driver: NewDriver) {
|
|
||||||
use crate::schema::drivers::dsl::*;
|
|
||||||
diesel::insert_into(drivers)
|
|
||||||
.values(&new_driver)
|
|
||||||
.execute(connection)
|
|
||||||
.expect("Couldn't insert new driver :)");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_driver(connection: &mut PgConnection, driver_id: i32) -> CommonDriver {
|
|
||||||
use crate::schema::drivers::dsl::*;
|
|
||||||
let driver = &mut drivers
|
|
||||||
.filter(id.eq(driver_id))
|
|
||||||
.limit(1)
|
|
||||||
.load::<Driver>(connection)
|
|
||||||
.expect("no drivers :(")[0];
|
|
||||||
return CommonDriver {
|
|
||||||
id: driver.id,
|
|
||||||
name: String::from(&driver.name),
|
|
||||||
address: String::from(&driver.address),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,34 +1,16 @@
|
|||||||
use std::env;
|
|
||||||
pub mod admin_data;
|
pub mod admin_data;
|
||||||
pub mod driver_data;
|
pub mod driver_data;
|
||||||
pub mod models;
|
|
||||||
pub mod radar_data;
|
pub mod radar_data;
|
||||||
pub mod schema;
|
|
||||||
pub mod ticket_data;
|
pub mod ticket_data;
|
||||||
pub mod vehicle_data;
|
pub mod vehicle_data;
|
||||||
use diesel::{Connection, PgConnection};
|
use async_trait::async_trait;
|
||||||
use dotenv::dotenv;
|
use sqlx::PgPool;
|
||||||
|
|
||||||
//boiler plate :D
|
//Nuke happened here but we got POOLS :DDDDDD
|
||||||
pub fn establish_connection() -> PgConnection {
|
#[async_trait]
|
||||||
dotenv().ok();
|
pub trait SqlStruct {
|
||||||
let database_url = env::var("DATABASE_URL").expect("fix your .env idot");
|
async fn add(&self, pool: &PgPool);
|
||||||
PgConnection::establish(&database_url)
|
async fn delete(&self, pool: &PgPool);
|
||||||
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url))
|
async fn listall(&self, pool: &PgPool);
|
||||||
|
async fn join(&self, join_target: impl SqlStruct, pool: &PgPool);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
//Pool instead
|
|
||||||
|
|
||||||
// pub type PgPool = r2d2::Pool<ConnectionManager<PgConnection>>;
|
|
||||||
// pub type PgPooledConnection = PooledConnection<ConnectionManager<PgConnection>>;
|
|
||||||
// fn init_pool(database_url: &str) -> Result<PgPool, PoolError> {
|
|
||||||
// let manager = ConnectionManager::<PgConnection>::new(database_url);
|
|
||||||
// Pool::builder().build(manager)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// pub fn establish_connection() -> PgPool {
|
|
||||||
// dotenv().ok();
|
|
||||||
//
|
|
||||||
// let database_url = env::var("DATABASE_URL").expect("pls obama put the link this time");
|
|
||||||
// init_pool(&database_url).expect("Failed to create pool")
|
|
||||||
// }
|
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
use crate::schema::*;
|
|
||||||
use diesel::{data_types::PgDate, prelude::*};
|
|
||||||
|
|
||||||
//Admins
|
|
||||||
#[derive(Queryable, Debug, AsChangeset, Identifiable)]
|
|
||||||
pub struct Admin {
|
|
||||||
pub id: i32,
|
|
||||||
pub name: String,
|
|
||||||
pub address: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Insertable)]
|
|
||||||
#[diesel(table_name = admins)]
|
|
||||||
pub struct NewAdmin<'a> {
|
|
||||||
pub id: i32,
|
|
||||||
pub name: &'a str,
|
|
||||||
pub address: &'a str,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Queryable, AsChangeset, Associations)]
|
|
||||||
#[diesel(belongs_to(Admin))]
|
|
||||||
pub struct AdminEmail {
|
|
||||||
pub admin_id: i32,
|
|
||||||
pub email: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Insertable, Associations)]
|
|
||||||
#[diesel(belongs_to(Admin))]
|
|
||||||
#[diesel(table_name = admin_emails)]
|
|
||||||
pub struct NewAdminEmail<'a> {
|
|
||||||
pub admin_id: &'a i32,
|
|
||||||
pub email: &'a str,
|
|
||||||
}
|
|
||||||
|
|
||||||
//Ticket things
|
|
||||||
#[derive(Queryable)]
|
|
||||||
pub struct Ticket {
|
|
||||||
pub id: i32,
|
|
||||||
pub category: String,
|
|
||||||
pub description: String,
|
|
||||||
pub issue_date: PgDate,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Insertable)]
|
|
||||||
#[diesel(table_name = tickets)]
|
|
||||||
pub struct NewTicket<'a> {
|
|
||||||
pub id: i32,
|
|
||||||
pub category: &'a str,
|
|
||||||
pub description: &'a str,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Insertable)]
|
|
||||||
#[diesel(table_name = issued_tickets)]
|
|
||||||
pub struct IssuedTicket {
|
|
||||||
ticket: i32,
|
|
||||||
vehicle: String,
|
|
||||||
driver: Option<i32>,
|
|
||||||
officer: i32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Insertable)]
|
|
||||||
#[diesel(table_name = auto_issued_tickets)]
|
|
||||||
pub struct AutoIssuedTicket<'a> {
|
|
||||||
ticket: &'a i32,
|
|
||||||
vehicle: &'a str,
|
|
||||||
driver: Option<i32>,
|
|
||||||
radar: &'a i32,
|
|
||||||
}
|
|
||||||
|
|
||||||
//Drivers
|
|
||||||
#[derive(Queryable, AsChangeset, Identifiable, QueryableByName)]
|
|
||||||
#[table_name = "drivers"]
|
|
||||||
pub struct Driver {
|
|
||||||
pub id: i32,
|
|
||||||
pub name: String,
|
|
||||||
pub address: String,
|
|
||||||
pub reg_date: PgDate,
|
|
||||||
pub birthdate: PgDate,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Insertable)]
|
|
||||||
#[diesel(table_name = drivers)]
|
|
||||||
pub struct NewDriver<'a> {
|
|
||||||
pub id: i32,
|
|
||||||
pub name: &'a str,
|
|
||||||
pub address: &'a str,
|
|
||||||
reg_date: PgDate,
|
|
||||||
birthdate: PgDate,
|
|
||||||
}
|
|
||||||
|
|
||||||
//Vehicles
|
|
||||||
#[derive(Queryable, QueryableByName)]
|
|
||||||
#[diesel(belongs_to(Driver), table_name = vehicles)]
|
|
||||||
pub struct Vehicle {
|
|
||||||
pub model: Option<String>,
|
|
||||||
pub color: Option<String>,
|
|
||||||
pub chasse_num: Option<i32>,
|
|
||||||
pub plate_num: String,
|
|
||||||
pub vehicle_type: String,
|
|
||||||
pub category: String,
|
|
||||||
pub owner: Option<i32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Queryable)]
|
|
||||||
pub struct Radar {
|
|
||||||
pub id: i32,
|
|
||||||
pub category: Option<String>,
|
|
||||||
pub address: Option<String>,
|
|
||||||
}
|
|
||||||
@@ -1,19 +1,2 @@
|
|||||||
use common::CommonRadar;
|
|
||||||
use diesel::prelude::*;
|
|
||||||
use diesel::PgConnection;
|
|
||||||
|
|
||||||
use crate::models::Radar;
|
|
||||||
|
|
||||||
pub fn get_radar(connection: &mut PgConnection, radar_id: i32) -> CommonRadar {
|
|
||||||
use crate::schema::radars::dsl::*;
|
|
||||||
let radar = &mut radars
|
|
||||||
.filter(id.eq(radar_id))
|
|
||||||
.limit(1)
|
|
||||||
.load::<Radar>(connection)
|
|
||||||
.expect("no radars :(")[0];
|
|
||||||
return CommonRadar {
|
|
||||||
id: radar.id,
|
|
||||||
category: radar.category.clone(),
|
|
||||||
address: radar.address.clone(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,131 +0,0 @@
|
|||||||
// @generated automatically by Diesel CLI.
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
admin_emails (admin_id, email) {
|
|
||||||
admin_id -> Int4,
|
|
||||||
email -> Text,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
admins (id) {
|
|
||||||
id -> Int4,
|
|
||||||
name -> Text,
|
|
||||||
address -> Text,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
auto_issued_tickets (ticket) {
|
|
||||||
ticket -> Int4,
|
|
||||||
vehicle -> Text,
|
|
||||||
driver -> Nullable<Int4>,
|
|
||||||
radar -> Int4,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
driver_phones (driver, number) {
|
|
||||||
driver -> Int4,
|
|
||||||
number -> Int4,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
drivers (id) {
|
|
||||||
id -> Int4,
|
|
||||||
name -> Text,
|
|
||||||
address -> Text,
|
|
||||||
reg_date -> Date,
|
|
||||||
birthdate -> Date,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
issued_tickets (ticket) {
|
|
||||||
ticket -> Int4,
|
|
||||||
vehicle -> Text,
|
|
||||||
driver -> Nullable<Int4>,
|
|
||||||
officer -> Int4,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
officer_emails (officer, email) {
|
|
||||||
officer -> Int4,
|
|
||||||
email -> Text,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
officer_phones (officer, number) {
|
|
||||||
officer -> Int4,
|
|
||||||
number -> Int4,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
officers (badge_num) {
|
|
||||||
badge_num -> Int4,
|
|
||||||
id -> Text,
|
|
||||||
jurisdiction -> Nullable<Text>,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
radars (id) {
|
|
||||||
id -> Int4,
|
|
||||||
category -> Nullable<Text>,
|
|
||||||
address -> Nullable<Text>,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
tickets (id) {
|
|
||||||
id -> Int4,
|
|
||||||
category -> Text,
|
|
||||||
description -> Text,
|
|
||||||
issue_date -> Date,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
vehicles (plate_num) {
|
|
||||||
model -> Nullable<Text>,
|
|
||||||
color -> Nullable<Text>,
|
|
||||||
chasse_num -> Nullable<Int4>,
|
|
||||||
plate_num -> Text,
|
|
||||||
vehicle_type -> Text,
|
|
||||||
category -> Text,
|
|
||||||
owner -> Nullable<Int4>,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::joinable!(admin_emails -> admins (admin_id));
|
|
||||||
diesel::joinable!(auto_issued_tickets -> drivers (driver));
|
|
||||||
diesel::joinable!(auto_issued_tickets -> radars (radar));
|
|
||||||
diesel::joinable!(auto_issued_tickets -> tickets (ticket));
|
|
||||||
diesel::joinable!(auto_issued_tickets -> vehicles (vehicle));
|
|
||||||
diesel::joinable!(driver_phones -> drivers (driver));
|
|
||||||
diesel::joinable!(issued_tickets -> drivers (driver));
|
|
||||||
diesel::joinable!(issued_tickets -> officers (officer));
|
|
||||||
diesel::joinable!(issued_tickets -> tickets (ticket));
|
|
||||||
diesel::joinable!(issued_tickets -> vehicles (vehicle));
|
|
||||||
diesel::joinable!(officer_emails -> officers (officer));
|
|
||||||
diesel::joinable!(officer_phones -> officers (officer));
|
|
||||||
diesel::joinable!(vehicles -> drivers (owner));
|
|
||||||
|
|
||||||
diesel::allow_tables_to_appear_in_same_query!(
|
|
||||||
admin_emails,
|
|
||||||
admins,
|
|
||||||
auto_issued_tickets,
|
|
||||||
driver_phones,
|
|
||||||
drivers,
|
|
||||||
issued_tickets,
|
|
||||||
officer_emails,
|
|
||||||
officer_phones,
|
|
||||||
officers,
|
|
||||||
radars,
|
|
||||||
tickets,
|
|
||||||
vehicles,
|
|
||||||
);
|
|
||||||
@@ -1,67 +1,2 @@
|
|||||||
use crate::{
|
|
||||||
models::{AutoIssuedTicket, IssuedTicket, NewTicket, Ticket},
|
|
||||||
schema::{drivers, issued_tickets, tickets},
|
|
||||||
};
|
|
||||||
use common::CommonTicket;
|
|
||||||
use diesel::prelude::*;
|
|
||||||
|
|
||||||
pub fn create_ticket(connection: &mut PgConnection, ticket: NewTicket) {
|
|
||||||
use crate::schema::tickets::dsl::*;
|
|
||||||
diesel::insert_into(tickets)
|
|
||||||
.values(&ticket)
|
|
||||||
.execute(connection)
|
|
||||||
.expect("Didn't save ticket AAAAAA");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_tickets(connection: &mut PgConnection, driver_id: i32) -> Vec<CommonTicket> {
|
|
||||||
//Chonky join function for the sake of my life :))
|
|
||||||
let join = tickets::table
|
|
||||||
.left_join(issued_tickets::table)
|
|
||||||
.select((
|
|
||||||
tickets::id,
|
|
||||||
tickets::category,
|
|
||||||
tickets::description,
|
|
||||||
tickets::issue_date,
|
|
||||||
))
|
|
||||||
.filter(issued_tickets::driver.eq(driver_id));
|
|
||||||
let tickets_by_driver = join.load::<Ticket>(connection).expect("oh no!");
|
|
||||||
let common_ticket_output = tickets_by_driver
|
|
||||||
.iter()
|
|
||||||
.map(|ticket| CommonTicket {
|
|
||||||
id: ticket.id,
|
|
||||||
category: String::from(&ticket.category),
|
|
||||||
description: String::from(&ticket.description),
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
return common_ticket_output;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_ticket(connection: &mut PgConnection, tickid: i32) -> CommonTicket {
|
|
||||||
use crate::schema::tickets::dsl::*;
|
|
||||||
let ticket = &mut tickets
|
|
||||||
.filter(id.eq(tickid))
|
|
||||||
.limit(1)
|
|
||||||
.load::<Ticket>(connection)
|
|
||||||
.expect("no tickets :(")[0];
|
|
||||||
return CommonTicket {
|
|
||||||
id: ticket.id,
|
|
||||||
category: String::from(&ticket.category),
|
|
||||||
description: String::from(&ticket.description),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn issue_ticket(connection: &mut PgConnection, issued_ticket: IssuedTicket) {
|
|
||||||
use crate::schema::issued_tickets::dsl::*;
|
|
||||||
diesel::insert_into(issued_tickets)
|
|
||||||
.values(issued_ticket)
|
|
||||||
.execute(connection)
|
|
||||||
.expect("PAINNNN IT NO WORKEY (issued tickets)");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn auto_issue_ticket(connection: &mut PgConnection, issued_ticket: AutoIssuedTicket) {
|
|
||||||
use crate::schema::auto_issued_tickets::dsl::*;
|
|
||||||
diesel::insert_into(auto_issued_tickets)
|
|
||||||
.values(issued_ticket)
|
|
||||||
.execute(connection)
|
|
||||||
.expect("PAINNNN IT NO WORKEY (issued tickets)");
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,41 +1,2 @@
|
|||||||
use common::CommonVehicle;
|
|
||||||
use diesel::prelude::*;
|
|
||||||
use diesel::PgConnection;
|
|
||||||
|
|
||||||
use crate::models::Vehicle;
|
|
||||||
|
|
||||||
pub fn get_vehicle(connection: &mut PgConnection, vehicle_id: String) -> CommonVehicle {
|
|
||||||
use crate::schema::vehicles::dsl::*;
|
|
||||||
let vehicle = &mut vehicles
|
|
||||||
.filter(plate_num.eq(vehicle_id))
|
|
||||||
.limit(1)
|
|
||||||
.load::<Vehicle>(connection)
|
|
||||||
.expect("no vehicles :(")[0];
|
|
||||||
return CommonVehicle {
|
|
||||||
model: vehicle.model.clone(),
|
|
||||||
color: vehicle.color.clone(),
|
|
||||||
chasse_num: vehicle.chasse_num,
|
|
||||||
plate_num: vehicle.plate_num.clone(),
|
|
||||||
vehicle_type: vehicle.vehicle_type.clone(),
|
|
||||||
category: vehicle.category.clone(),
|
|
||||||
owner: vehicle.owner,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// pub fn insert_vehicle(connection: &mut PgConnection, vehicle: CommonVehicle) -> bool {
|
|
||||||
// use crate::schema::vehicles::dsl::*;
|
|
||||||
// //convert CommonVehicle to Vehicle
|
|
||||||
// let vehicle = Vehicle {
|
|
||||||
// model: vehicle.model,
|
|
||||||
// color: vehicle.color,
|
|
||||||
// chasse_num: vehicle.chasse_num,
|
|
||||||
// plate_num: vehicle.plate_num,
|
|
||||||
// vehicle_type: vehicle.vehicle_type,
|
|
||||||
// category: vehicle.category,
|
|
||||||
// owner: vehicle.owner,
|
|
||||||
// };
|
|
||||||
// diesel::insert_into(vehicles)
|
|
||||||
// .values(&vehicle)
|
|
||||||
// .execute(connection)
|
|
||||||
// .is_ok()
|
|
||||||
// }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user