mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-24 14:31:55 +01:00
42 lines
985 B
Go
42 lines
985 B
Go
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/sysadminsmedia/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", "thumbnail").Default("attachment"),
|
|
field.Bool("primary").Default(false),
|
|
field.String("title").Default(""),
|
|
field.String("path").Default(""),
|
|
field.String("mime_type").Default("application/octet-stream"),
|
|
}
|
|
}
|
|
|
|
// Edges of the Attachment.
|
|
func (Attachment) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.From("item", Item.Type).
|
|
Ref("attachments").
|
|
Unique(),
|
|
edge.To("thumbnail", Attachment.Type).
|
|
Unique(),
|
|
}
|
|
}
|