meta.go 745 B

123456789101112131415161718192021222324252627282930313233343536
  1. package schema
  2. import (
  3. "entgo.io/ent"
  4. "entgo.io/ent/schema/edge"
  5. "entgo.io/ent/schema/field"
  6. "github.com/crowdsecurity/crowdsec/pkg/types"
  7. )
  8. // Meta holds the schema definition for the Meta entity.
  9. type Meta struct {
  10. ent.Schema
  11. }
  12. // Fields of the Meta.
  13. func (Meta) Fields() []ent.Field {
  14. return []ent.Field{
  15. field.Time("created_at").
  16. Default(types.UtcNow).
  17. UpdateDefault(types.UtcNow).Nillable().Optional(),
  18. field.Time("updated_at").
  19. Default(types.UtcNow).
  20. UpdateDefault(types.UtcNow).Nillable().Optional(),
  21. field.String("key"),
  22. field.String("value").MaxLen(4095),
  23. }
  24. }
  25. // Edges of the Meta.
  26. func (Meta) Edges() []ent.Edge {
  27. return []ent.Edge{
  28. edge.From("owner", Alert.Type).
  29. Ref("metas").
  30. Unique(),
  31. }
  32. }