backend/src/model.rs

61 lines
1.4 KiB
Rust
Raw Normal View History

2023-08-27 17:16:10 +02:00
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)]
2023-08-30 09:22:44 +02:00
#[diesel(check_for_backend(diesel::mysql::Mysql))]
2023-08-27 17:16:10 +02:00
pub struct NewUser {
pub username: String,
pub email: String,
pub salt: String,
pub pass: String,
pub joined: Date,
}
2023-08-30 09:22:44 +02:00
#[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,
}