Skip to content

Instantly share code, notes, and snippets.

@luisvonmuller
Last active July 29, 2020 01:48
Show Gist options
  • Save luisvonmuller/6a080d08910d6e9376b603c654687eba to your computer and use it in GitHub Desktop.
Save luisvonmuller/6a080d08910d6e9376b603c654687eba to your computer and use it in GitHub Desktop.
/* Import macros and others */
use crate::schema::*;
/* For beeing able to serialize */
use serde::Serialize;
#[derive(Debug, Queryable, Serialize)]
pub struct Hero {
pub id: i32,
pub fantasy_name: String,
pub real_name: Option<String>,
pub spotted_photo: String,
pub strength_level: i32,
}
#[derive(Debug, Insertable, AsChangeset)]
#[table_name="heroes"]
pub struct NewHero<'x> {
pub fantasy_name: &'x str,
pub real_name: Option<&'x str>,
pub spotted_photo: String,
pub strength_level: i32,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment