1
0
Fork 0
forked from TWS/kalkutago

generate entities

This commit is contained in:
D. Scott Boggs 2023-06-07 08:48:44 -04:00
parent 77669ffd9a
commit 625da9b7af
7 changed files with 165 additions and 0 deletions

27
src/entities/groups.rs Normal file
View file

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

8
src/entities/mod.rs Normal file
View file

@ -0,0 +1,8 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3
pub mod prelude;
pub mod groups;
pub mod ticks;
pub mod track2_groups;
pub mod tracks;

6
src/entities/prelude.rs Normal file
View file

@ -0,0 +1,6 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3
pub use super::groups::Entity as Groups;
pub use super::ticks::Entity as Ticks;
pub use super::track2_groups::Entity as Track2Groups;
pub use super::tracks::Entity as Tracks;

38
src/entities/ticks.rs Normal file
View file

@ -0,0 +1,38 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "ticks")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub track_id: Option<i32>,
pub year: Option<i32>,
pub month: Option<i32>,
pub day: Option<i32>,
pub hour: Option<i32>,
pub minute: Option<i32>,
pub second: Option<i32>,
pub has_time_info: Option<i32>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::tracks::Entity",
from = "Column::TrackId",
to = "super::tracks::Column::Id",
on_update = "NoAction",
on_delete = "NoAction"
)]
Tracks,
}
impl Related<super::tracks::Entity> for Entity {
fn to() -> RelationDef {
Relation::Tracks.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View file

@ -0,0 +1,46 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "track2_groups")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub track_id: i32,
pub group_id: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::groups::Entity",
from = "Column::GroupId",
to = "super::groups::Column::Id",
on_update = "NoAction",
on_delete = "NoAction"
)]
Groups,
#[sea_orm(
belongs_to = "super::tracks::Entity",
from = "Column::TrackId",
to = "super::tracks::Column::Id",
on_update = "NoAction",
on_delete = "NoAction"
)]
Tracks,
}
impl Related<super::groups::Entity> for Entity {
fn to() -> RelationDef {
Relation::Groups.def()
}
}
impl Related<super::tracks::Entity> for Entity {
fn to() -> RelationDef {
Relation::Tracks.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

39
src/entities/tracks.rs Normal file
View file

@ -0,0 +1,39 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "tracks")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub name: String,
pub description: String,
pub icon: String,
pub enabled: i32,
pub multiple_entries_per_day: Option<i32>,
pub color: Option<i32>,
pub order: Option<i32>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::ticks::Entity")]
Ticks,
#[sea_orm(has_many = "super::track2_groups::Entity")]
Track2Groups,
}
impl Related<super::ticks::Entity> for Entity {
fn to() -> RelationDef {
Relation::Ticks.def()
}
}
impl Related<super::track2_groups::Entity> for Entity {
fn to() -> RelationDef {
Relation::Track2Groups.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View file

@ -1,5 +1,6 @@
#![feature(default_free_fn)]
mod db;
mod entities;
mod error;
mod migrator;
use error::Result;