-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.rs
39 lines (33 loc) · 999 Bytes
/
model.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use diesel::{Associations, Identifiable, Insertable, Queryable, Selectable};
use crate::bot::core::db::schema::telegram_accounts;
use crate::bot::core::db::schema::users;
#[derive(Insertable)]
#[diesel(table_name = users)]
pub struct NewUser<'a> {
pub name: &'a str,
pub start: &'a str,
pub role: &'a str,
}
#[derive(Queryable, Selectable, Identifiable, PartialEq, Debug)]
#[diesel(table_name = users)]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct User {
pub id: i64,
pub name: String,
pub start: String,
pub role: String,
}
#[derive(Insertable)]
#[diesel(table_name = telegram_accounts)]
pub struct NewTelegramAccount<'a> {
pub id: &'a i64,
pub user_id: &'a i64,
}
#[derive(Queryable, Selectable, Identifiable, Associations, PartialEq, Debug)]
#[diesel(table_name = telegram_accounts)]
#[diesel(belongs_to(User))]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct TelegramAccount {
pub id: i64,
pub user_id: i64,
}