mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-25 10:05:43 +00:00
b20c88e256
* add support for primary images
* fix locked loading state issue
* add action to auto-set images
Former-commit-id: 318b8be192
44 lines
891 B
Go
44 lines
891 B
Go
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
|
)
|
|
|
|
// 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").
|
|
Values("photo", "manual", "warranty", "attachment", "receipt").
|
|
Default("attachment"),
|
|
field.Bool("primary").
|
|
Default(false),
|
|
}
|
|
}
|
|
|
|
// 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(),
|
|
}
|
|
}
|