package schema import ( "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" "time" ) // DocumentBlock holds the schema definition for the DocumentBlock entity. type DocumentBlock struct { ent.Schema } // Fields of the DocumentBlock. func (DocumentBlock) Fields() []ent.Field { return []ent.Field{ field.String("name"), field.String("content"), // order field.Int64("order"), // document id field.Int64("document_id"), field.String("user_id"), field.Time("created_at").Default(time.Now), field.Time("updated_at").Default(time.Now), } } // Edges of the DocumentBlock. func (DocumentBlock) Edges() []ent.Edge { return []ent.Edge{ edge.To("document", Document.Type), } } func (DocumentBlock) Indexes() []ent.Index { return []ent.Index{ index.Fields("name", "user_id", "order"), } }