redeemcode.go 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. // Code generated by ent, DO NOT EDIT.
  2. package redeemcode
  3. import (
  4. "time"
  5. "entgo.io/ent/dialect/sql"
  6. "entgo.io/ent/dialect/sql/sqlgraph"
  7. )
  8. const (
  9. // Label holds the string label denoting the redeemcode type in the database.
  10. Label = "redeem_code"
  11. // FieldID holds the string denoting the id field in the database.
  12. FieldID = "id"
  13. // FieldCode holds the string denoting the code field in the database.
  14. FieldCode = "code"
  15. // FieldType holds the string denoting the type field in the database.
  16. FieldType = "type"
  17. // FieldValue holds the string denoting the value field in the database.
  18. FieldValue = "value"
  19. // FieldStatus holds the string denoting the status field in the database.
  20. FieldStatus = "status"
  21. // FieldUsedBy holds the string denoting the used_by field in the database.
  22. FieldUsedBy = "used_by"
  23. // FieldUsedAt holds the string denoting the used_at field in the database.
  24. FieldUsedAt = "used_at"
  25. // FieldNotes holds the string denoting the notes field in the database.
  26. FieldNotes = "notes"
  27. // FieldCreatedAt holds the string denoting the created_at field in the database.
  28. FieldCreatedAt = "created_at"
  29. // FieldExpiresAt holds the string denoting the expires_at field in the database.
  30. FieldExpiresAt = "expires_at"
  31. // FieldGroupID holds the string denoting the group_id field in the database.
  32. FieldGroupID = "group_id"
  33. // FieldValidityDays holds the string denoting the validity_days field in the database.
  34. FieldValidityDays = "validity_days"
  35. // EdgeUser holds the string denoting the user edge name in mutations.
  36. EdgeUser = "user"
  37. // EdgeGroup holds the string denoting the group edge name in mutations.
  38. EdgeGroup = "group"
  39. // Table holds the table name of the redeemcode in the database.
  40. Table = "redeem_codes"
  41. // UserTable is the table that holds the user relation/edge.
  42. UserTable = "redeem_codes"
  43. // UserInverseTable is the table name for the User entity.
  44. // It exists in this package in order to avoid circular dependency with the "user" package.
  45. UserInverseTable = "users"
  46. // UserColumn is the table column denoting the user relation/edge.
  47. UserColumn = "used_by"
  48. // GroupTable is the table that holds the group relation/edge.
  49. GroupTable = "redeem_codes"
  50. // GroupInverseTable is the table name for the Group entity.
  51. // It exists in this package in order to avoid circular dependency with the "group" package.
  52. GroupInverseTable = "groups"
  53. // GroupColumn is the table column denoting the group relation/edge.
  54. GroupColumn = "group_id"
  55. )
  56. // Columns holds all SQL columns for redeemcode fields.
  57. var Columns = []string{
  58. FieldID,
  59. FieldCode,
  60. FieldType,
  61. FieldValue,
  62. FieldStatus,
  63. FieldUsedBy,
  64. FieldUsedAt,
  65. FieldNotes,
  66. FieldCreatedAt,
  67. FieldExpiresAt,
  68. FieldGroupID,
  69. FieldValidityDays,
  70. }
  71. // ValidColumn reports if the column name is valid (part of the table columns).
  72. func ValidColumn(column string) bool {
  73. for i := range Columns {
  74. if column == Columns[i] {
  75. return true
  76. }
  77. }
  78. return false
  79. }
  80. var (
  81. // CodeValidator is a validator for the "code" field. It is called by the builders before save.
  82. CodeValidator func(string) error
  83. // DefaultType holds the default value on creation for the "type" field.
  84. DefaultType string
  85. // TypeValidator is a validator for the "type" field. It is called by the builders before save.
  86. TypeValidator func(string) error
  87. // DefaultValue holds the default value on creation for the "value" field.
  88. DefaultValue float64
  89. // DefaultStatus holds the default value on creation for the "status" field.
  90. DefaultStatus string
  91. // StatusValidator is a validator for the "status" field. It is called by the builders before save.
  92. StatusValidator func(string) error
  93. // DefaultCreatedAt holds the default value on creation for the "created_at" field.
  94. DefaultCreatedAt func() time.Time
  95. // DefaultValidityDays holds the default value on creation for the "validity_days" field.
  96. DefaultValidityDays int
  97. )
  98. // OrderOption defines the ordering options for the RedeemCode queries.
  99. type OrderOption func(*sql.Selector)
  100. // ByID orders the results by the id field.
  101. func ByID(opts ...sql.OrderTermOption) OrderOption {
  102. return sql.OrderByField(FieldID, opts...).ToFunc()
  103. }
  104. // ByCode orders the results by the code field.
  105. func ByCode(opts ...sql.OrderTermOption) OrderOption {
  106. return sql.OrderByField(FieldCode, opts...).ToFunc()
  107. }
  108. // ByType orders the results by the type field.
  109. func ByType(opts ...sql.OrderTermOption) OrderOption {
  110. return sql.OrderByField(FieldType, opts...).ToFunc()
  111. }
  112. // ByValue orders the results by the value field.
  113. func ByValue(opts ...sql.OrderTermOption) OrderOption {
  114. return sql.OrderByField(FieldValue, opts...).ToFunc()
  115. }
  116. // ByStatus orders the results by the status field.
  117. func ByStatus(opts ...sql.OrderTermOption) OrderOption {
  118. return sql.OrderByField(FieldStatus, opts...).ToFunc()
  119. }
  120. // ByUsedBy orders the results by the used_by field.
  121. func ByUsedBy(opts ...sql.OrderTermOption) OrderOption {
  122. return sql.OrderByField(FieldUsedBy, opts...).ToFunc()
  123. }
  124. // ByUsedAt orders the results by the used_at field.
  125. func ByUsedAt(opts ...sql.OrderTermOption) OrderOption {
  126. return sql.OrderByField(FieldUsedAt, opts...).ToFunc()
  127. }
  128. // ByNotes orders the results by the notes field.
  129. func ByNotes(opts ...sql.OrderTermOption) OrderOption {
  130. return sql.OrderByField(FieldNotes, opts...).ToFunc()
  131. }
  132. // ByCreatedAt orders the results by the created_at field.
  133. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
  134. return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
  135. }
  136. // ByExpiresAt orders the results by the expires_at field.
  137. func ByExpiresAt(opts ...sql.OrderTermOption) OrderOption {
  138. return sql.OrderByField(FieldExpiresAt, opts...).ToFunc()
  139. }
  140. // ByGroupID orders the results by the group_id field.
  141. func ByGroupID(opts ...sql.OrderTermOption) OrderOption {
  142. return sql.OrderByField(FieldGroupID, opts...).ToFunc()
  143. }
  144. // ByValidityDays orders the results by the validity_days field.
  145. func ByValidityDays(opts ...sql.OrderTermOption) OrderOption {
  146. return sql.OrderByField(FieldValidityDays, opts...).ToFunc()
  147. }
  148. // ByUserField orders the results by user field.
  149. func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
  150. return func(s *sql.Selector) {
  151. sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
  152. }
  153. }
  154. // ByGroupField orders the results by group field.
  155. func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption {
  156. return func(s *sql.Selector) {
  157. sqlgraph.OrderByNeighborTerms(s, newGroupStep(), sql.OrderByField(field, opts...))
  158. }
  159. }
  160. func newUserStep() *sqlgraph.Step {
  161. return sqlgraph.NewStep(
  162. sqlgraph.From(Table, FieldID),
  163. sqlgraph.To(UserInverseTable, FieldID),
  164. sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
  165. )
  166. }
  167. func newGroupStep() *sqlgraph.Step {
  168. return sqlgraph.NewStep(
  169. sqlgraph.From(Table, FieldID),
  170. sqlgraph.To(GroupInverseTable, FieldID),
  171. sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
  172. )
  173. }