mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2026-01-04 03:54:53 +01:00
refactor
This commit is contained in:
@@ -1 +0,0 @@
|
||||
package schema
|
||||
@@ -99,6 +99,13 @@ func (Item) Fields() []ent.Field {
|
||||
|
||||
// Edges of the Item.
|
||||
func (Item) Edges() []ent.Edge {
|
||||
owned := func(s string, t any) ent.Edge {
|
||||
return edge.To(s, t).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
})
|
||||
}
|
||||
|
||||
return []ent.Edge{
|
||||
edge.To("children", Item.Type).
|
||||
From("parent").
|
||||
@@ -108,17 +115,8 @@ func (Item) Edges() []ent.Edge {
|
||||
edge.From("location", Location.Type).
|
||||
Ref("items").
|
||||
Unique(),
|
||||
edge.To("fields", ItemField.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.To("maintenance_entries", MaintenanceEntry.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.To("attachments", Attachment.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
owned("fields", ItemField.Type),
|
||||
owned("maintenance_entries", MaintenanceEntry.Type),
|
||||
owned("attachments", Attachment.Type),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user