telegram-commerce/ent/schema/productcategory.go
2023-10-26 01:24:32 +03:30

33 lines
766 B
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"time"
)
// ProductCategory holds the schema definition for the ProductCategory entity.
type ProductCategory struct {
ent.Schema
}
// Fields of the ProductCategory.
func (ProductCategory) Fields() []ent.Field {
return []ent.Field{
field.String("name").Default("unknown"),
field.String("slug").Unique(),
field.String("description").Optional().Nillable(),
field.Bool("status").Default(true),
field.Time("created_at").Default(time.Now()),
field.Time("updated_at").Default(time.Now()).UpdateDefault(time.Now),
}
}
// Edges of the ProductCategory.
func (ProductCategory) Edges() []ent.Edge {
return []ent.Edge{
edge.To("products", Product.Type),
}
}