Skip to content

Instantly share code, notes, and snippets.

@erickt
Created February 19, 2017 22:23
Show Gist options
  • Save erickt/c9a66009926d49f07a5fd940260793d5 to your computer and use it in GitHub Desktop.
Save erickt/c9a66009926d49f07a5fd940260793d5 to your computer and use it in GitHub Desktop.
#[derive(Queryable)]
pub struct Account {
#[diesel(type="BigInt")]
pub id: i32,
#[diesel(name="user_name", type="Nullable<VarChar>")]
pub username: String,
#[diesel(type="BigInt")]
pub balance: i32,
}
table! {
users (non_standard_primary_key) {
non_standard_primary_key -> Integer,
name -> VarChar,
favorite_color -> Nullable<VarChar>,
}
}
#[derive(Queryable)]
#[diesel(pk="user_id")]
pub struct User {
#[diesel(type="Integer")]
user_id: i32,
#[diesel(type="VarChar")]
name: String,
#[diesel(type="Nullable<VarChar>")]
favorite_color: Option<String>,
}
#[derive(Queryable)]
#[diesel(pk="(user_id, post_id)")]
pub struct Followings {
#[diesel(type="Integer")]
pub user_id: i32,
#[diesel(type="Integer")]
pub post_id: i32,
#[diesel(type="Bool")]
pub favorited: bool,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment