user-auth orm and meili changes

This commit is contained in:
2022-12-29 22:22:04 +05:30
parent 0e357b0d4e
commit ec907e4b5f
20 changed files with 702 additions and 175 deletions

View File

@@ -1,8 +1,8 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.6
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "book")]
pub struct Model {
#[sea_orm(primary_key)]
@@ -19,12 +19,15 @@ pub struct Model {
pub time_added: Option<String>,
pub rating: Option<i32>,
pub comments: Option<String>,
pub user_id: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::book_author::Entity")]
BookAuthor,
#[sea_orm(has_many = "super::book_isbn::Entity")]
BookIsbn,
#[sea_orm(has_many = "super::book_person::Entity")]
BookPerson,
#[sea_orm(has_many = "super::book_place::Entity")]
@@ -33,8 +36,14 @@ pub enum Relation {
BookSubject,
#[sea_orm(has_many = "super::book_time::Entity")]
BookTime,
#[sea_orm(has_many = "super::book_isbn::Entity")]
BookIsbn,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
User,
}
impl Related<super::book_author::Entity> for Entity {
@@ -43,6 +52,12 @@ impl Related<super::book_author::Entity> for Entity {
}
}
impl Related<super::book_isbn::Entity> for Entity {
fn to() -> RelationDef {
Relation::BookIsbn.def()
}
}
impl Related<super::book_person::Entity> for Entity {
fn to() -> RelationDef {
Relation::BookPerson.def()
@@ -67,9 +82,9 @@ impl Related<super::book_time::Entity> for Entity {
}
}
impl Related<super::book_isbn::Entity> for Entity {
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::BookIsbn.def()
Relation::User.def()
}
}

View File

@@ -1,8 +1,8 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.6
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "book_author")]
pub struct Model {
#[sea_orm(primary_key)]

View File

@@ -1,8 +1,8 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.6
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "book_isbn")]
pub struct Model {
#[sea_orm(primary_key)]

View File

@@ -1,8 +1,8 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.6
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "book_person")]
pub struct Model {
#[sea_orm(primary_key)]

View File

@@ -1,8 +1,8 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.6
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "book_place")]
pub struct Model {
#[sea_orm(primary_key)]

View File

@@ -1,8 +1,8 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.6
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "book_subject")]
pub struct Model {
#[sea_orm(primary_key)]

View File

@@ -1,8 +1,8 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.6
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "book_time")]
pub struct Model {
#[sea_orm(primary_key)]

View File

@@ -1,4 +1,4 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.6
pub mod prelude;
@@ -9,3 +9,4 @@ pub mod book_person;
pub mod book_place;
pub mod book_subject;
pub mod book_time;
pub mod user;

View File

@@ -1,4 +1,4 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.6
pub use super::book::Entity as Book;
pub use super::book_author::Entity as BookAuthor;
@@ -7,3 +7,4 @@ pub use super::book_person::Entity as BookPerson;
pub use super::book_place::Entity as BookPlace;
pub use super::book_subject::Entity as BookSubject;
pub use super::book_time::Entity as BookTime;
pub use super::user::Entity as User;

View File

@@ -0,0 +1,26 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.6
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub user_name: Option<String>,
pub password_hash: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::book::Entity")]
Book,
}
impl Related<super::book::Entity> for Entity {
fn to() -> RelationDef {
Relation::Book.def()
}
}
impl ActiveModelBehavior for ActiveModel {}