rag/internal/ent/schema/document.go
2024-06-13 09:16:48 +08:00

41 lines
824 B
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"time"
)
// Document holds the schema definition for the Document entity.
type Document struct {
ent.Schema
}
// Fields of the Document.
func (Document) Fields() []ent.Field {
return []ent.Field{
field.String("title"),
field.String("description"),
field.String("user_id"),
field.Uint("library_id"),
field.Bool("synced"),
field.JSON("document_block_ids", []int32{}),
field.Time("created_at").Default(time.Now),
field.Time("updated_at").Default(time.Now),
}
}
// Edges of the Document.
func (Document) Edges() []ent.Edge {
return []ent.Edge{
//edge.To("library", Library.Type),
}
}
func (Document) Indexes() []ent.Index {
return []ent.Index{
index.Fields("user_id", "library_id", "synced"),
}
}