1use sea_orm::entity::prelude::*;
4
5#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
6#[sea_orm(table_name = "krate")]
7pub struct Model {
8 #[sea_orm(primary_key)]
9 pub id: i64,
10 #[sea_orm(column_type = "Text", unique)]
11 pub name: String,
12 #[sea_orm(column_type = "Text")]
13 pub max_version: String,
14 pub total_downloads: i64,
15 #[sea_orm(column_type = "Text")]
16 pub last_updated: String,
17 #[sea_orm(column_type = "Text", nullable)]
18 pub description: Option<String>,
19 #[sea_orm(column_type = "Text", nullable)]
20 pub homepage: Option<String>,
21 #[sea_orm(column_type = "Text", nullable)]
22 pub repository: Option<String>,
23 #[sea_orm(column_type = "Text")]
24 pub original_name: String,
25 pub e_tag: String,
26 pub restricted_download: bool,
27}
28
29#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
30pub enum Relation {
31 #[sea_orm(has_many = "super::crate_author_to_crate::Entity")]
32 CrateAuthorToCrate,
33 #[sea_orm(has_many = "super::crate_category_to_crate::Entity")]
34 CrateCategoryToCrate,
35 #[sea_orm(has_many = "super::crate_group::Entity")]
36 CrateGroup,
37 #[sea_orm(has_many = "super::crate_index::Entity")]
38 CrateIndex,
39 #[sea_orm(has_many = "super::crate_keyword_to_crate::Entity")]
40 CrateKeywordToCrate,
41 #[sea_orm(has_many = "super::crate_meta::Entity")]
42 CrateMeta,
43 #[sea_orm(has_many = "super::crate_user::Entity")]
44 CrateUser,
45 #[sea_orm(has_many = "super::owner::Entity")]
46 Owner,
47}
48
49impl Related<super::crate_author_to_crate::Entity> for Entity {
50 fn to() -> RelationDef {
51 Relation::CrateAuthorToCrate.def()
52 }
53}
54
55impl Related<super::crate_category_to_crate::Entity> for Entity {
56 fn to() -> RelationDef {
57 Relation::CrateCategoryToCrate.def()
58 }
59}
60
61impl Related<super::crate_group::Entity> for Entity {
62 fn to() -> RelationDef {
63 Relation::CrateGroup.def()
64 }
65}
66
67impl Related<super::crate_index::Entity> for Entity {
68 fn to() -> RelationDef {
69 Relation::CrateIndex.def()
70 }
71}
72
73impl Related<super::crate_keyword_to_crate::Entity> for Entity {
74 fn to() -> RelationDef {
75 Relation::CrateKeywordToCrate.def()
76 }
77}
78
79impl Related<super::crate_meta::Entity> for Entity {
80 fn to() -> RelationDef {
81 Relation::CrateMeta.def()
82 }
83}
84
85impl Related<super::crate_user::Entity> for Entity {
86 fn to() -> RelationDef {
87 Relation::CrateUser.def()
88 }
89}
90
91impl Related<super::owner::Entity> for Entity {
92 fn to() -> RelationDef {
93 Relation::Owner.def()
94 }
95}
96
97impl ActiveModelBehavior for ActiveModel {}