You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
kratos/examples/blog/internal/data/ent/schema/article.go

40 lines
792 B

package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"time"
)
// Article holds the schema definition for the Article entity.
type Article struct {
ent.Schema
}
// Fields of the Post.
func (Article) Fields() []ent.Field {
return []ent.Field{
field.Int64("id"),
field.String("title"),
field.String("content"),
field.Time("created_at").
Default(time.Now).SchemaType(map[string]string{
dialect.MySQL: "datetime",
}),
field.Time("updated_at").
Default(time.Now).SchemaType(map[string]string{
dialect.MySQL: "datetime",
}),
}
}
// Edges of the Post.
func (Article) Edges() []ent.Edge {
return []ent.Edge{
edge.To("comments", Comment.Type),
edge.From("tags", Tag.Type).
Ref("posts"),
}
}