aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/models.rs22
-rw-r--r--src/schema.rs15
2 files changed, 36 insertions, 1 deletions
diff --git a/src/models.rs b/src/models.rs
index ce28ac8..fb6122c 100644
--- a/src/models.rs
+++ b/src/models.rs
@@ -1,4 +1,6 @@
1use super::schema::members; 1use super::schema::{members, product};
2
3use bigdecimal::BigDecimal;
2use diesel::{Insertable, Queryable}; 4use diesel::{Insertable, Queryable};
3use serde::{Deserialize, Serialize}; 5use serde::{Deserialize, Serialize};
4 6
@@ -19,3 +21,21 @@ pub struct NewMember {
19 pub phone_number: String, 21 pub phone_number: String,
20 pub email_id: String, 22 pub email_id: String,
21} 23}
24
25#[derive(Queryable, Serialize)]
26pub struct Product {
27 pub id: i32,
28 pub name: String,
29 pub kind: Option<String>,
30 pub price: f32,
31 pub description: Option<String>,
32}
33
34#[derive(Insertable, Deserialize)]
35#[table_name = "product"]
36pub struct NewProduct {
37 pub name: String,
38 pub kind: Option<String>,
39 pub price: f32,
40 pub description: Option<String>,
41}
diff --git a/src/schema.rs b/src/schema.rs
index 8ed6e58..b6074f2 100644
--- a/src/schema.rs
+++ b/src/schema.rs
@@ -7,3 +7,18 @@ table! {
7 email_id -> Varchar, 7 email_id -> Varchar,
8 } 8 }
9} 9}
10
11table! {
12 product (id) {
13 id -> Integer,
14 name -> Varchar,
15 kind -> Nullable<Varchar>,
16 price -> Float,
17 description -> Nullable<Varchar>,
18 }
19}
20
21allow_tables_to_appear_in_same_query!(
22 members,
23 product,
24);