aboutsummaryrefslogtreecommitdiff
path: root/src/models.rs
blob: fb6122ce70e968bb0edec7877b282bd57770a92f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use super::schema::{members, product};

use bigdecimal::BigDecimal;
use diesel::{Insertable, Queryable};
use serde::{Deserialize, Serialize};

#[derive(Queryable, Serialize)]
pub struct Member {
    pub id: i32,
    pub username: String,
    pub password: String,
    pub phone_number: String,
    pub email_id: String,
}

#[derive(Insertable, Deserialize)]
#[table_name = "members"]
pub struct NewMember {
    pub username: String,
    pub password: String,
    pub phone_number: String,
    pub email_id: String,
}

#[derive(Queryable, Serialize)]
pub struct Product {
    pub id: i32,
    pub name: String,
    pub kind: Option<String>,
    pub price: f32,
    pub description: Option<String>,
}

#[derive(Insertable, Deserialize)]
#[table_name = "product"]
pub struct NewProduct {
    pub name: String,
    pub kind: Option<String>,
    pub price: f32,
    pub description: Option<String>,
}