32 lines
756 B
Plaintext
32 lines
756 B
Plaintext
|
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"),
|
||
|
}
|
||
|
}
|