2022-08-30 18:04:50 +00:00
|
|
|
package schema
|
|
|
|
|
|
|
|
import (
|
|
|
|
"entgo.io/ent"
|
2022-09-13 04:54:30 +00:00
|
|
|
"entgo.io/ent/dialect/entsql"
|
2022-08-30 18:04:50 +00:00
|
|
|
"entgo.io/ent/schema/edge"
|
2022-10-30 04:05:38 +00:00
|
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
2022-08-30 18:04:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Location holds the schema definition for the Location entity.
|
|
|
|
type Location struct {
|
|
|
|
ent.Schema
|
|
|
|
}
|
|
|
|
|
|
|
|
func (Location) Mixin() []ent.Mixin {
|
|
|
|
return []ent.Mixin{
|
|
|
|
mixins.BaseMixin{},
|
|
|
|
mixins.DetailsMixin{},
|
2023-03-07 06:18:58 +00:00
|
|
|
GroupMixin{ref: "locations"},
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fields of the Location.
|
|
|
|
func (Location) Fields() []ent.Field {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Edges of the Location.
|
|
|
|
func (Location) Edges() []ent.Edge {
|
|
|
|
return []ent.Edge{
|
2022-10-24 04:54:39 +00:00
|
|
|
edge.To("children", Location.Type).
|
|
|
|
From("parent").
|
|
|
|
Unique(),
|
2022-09-13 04:54:30 +00:00
|
|
|
edge.To("items", Item.Type).
|
|
|
|
Annotations(entsql.Annotation{
|
|
|
|
OnDelete: entsql.Cascade,
|
|
|
|
}),
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
|
|
|
}
|