backend/src/model.rs
2023-08-30 09:27:04 +02:00

61 lines
1.4 KiB
Rust

use time::Date;
#[derive(Queryable, Selectable)]
#[diesel(table_name = crate::schema::users)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct User {
pub id: i64,
pub username: String,
pub email: String,
pub salt: String,
pub pass: String,
pub joined: Date,
}
#[derive(Insertable)]
#[diesel(table_name = crate::schema::users)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct NewUser {
pub username: String,
pub email: String,
pub salt: String,
pub pass: String,
pub joined: Date,
}
#[derive(Queryable, Selectable)]
#[diesel(table_name = crate::schema::channels)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct Channel {
pub id: i64,
pub user: i64,
pub name: String,
pub bio: Option<String>,
}
#[derive(Insertable)]
#[diesel(table_name = crate::schema::channels)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct NewChannel {
pub user: i64,
pub name: String,
pub bio: Option<String>,
}
#[derive(Queryable, Selectable)]
#[diesel(table_name = crate::schema::subscription)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct Subscription {
pub subscription_id: i64,
pub user_id: i64,
pub channel_id: i64,
}
#[derive(Insertable)]
#[diesel(table_name = crate::schema::subscription)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct NewSubscription {
pub user_id: i64,
pub channel_id: i64,
}