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/comment.go

41 lines
781 B

package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// Comment holds the schema definition for the Comment entity.
type Comment struct {
ent.Schema
}
// Fields of the Comment.
func (Comment) Fields() []ent.Field {
return []ent.Field{
field.Int64("id"),
field.String("name"),
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 Comment.
func (Comment) Edges() []ent.Edge {
return []ent.Edge{
edge.From("post", Article.Type).
Ref("comments").
Unique(),
}
}