aboutsummaryrefslogtreecommitdiff
path: root/examples/tutorial02/polls/models.rs
blob: fb8be8f6914f120a916b4b4651be8a66c1bf706e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use tosin::db::models::{Model, Id, gather};

#[derive(Model)]
pub struct Question {
    id: Option<Id>,
    #[model(max_length=200)]
    question_text: String,
    /// date published
    pub_date: time::PrimitiveDateTime,
}

#[derive(Model)]
pub struct Choice {
    id: Option<Id>,
    #[model(Question, on_delete=Cascade)]
    question: Id,
    #[model(max_length=200)]
    choice_text: String,
    #[model(default = 0)]
    votes: usize,
}

gather!();