rag/ent/schema/documentblock.go

44 lines
864 B
Go
Raw Normal View History

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
2024-07-20 17:20:52 +00:00
field.Int64("order"),
// document id
2024-07-20 17:20:52 +00:00
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"),
}
}