todo.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // Code generated by entc, DO NOT EDIT.
  2. package todo
  3. import (
  4. "fmt"
  5. "time"
  6. )
  7. const (
  8. // Label holds the string label denoting the todo type in the database.
  9. Label = "todo"
  10. // FieldID holds the string denoting the id field in the database.
  11. FieldID = "id"
  12. // FieldText holds the string denoting the text field in the database.
  13. FieldText = "text"
  14. // FieldCreatedAt holds the string denoting the created_at field in the database.
  15. FieldCreatedAt = "created_at"
  16. // FieldStatus holds the string denoting the status field in the database.
  17. FieldStatus = "status"
  18. // FieldPriority holds the string denoting the priority field in the database.
  19. FieldPriority = "priority"
  20. // EdgeChildren holds the string denoting the children edge name in mutations.
  21. EdgeChildren = "children"
  22. // EdgeParent holds the string denoting the parent edge name in mutations.
  23. EdgeParent = "parent"
  24. // Table holds the table name of the todo in the database.
  25. Table = "todos"
  26. // ChildrenTable is the table that holds the children relation/edge.
  27. ChildrenTable = "todos"
  28. // ChildrenColumn is the table column denoting the children relation/edge.
  29. ChildrenColumn = "todo_parent"
  30. // ParentTable is the table that holds the parent relation/edge.
  31. ParentTable = "todos"
  32. // ParentColumn is the table column denoting the parent relation/edge.
  33. ParentColumn = "todo_parent"
  34. )
  35. // Columns holds all SQL columns for todo fields.
  36. var Columns = []string{
  37. FieldID,
  38. FieldText,
  39. FieldCreatedAt,
  40. FieldStatus,
  41. FieldPriority,
  42. }
  43. // ForeignKeys holds the SQL foreign-keys that are owned by the "todos"
  44. // table and are not defined as standalone fields in the schema.
  45. var ForeignKeys = []string{
  46. "todo_parent",
  47. }
  48. // ValidColumn reports if the column name is valid (part of the table columns).
  49. func ValidColumn(column string) bool {
  50. for i := range Columns {
  51. if column == Columns[i] {
  52. return true
  53. }
  54. }
  55. for i := range ForeignKeys {
  56. if column == ForeignKeys[i] {
  57. return true
  58. }
  59. }
  60. return false
  61. }
  62. var (
  63. // TextValidator is a validator for the "text" field. It is called by the builders before save.
  64. TextValidator func(string) error
  65. // DefaultCreatedAt holds the default value on creation for the "created_at" field.
  66. DefaultCreatedAt func() time.Time
  67. // DefaultPriority holds the default value on creation for the "priority" field.
  68. DefaultPriority int
  69. )
  70. // Status defines the type for the "status" enum field.
  71. type Status string
  72. // StatusInProgress is the default value of the Status enum.
  73. const DefaultStatus = StatusInProgress
  74. // Status values.
  75. const (
  76. StatusInProgress Status = "in_progress"
  77. StatusCompleted Status = "completed"
  78. )
  79. func (s Status) String() string {
  80. return string(s)
  81. }
  82. // StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
  83. func StatusValidator(s Status) error {
  84. switch s {
  85. case StatusInProgress, StatusCompleted:
  86. return nil
  87. default:
  88. return fmt.Errorf("todo: invalid enum value for status field: %q", s)
  89. }
  90. }