agent_base.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package schema
  2. import (
  3. "entgo.io/ent"
  4. "entgo.io/ent/dialect/entsql"
  5. "entgo.io/ent/schema"
  6. "entgo.io/ent/schema/edge"
  7. "entgo.io/ent/schema/field"
  8. )
  9. type AgentBase struct {
  10. ent.Schema
  11. }
  12. func (AgentBase) Fields() []ent.Field {
  13. return []ent.Field{
  14. field.String("id").Comment("id"),
  15. field.String("q").Optional().Default("").Comment("q"),
  16. field.String("a").Optional().Default("").Comment("a"),
  17. field.Uint64("chunk_index").Positive().Comment("chunk_index"),
  18. field.JSON("indexes", []string{}).Optional().
  19. Annotations(entsql.WithComments(true)).
  20. Comment("indexes"),
  21. field.String("dataset_id").Optional().Default("").Comment("dataset_id"),
  22. field.String("collection_id").Optional().Default("").Comment("collection_id"),
  23. field.String("source_name").Optional().Default("").Comment("source_name"),
  24. field.JSON("can_write", []bool{}).Optional().
  25. Annotations(entsql.WithComments(true)).
  26. Comment("can_write"),
  27. field.JSON("is_owner", []bool{}).Optional().
  28. Annotations(entsql.WithComments(true)).
  29. Comment("is_owner"),
  30. }
  31. }
  32. func (AgentBase) Mixin() []ent.Mixin {
  33. return []ent.Mixin{}
  34. }
  35. func (AgentBase) Edges() []ent.Edge {
  36. return []ent.Edge{
  37. edge.To("wx_agent", Wx.Type),
  38. }
  39. }
  40. func (AgentBase) Indexes() []ent.Index {
  41. return []ent.Index{}
  42. }
  43. func (AgentBase) Annotations() []schema.Annotation {
  44. return []schema.Annotation{
  45. entsql.WithComments(true),
  46. entsql.Annotation{Table: "agent_base"},
  47. }
  48. }