online-order/ent/schema/businessconfig.go
2023-10-29 02:42:07 +03:30

43 lines
970 B
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// BusinessConfig holds the schema definition for the BusinessConfig entity.
type BusinessConfig struct {
ent.Schema
}
type AuthConfig struct {
uri string
username string
password string
}
// Fields of the BusinessConfig.
func (BusinessConfig) Fields() []ent.Field {
return []ent.Field{
field.String("company").Default("WillaEngine"),
field.JSON("auth_config", AuthConfig{}),
field.JSON("config", []string{}).Comment("{type:'products',uri:''}"),
field.Int("business_id").Optional().Nillable(),
}
}
// Edges of the BusinessConfig.
func (BusinessConfig) Edges() []ent.Edge {
return []ent.Edge{
edge.From("businesses", Business.Type).Ref("business_configs").Unique().Field("business_id"),
}
}
func (BusinessConfig) Indexes() []ent.Index {
return []ent.Index{
index.Fields("company", "business_id").Unique(),
}
}