-
-
Notifications
You must be signed in to change notification settings - Fork 560
/
Copy pathattributes.rs
69 lines (64 loc) · 1.97 KB
/
attributes.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
pub mod derive_attr {
use bae::FromAttributes;
/// Attributes for Models and ActiveModels
#[derive(Default, FromAttributes)]
#[allow(dead_code)]
pub struct SeaOrm {
pub column: Option<syn::Ident>,
pub entity: Option<syn::Ident>,
pub model: Option<syn::Ident>,
pub active_model: Option<syn::Ident>,
pub primary_key: Option<syn::Ident>,
pub relation: Option<syn::Ident>,
pub schema_name: Option<syn::Lit>,
pub table_name: Option<syn::Lit>,
pub comment: Option<syn::Lit>,
pub table_iden: Option<()>,
pub rename_all: Option<syn::Lit>,
}
}
pub mod field_attr {
use bae::FromAttributes;
/// Operations for Models and ActiveModels
#[derive(Default, FromAttributes)]
pub struct SeaOrm {
pub belongs_to: Option<syn::Lit>,
pub has_one: Option<syn::Lit>,
pub has_many: Option<syn::Lit>,
pub on_update: Option<syn::Lit>,
pub on_delete: Option<syn::Lit>,
pub on_condition: Option<syn::Lit>,
pub from: Option<syn::Lit>,
pub to: Option<syn::Lit>,
pub fk_name: Option<syn::Lit>,
pub condition_type: Option<syn::Lit>,
}
}
#[cfg(feature = "seaography")]
pub mod related_attr {
use bae::FromAttributes;
/// Operations for RelatedEntity enumeration
#[derive(Default, FromAttributes)]
pub struct SeaOrm {
///
/// Allows to modify target entity
///
/// Required on enumeration variants
///
/// If used on enumeration attributes
/// it allows to specify different
/// Entity ident
pub entity: Option<syn::Lit>,
///
/// ActiveModel ident
pub active_model: Option<syn::Lit>,
///
/// Allows to specify RelationDef
///
/// Optional
///
/// If not supplied the generated code
/// will utilize `impl Related` trait
pub def: Option<syn::Lit>,
}
}