Add project and data model
This commit is contained in:
18
src/models/_entities/data.rs
Normal file
18
src/models/_entities/data.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
//! `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 = "data")]
|
||||
pub struct Model {
|
||||
pub created_at: DateTimeWithTimeZone,
|
||||
pub updated_at: DateTimeWithTimeZone,
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub file_url: String,
|
||||
pub protected: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
@@ -19,4 +19,4 @@ pub struct Model {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
pub enum Relation {}
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
pub mod prelude;
|
||||
|
||||
pub mod data;
|
||||
pub mod jobs;
|
||||
pub mod projects;
|
||||
pub mod skills;
|
||||
pub mod users;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
|
||||
|
||||
pub use super::data::Entity as Data;
|
||||
pub use super::jobs::Entity as Jobs;
|
||||
pub use super::projects::Entity as Projects;
|
||||
pub use super::skills::Entity as Skills;
|
||||
pub use super::users::Entity as Users;
|
||||
|
24
src/models/_entities/projects.rs
Normal file
24
src/models/_entities/projects.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
//! `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 = "projects")]
|
||||
pub struct Model {
|
||||
pub created_at: DateTimeWithTimeZone,
|
||||
pub updated_at: DateTimeWithTimeZone,
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub technology: String,
|
||||
pub short_description: String,
|
||||
pub description: Option<String>,
|
||||
pub category: String,
|
||||
pub github_url: Option<String>,
|
||||
pub download_url: Option<String>,
|
||||
pub visit_url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
7
src/models/data.rs
Normal file
7
src/models/data.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use super::_entities::data::{ActiveModel, Entity};
|
||||
pub type Data = Entity;
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {
|
||||
// extend activemodel below (keep comment for generators)
|
||||
}
|
@@ -2,3 +2,5 @@ pub mod _entities;
|
||||
pub mod users;
|
||||
pub mod skills;
|
||||
pub mod jobs;
|
||||
pub mod projects;
|
||||
pub mod data;
|
||||
|
21
src/models/projects.rs
Normal file
21
src/models/projects.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use super::_entities::projects::{ActiveModel, Entity};
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub type Projects = Entity;
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {
|
||||
// extend activemodel below (keep comment for generators)
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
struct ProjectWithTechnologies {
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub technologies: Vec<String>,
|
||||
pub short_description: String,
|
||||
pub description: Option<String>,
|
||||
pub category: String,
|
||||
pub github_url: Option<String>,
|
||||
pub download_url: Option<String>,
|
||||
pub visit_url: Option<String>,
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
use loco_rs::prelude::*;
|
||||
|
||||
use crate::models::{
|
||||
_entities::jobs::{ActiveModel, Entity, Model},
|
||||
_entities::jobs::{Entity, Model},
|
||||
jobs::{get_technologies_from_string, JobWithTechnologies},
|
||||
};
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
use loco_rs::prelude::*;
|
||||
|
||||
use crate::models::_entities::skills::{ActiveModel, Entity, Model};
|
||||
use crate::models::_entities::skills::{Entity, Model};
|
||||
|
||||
pub async fn get_all_skills(ctx: &AppContext) -> Result<Vec<Model>> {
|
||||
let skills = Entity::find().all(&ctx.db).await?;
|
||||
|
Reference in New Issue
Block a user