2022-09-12 22:47:27 +00:00
|
|
|
package schema
|
|
|
|
|
|
|
|
import (
|
|
|
|
"entgo.io/ent"
|
|
|
|
"entgo.io/ent/schema/edge"
|
|
|
|
"entgo.io/ent/schema/field"
|
2022-10-30 04:05:38 +00:00
|
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
2022-09-12 22:47:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Attachment holds the schema definition for the Attachment entity.
|
|
|
|
type Attachment struct {
|
|
|
|
ent.Schema
|
|
|
|
}
|
|
|
|
|
|
|
|
func (Attachment) Mixin() []ent.Mixin {
|
|
|
|
return []ent.Mixin{
|
|
|
|
mixins.BaseMixin{},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fields of the Attachment.
|
|
|
|
func (Attachment) Fields() []ent.Field {
|
|
|
|
return []ent.Field{
|
|
|
|
field.Enum("type").
|
2022-10-16 03:45:36 +00:00
|
|
|
Values("photo", "manual", "warranty", "attachment", "receipt").
|
2022-09-12 22:47:27 +00:00
|
|
|
Default("attachment"),
|
2023-10-07 02:51:08 +00:00
|
|
|
field.Bool("primary").
|
|
|
|
Default(false),
|
2022-09-12 22:47:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Edges of the Attachment.
|
|
|
|
func (Attachment) Edges() []ent.Edge {
|
|
|
|
return []ent.Edge{
|
|
|
|
edge.From("item", Item.Type).
|
|
|
|
Ref("attachments").
|
|
|
|
Required().
|
|
|
|
Unique(),
|
|
|
|
edge.From("document", Document.Type).
|
|
|
|
Ref("attachments").
|
|
|
|
Required().
|
|
|
|
Unique(),
|
|
|
|
}
|
|
|
|
}
|