add thumbnails model
This commit is contained in:
@@ -16,4 +16,22 @@ pub struct Model {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::project_thumbnails::Entity")]
|
||||
ProjectThumbnails,
|
||||
}
|
||||
|
||||
impl Related<super::project_thumbnails::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::ProjectThumbnails.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::projects::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::project_thumbnails::Relation::Projects.def()
|
||||
}
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::project_thumbnails::Relation::Data.def().rev())
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ pub mod prelude;
|
||||
|
||||
pub mod data;
|
||||
pub mod jobs;
|
||||
pub mod project_thumbnails;
|
||||
pub mod projects;
|
||||
pub mod skills;
|
||||
pub mod users;
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
pub use super::data::Entity as Data;
|
||||
pub use super::jobs::Entity as Jobs;
|
||||
pub use super::project_thumbnails::Entity as ProjectThumbnails;
|
||||
pub use super::projects::Entity as Projects;
|
||||
pub use super::skills::Entity as Skills;
|
||||
pub use super::users::Entity as Users;
|
||||
|
47
src/models/_entities/project_thumbnails.rs
Normal file
47
src/models/_entities/project_thumbnails.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "project_thumbnails")]
|
||||
pub struct Model {
|
||||
pub created_at: DateTimeWithTimeZone,
|
||||
pub updated_at: DateTimeWithTimeZone,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub project_id: i32,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub data_id: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::data::Entity",
|
||||
from = "Column::DataId",
|
||||
to = "super::data::Column::Id",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Data,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::projects::Entity",
|
||||
from = "Column::ProjectId",
|
||||
to = "super::projects::Column::Id",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Projects,
|
||||
}
|
||||
|
||||
impl Related<super::data::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Data.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::projects::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Projects.def()
|
||||
}
|
||||
}
|
@@ -21,4 +21,22 @@ pub struct Model {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::project_thumbnails::Entity")]
|
||||
ProjectThumbnails,
|
||||
}
|
||||
|
||||
impl Related<super::project_thumbnails::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::ProjectThumbnails.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::data::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::project_thumbnails::Relation::Data.def()
|
||||
}
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::project_thumbnails::Relation::Projects.def().rev())
|
||||
}
|
||||
}
|
@@ -4,3 +4,4 @@ pub mod skills;
|
||||
pub mod jobs;
|
||||
pub mod projects;
|
||||
pub mod data;
|
||||
pub mod project_thumbnails;
|
||||
|
7
src/models/project_thumbnails.rs
Normal file
7
src/models/project_thumbnails.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use super::_entities::project_thumbnails::{ActiveModel, Entity};
|
||||
pub type ProjectThumbnails = Entity;
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {
|
||||
// extend activemodel below (keep comment for generators)
|
||||
}
|
@@ -19,3 +19,12 @@ struct ProjectWithTechnologies {
|
||||
pub download_url: Option<String>,
|
||||
pub visit_url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Category {
|
||||
Web,
|
||||
Mobile,
|
||||
Desktop,
|
||||
Game,
|
||||
Api,
|
||||
}
|
||||
|
Reference in New Issue
Block a user