promocodeusage.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Code generated by ent, DO NOT EDIT.
  2. package promocodeusage
  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 promocodeusage type in the database.
  10. Label = "promo_code_usage"
  11. // FieldID holds the string denoting the id field in the database.
  12. FieldID = "id"
  13. // FieldPromoCodeID holds the string denoting the promo_code_id field in the database.
  14. FieldPromoCodeID = "promo_code_id"
  15. // FieldUserID holds the string denoting the user_id field in the database.
  16. FieldUserID = "user_id"
  17. // FieldBonusAmount holds the string denoting the bonus_amount field in the database.
  18. FieldBonusAmount = "bonus_amount"
  19. // FieldUsedAt holds the string denoting the used_at field in the database.
  20. FieldUsedAt = "used_at"
  21. // EdgePromoCode holds the string denoting the promo_code edge name in mutations.
  22. EdgePromoCode = "promo_code"
  23. // EdgeUser holds the string denoting the user edge name in mutations.
  24. EdgeUser = "user"
  25. // Table holds the table name of the promocodeusage in the database.
  26. Table = "promo_code_usages"
  27. // PromoCodeTable is the table that holds the promo_code relation/edge.
  28. PromoCodeTable = "promo_code_usages"
  29. // PromoCodeInverseTable is the table name for the PromoCode entity.
  30. // It exists in this package in order to avoid circular dependency with the "promocode" package.
  31. PromoCodeInverseTable = "promo_codes"
  32. // PromoCodeColumn is the table column denoting the promo_code relation/edge.
  33. PromoCodeColumn = "promo_code_id"
  34. // UserTable is the table that holds the user relation/edge.
  35. UserTable = "promo_code_usages"
  36. // UserInverseTable is the table name for the User entity.
  37. // It exists in this package in order to avoid circular dependency with the "user" package.
  38. UserInverseTable = "users"
  39. // UserColumn is the table column denoting the user relation/edge.
  40. UserColumn = "user_id"
  41. )
  42. // Columns holds all SQL columns for promocodeusage fields.
  43. var Columns = []string{
  44. FieldID,
  45. FieldPromoCodeID,
  46. FieldUserID,
  47. FieldBonusAmount,
  48. FieldUsedAt,
  49. }
  50. // ValidColumn reports if the column name is valid (part of the table columns).
  51. func ValidColumn(column string) bool {
  52. for i := range Columns {
  53. if column == Columns[i] {
  54. return true
  55. }
  56. }
  57. return false
  58. }
  59. var (
  60. // DefaultUsedAt holds the default value on creation for the "used_at" field.
  61. DefaultUsedAt func() time.Time
  62. )
  63. // OrderOption defines the ordering options for the PromoCodeUsage queries.
  64. type OrderOption func(*sql.Selector)
  65. // ByID orders the results by the id field.
  66. func ByID(opts ...sql.OrderTermOption) OrderOption {
  67. return sql.OrderByField(FieldID, opts...).ToFunc()
  68. }
  69. // ByPromoCodeID orders the results by the promo_code_id field.
  70. func ByPromoCodeID(opts ...sql.OrderTermOption) OrderOption {
  71. return sql.OrderByField(FieldPromoCodeID, opts...).ToFunc()
  72. }
  73. // ByUserID orders the results by the user_id field.
  74. func ByUserID(opts ...sql.OrderTermOption) OrderOption {
  75. return sql.OrderByField(FieldUserID, opts...).ToFunc()
  76. }
  77. // ByBonusAmount orders the results by the bonus_amount field.
  78. func ByBonusAmount(opts ...sql.OrderTermOption) OrderOption {
  79. return sql.OrderByField(FieldBonusAmount, opts...).ToFunc()
  80. }
  81. // ByUsedAt orders the results by the used_at field.
  82. func ByUsedAt(opts ...sql.OrderTermOption) OrderOption {
  83. return sql.OrderByField(FieldUsedAt, opts...).ToFunc()
  84. }
  85. // ByPromoCodeField orders the results by promo_code field.
  86. func ByPromoCodeField(field string, opts ...sql.OrderTermOption) OrderOption {
  87. return func(s *sql.Selector) {
  88. sqlgraph.OrderByNeighborTerms(s, newPromoCodeStep(), sql.OrderByField(field, opts...))
  89. }
  90. }
  91. // ByUserField orders the results by user field.
  92. func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
  93. return func(s *sql.Selector) {
  94. sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
  95. }
  96. }
  97. func newPromoCodeStep() *sqlgraph.Step {
  98. return sqlgraph.NewStep(
  99. sqlgraph.From(Table, FieldID),
  100. sqlgraph.To(PromoCodeInverseTable, FieldID),
  101. sqlgraph.Edge(sqlgraph.M2O, true, PromoCodeTable, PromoCodeColumn),
  102. )
  103. }
  104. func newUserStep() *sqlgraph.Step {
  105. return sqlgraph.NewStep(
  106. sqlgraph.From(Table, FieldID),
  107. sqlgraph.To(UserInverseTable, FieldID),
  108. sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
  109. )
  110. }