mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-22 16:45:43 +00:00
refactor
This commit is contained in:
parent
883468e04c
commit
b6c2db0e83
2 changed files with 10 additions and 13 deletions
|
@ -1 +0,0 @@
|
||||||
package schema
|
|
|
@ -99,6 +99,13 @@ func (Item) Fields() []ent.Field {
|
||||||
|
|
||||||
// Edges of the Item.
|
// Edges of the Item.
|
||||||
func (Item) Edges() []ent.Edge {
|
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{
|
return []ent.Edge{
|
||||||
edge.To("children", Item.Type).
|
edge.To("children", Item.Type).
|
||||||
From("parent").
|
From("parent").
|
||||||
|
@ -108,17 +115,8 @@ func (Item) Edges() []ent.Edge {
|
||||||
edge.From("location", Location.Type).
|
edge.From("location", Location.Type).
|
||||||
Ref("items").
|
Ref("items").
|
||||||
Unique(),
|
Unique(),
|
||||||
edge.To("fields", ItemField.Type).
|
owned("fields", ItemField.Type),
|
||||||
Annotations(entsql.Annotation{
|
owned("maintenance_entries", MaintenanceEntry.Type),
|
||||||
OnDelete: entsql.Cascade,
|
owned("attachments", Attachment.Type),
|
||||||
}),
|
|
||||||
edge.To("maintenance_entries", MaintenanceEntry.Type).
|
|
||||||
Annotations(entsql.Annotation{
|
|
||||||
OnDelete: entsql.Cascade,
|
|
||||||
}),
|
|
||||||
edge.To("attachments", Attachment.Type).
|
|
||||||
Annotations(entsql.Annotation{
|
|
||||||
OnDelete: entsql.Cascade,
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue