online-order/command/generateCrud/schema.text

32 lines
756 B
Plaintext
Raw Permalink Normal View History

2023-11-17 20:20:29 +00:00
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"time"
)
// {Name} holds the schema definition for the {Name} entity.
type {Name} struct {
ent.Schema
}
// Fields of the {Name}.
func ({Name}) Fields() []ent.Field {
return []ent.Field{
field.Int("business_id").Optional().Nillable(),
field.Int("user_id").Optional().Nillable(),
field.Time("created_at").Default(time.Now()),
field.Time("updated_at").Default(time.Now()).UpdateDefault(time.Now),
}
}
// Edges of the {Name}.
func ({Name}) Edges() []ent.Edge {
return []ent.Edge{
edge.From("businesses", Business.Type).Ref("{name}s").Unique().Field("business_id"),
edge.From("users", User.Type).Ref("{name}s").Unique().Field("user_id"),
}
}