Created
October 24, 2019 11:35
-
-
Save louis030195/6ad426ac56f6864e1321ab1d406ff330 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(proc_macro_derive_resolution_fallback)] | |
pub mod handler; | |
pub mod repository; | |
use mongodb::bson; | |
#[derive(Serialize, Deserialize, Debug, Clone)] | |
pub struct Cat { | |
#[serde(rename = "_id")] // Use MongoDB's special primary key field name when serializing | |
pub id: Option<bson::oid::ObjectId>, | |
pub name: Option<String>, | |
pub color: Option<String>, | |
pub age: Option<i32>, | |
} | |
#[derive(Serialize, Deserialize, Debug, Clone)] | |
pub struct InsertableCat { | |
pub name: Option<String>, | |
pub color: Option<String>, | |
pub age: Option<i32>, | |
} | |
impl InsertableCat { | |
fn from_cat(cats: Cat) -> InsertableCat { | |
InsertableCat { | |
name: cats.name, | |
color: cats.color, | |
age: cats.age, | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment