Last active
April 1, 2018 11:51
-
-
Save butlerx/b45cbc34ce8ad72389414068e7a0dc2c to your computer and use it in GitHub Desktop.
stv_db
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
use std::time::SystemTime; | |
#[derive(Queryable)] | |
pub struct Election { | |
pub id: i32, | |
pub title: String, | |
pub draft: bool, | |
pub candidates: Vec<i32>, | |
pub created_at: SystemTime, | |
pub started_at: SystemTime, | |
pub finished_at: SystemTime, | |
} | |
#[derive(Queryable)] | |
pub struct Ballot { | |
pub ballot_id: i32, | |
pub created_at: SystemTime, | |
pub user_id: i32, | |
pub election_id: i32, | |
pub preference: Vec<i32>, | |
} | |
#[derive(Queryable)] | |
pub struct Voter { | |
pub user_id: i32, | |
pub user_name: String, | |
} | |
#[derive(Queryable)] | |
pub struct Candidate { | |
pub candidate_id: i32, | |
pub name: String, | |
} |
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
table! { | |
election(id) { | |
id -> Integer, | |
title -> Text, | |
draft -> Bool, | |
candidates -> Array<Integer>, | |
created_at -> Timestamp, | |
started_at -> Timestamp, | |
finished_at -> Timestamp, | |
} | |
} | |
table! { | |
ballot(ballot_id) { | |
ballot_id -> Integer, | |
created_at -> Timestamp, | |
user_id -> Integer, | |
election_id -> Integer, | |
preference -> Array<Integer>, | |
} | |
} | |
table! { | |
voter(user_id) { | |
user_id -> Integer, | |
user_name -> Text, | |
} | |
} | |
table! { | |
candidate(candidate_id) { | |
candidate_id -> Integer, | |
name -> Text, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment