usersubscription.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. // Code generated by ent, DO NOT EDIT.
  2. package usersubscription
  3. import (
  4. "time"
  5. "entgo.io/ent"
  6. "entgo.io/ent/dialect/sql"
  7. "entgo.io/ent/dialect/sql/sqlgraph"
  8. )
  9. const (
  10. // Label holds the string label denoting the usersubscription type in the database.
  11. Label = "user_subscription"
  12. // FieldID holds the string denoting the id field in the database.
  13. FieldID = "id"
  14. // FieldCreatedAt holds the string denoting the created_at field in the database.
  15. FieldCreatedAt = "created_at"
  16. // FieldUpdatedAt holds the string denoting the updated_at field in the database.
  17. FieldUpdatedAt = "updated_at"
  18. // FieldDeletedAt holds the string denoting the deleted_at field in the database.
  19. FieldDeletedAt = "deleted_at"
  20. // FieldUserID holds the string denoting the user_id field in the database.
  21. FieldUserID = "user_id"
  22. // FieldGroupID holds the string denoting the group_id field in the database.
  23. FieldGroupID = "group_id"
  24. // FieldStartsAt holds the string denoting the starts_at field in the database.
  25. FieldStartsAt = "starts_at"
  26. // FieldExpiresAt holds the string denoting the expires_at field in the database.
  27. FieldExpiresAt = "expires_at"
  28. // FieldStatus holds the string denoting the status field in the database.
  29. FieldStatus = "status"
  30. // FieldDailyWindowStart holds the string denoting the daily_window_start field in the database.
  31. FieldDailyWindowStart = "daily_window_start"
  32. // FieldWeeklyWindowStart holds the string denoting the weekly_window_start field in the database.
  33. FieldWeeklyWindowStart = "weekly_window_start"
  34. // FieldMonthlyWindowStart holds the string denoting the monthly_window_start field in the database.
  35. FieldMonthlyWindowStart = "monthly_window_start"
  36. // FieldDailyUsageUsd holds the string denoting the daily_usage_usd field in the database.
  37. FieldDailyUsageUsd = "daily_usage_usd"
  38. // FieldWeeklyUsageUsd holds the string denoting the weekly_usage_usd field in the database.
  39. FieldWeeklyUsageUsd = "weekly_usage_usd"
  40. // FieldMonthlyUsageUsd holds the string denoting the monthly_usage_usd field in the database.
  41. FieldMonthlyUsageUsd = "monthly_usage_usd"
  42. // FieldAssignedBy holds the string denoting the assigned_by field in the database.
  43. FieldAssignedBy = "assigned_by"
  44. // FieldAssignedAt holds the string denoting the assigned_at field in the database.
  45. FieldAssignedAt = "assigned_at"
  46. // FieldNotes holds the string denoting the notes field in the database.
  47. FieldNotes = "notes"
  48. // EdgeUser holds the string denoting the user edge name in mutations.
  49. EdgeUser = "user"
  50. // EdgeGroup holds the string denoting the group edge name in mutations.
  51. EdgeGroup = "group"
  52. // EdgeAssignedByUser holds the string denoting the assigned_by_user edge name in mutations.
  53. EdgeAssignedByUser = "assigned_by_user"
  54. // EdgeUsageLogs holds the string denoting the usage_logs edge name in mutations.
  55. EdgeUsageLogs = "usage_logs"
  56. // Table holds the table name of the usersubscription in the database.
  57. Table = "user_subscriptions"
  58. // UserTable is the table that holds the user relation/edge.
  59. UserTable = "user_subscriptions"
  60. // UserInverseTable is the table name for the User entity.
  61. // It exists in this package in order to avoid circular dependency with the "user" package.
  62. UserInverseTable = "users"
  63. // UserColumn is the table column denoting the user relation/edge.
  64. UserColumn = "user_id"
  65. // GroupTable is the table that holds the group relation/edge.
  66. GroupTable = "user_subscriptions"
  67. // GroupInverseTable is the table name for the Group entity.
  68. // It exists in this package in order to avoid circular dependency with the "group" package.
  69. GroupInverseTable = "groups"
  70. // GroupColumn is the table column denoting the group relation/edge.
  71. GroupColumn = "group_id"
  72. // AssignedByUserTable is the table that holds the assigned_by_user relation/edge.
  73. AssignedByUserTable = "user_subscriptions"
  74. // AssignedByUserInverseTable is the table name for the User entity.
  75. // It exists in this package in order to avoid circular dependency with the "user" package.
  76. AssignedByUserInverseTable = "users"
  77. // AssignedByUserColumn is the table column denoting the assigned_by_user relation/edge.
  78. AssignedByUserColumn = "assigned_by"
  79. // UsageLogsTable is the table that holds the usage_logs relation/edge.
  80. UsageLogsTable = "usage_logs"
  81. // UsageLogsInverseTable is the table name for the UsageLog entity.
  82. // It exists in this package in order to avoid circular dependency with the "usagelog" package.
  83. UsageLogsInverseTable = "usage_logs"
  84. // UsageLogsColumn is the table column denoting the usage_logs relation/edge.
  85. UsageLogsColumn = "subscription_id"
  86. )
  87. // Columns holds all SQL columns for usersubscription fields.
  88. var Columns = []string{
  89. FieldID,
  90. FieldCreatedAt,
  91. FieldUpdatedAt,
  92. FieldDeletedAt,
  93. FieldUserID,
  94. FieldGroupID,
  95. FieldStartsAt,
  96. FieldExpiresAt,
  97. FieldStatus,
  98. FieldDailyWindowStart,
  99. FieldWeeklyWindowStart,
  100. FieldMonthlyWindowStart,
  101. FieldDailyUsageUsd,
  102. FieldWeeklyUsageUsd,
  103. FieldMonthlyUsageUsd,
  104. FieldAssignedBy,
  105. FieldAssignedAt,
  106. FieldNotes,
  107. }
  108. // ValidColumn reports if the column name is valid (part of the table columns).
  109. func ValidColumn(column string) bool {
  110. for i := range Columns {
  111. if column == Columns[i] {
  112. return true
  113. }
  114. }
  115. return false
  116. }
  117. // Note that the variables below are initialized by the runtime
  118. // package on the initialization of the application. Therefore,
  119. // it should be imported in the main as follows:
  120. //
  121. // import _ "github.com/Wei-Shaw/sub2api/ent/runtime"
  122. var (
  123. Hooks [1]ent.Hook
  124. Interceptors [1]ent.Interceptor
  125. // DefaultCreatedAt holds the default value on creation for the "created_at" field.
  126. DefaultCreatedAt func() time.Time
  127. // DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
  128. DefaultUpdatedAt func() time.Time
  129. // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
  130. UpdateDefaultUpdatedAt func() time.Time
  131. // DefaultStatus holds the default value on creation for the "status" field.
  132. DefaultStatus string
  133. // StatusValidator is a validator for the "status" field. It is called by the builders before save.
  134. StatusValidator func(string) error
  135. // DefaultDailyUsageUsd holds the default value on creation for the "daily_usage_usd" field.
  136. DefaultDailyUsageUsd float64
  137. // DefaultWeeklyUsageUsd holds the default value on creation for the "weekly_usage_usd" field.
  138. DefaultWeeklyUsageUsd float64
  139. // DefaultMonthlyUsageUsd holds the default value on creation for the "monthly_usage_usd" field.
  140. DefaultMonthlyUsageUsd float64
  141. // DefaultAssignedAt holds the default value on creation for the "assigned_at" field.
  142. DefaultAssignedAt func() time.Time
  143. )
  144. // OrderOption defines the ordering options for the UserSubscription queries.
  145. type OrderOption func(*sql.Selector)
  146. // ByID orders the results by the id field.
  147. func ByID(opts ...sql.OrderTermOption) OrderOption {
  148. return sql.OrderByField(FieldID, opts...).ToFunc()
  149. }
  150. // ByCreatedAt orders the results by the created_at field.
  151. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
  152. return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
  153. }
  154. // ByUpdatedAt orders the results by the updated_at field.
  155. func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
  156. return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
  157. }
  158. // ByDeletedAt orders the results by the deleted_at field.
  159. func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
  160. return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
  161. }
  162. // ByUserID orders the results by the user_id field.
  163. func ByUserID(opts ...sql.OrderTermOption) OrderOption {
  164. return sql.OrderByField(FieldUserID, opts...).ToFunc()
  165. }
  166. // ByGroupID orders the results by the group_id field.
  167. func ByGroupID(opts ...sql.OrderTermOption) OrderOption {
  168. return sql.OrderByField(FieldGroupID, opts...).ToFunc()
  169. }
  170. // ByStartsAt orders the results by the starts_at field.
  171. func ByStartsAt(opts ...sql.OrderTermOption) OrderOption {
  172. return sql.OrderByField(FieldStartsAt, opts...).ToFunc()
  173. }
  174. // ByExpiresAt orders the results by the expires_at field.
  175. func ByExpiresAt(opts ...sql.OrderTermOption) OrderOption {
  176. return sql.OrderByField(FieldExpiresAt, opts...).ToFunc()
  177. }
  178. // ByStatus orders the results by the status field.
  179. func ByStatus(opts ...sql.OrderTermOption) OrderOption {
  180. return sql.OrderByField(FieldStatus, opts...).ToFunc()
  181. }
  182. // ByDailyWindowStart orders the results by the daily_window_start field.
  183. func ByDailyWindowStart(opts ...sql.OrderTermOption) OrderOption {
  184. return sql.OrderByField(FieldDailyWindowStart, opts...).ToFunc()
  185. }
  186. // ByWeeklyWindowStart orders the results by the weekly_window_start field.
  187. func ByWeeklyWindowStart(opts ...sql.OrderTermOption) OrderOption {
  188. return sql.OrderByField(FieldWeeklyWindowStart, opts...).ToFunc()
  189. }
  190. // ByMonthlyWindowStart orders the results by the monthly_window_start field.
  191. func ByMonthlyWindowStart(opts ...sql.OrderTermOption) OrderOption {
  192. return sql.OrderByField(FieldMonthlyWindowStart, opts...).ToFunc()
  193. }
  194. // ByDailyUsageUsd orders the results by the daily_usage_usd field.
  195. func ByDailyUsageUsd(opts ...sql.OrderTermOption) OrderOption {
  196. return sql.OrderByField(FieldDailyUsageUsd, opts...).ToFunc()
  197. }
  198. // ByWeeklyUsageUsd orders the results by the weekly_usage_usd field.
  199. func ByWeeklyUsageUsd(opts ...sql.OrderTermOption) OrderOption {
  200. return sql.OrderByField(FieldWeeklyUsageUsd, opts...).ToFunc()
  201. }
  202. // ByMonthlyUsageUsd orders the results by the monthly_usage_usd field.
  203. func ByMonthlyUsageUsd(opts ...sql.OrderTermOption) OrderOption {
  204. return sql.OrderByField(FieldMonthlyUsageUsd, opts...).ToFunc()
  205. }
  206. // ByAssignedBy orders the results by the assigned_by field.
  207. func ByAssignedBy(opts ...sql.OrderTermOption) OrderOption {
  208. return sql.OrderByField(FieldAssignedBy, opts...).ToFunc()
  209. }
  210. // ByAssignedAt orders the results by the assigned_at field.
  211. func ByAssignedAt(opts ...sql.OrderTermOption) OrderOption {
  212. return sql.OrderByField(FieldAssignedAt, opts...).ToFunc()
  213. }
  214. // ByNotes orders the results by the notes field.
  215. func ByNotes(opts ...sql.OrderTermOption) OrderOption {
  216. return sql.OrderByField(FieldNotes, opts...).ToFunc()
  217. }
  218. // ByUserField orders the results by user field.
  219. func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
  220. return func(s *sql.Selector) {
  221. sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
  222. }
  223. }
  224. // ByGroupField orders the results by group field.
  225. func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption {
  226. return func(s *sql.Selector) {
  227. sqlgraph.OrderByNeighborTerms(s, newGroupStep(), sql.OrderByField(field, opts...))
  228. }
  229. }
  230. // ByAssignedByUserField orders the results by assigned_by_user field.
  231. func ByAssignedByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
  232. return func(s *sql.Selector) {
  233. sqlgraph.OrderByNeighborTerms(s, newAssignedByUserStep(), sql.OrderByField(field, opts...))
  234. }
  235. }
  236. // ByUsageLogsCount orders the results by usage_logs count.
  237. func ByUsageLogsCount(opts ...sql.OrderTermOption) OrderOption {
  238. return func(s *sql.Selector) {
  239. sqlgraph.OrderByNeighborsCount(s, newUsageLogsStep(), opts...)
  240. }
  241. }
  242. // ByUsageLogs orders the results by usage_logs terms.
  243. func ByUsageLogs(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
  244. return func(s *sql.Selector) {
  245. sqlgraph.OrderByNeighborTerms(s, newUsageLogsStep(), append([]sql.OrderTerm{term}, terms...)...)
  246. }
  247. }
  248. func newUserStep() *sqlgraph.Step {
  249. return sqlgraph.NewStep(
  250. sqlgraph.From(Table, FieldID),
  251. sqlgraph.To(UserInverseTable, FieldID),
  252. sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
  253. )
  254. }
  255. func newGroupStep() *sqlgraph.Step {
  256. return sqlgraph.NewStep(
  257. sqlgraph.From(Table, FieldID),
  258. sqlgraph.To(GroupInverseTable, FieldID),
  259. sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
  260. )
  261. }
  262. func newAssignedByUserStep() *sqlgraph.Step {
  263. return sqlgraph.NewStep(
  264. sqlgraph.From(Table, FieldID),
  265. sqlgraph.To(AssignedByUserInverseTable, FieldID),
  266. sqlgraph.Edge(sqlgraph.M2O, true, AssignedByUserTable, AssignedByUserColumn),
  267. )
  268. }
  269. func newUsageLogsStep() *sqlgraph.Step {
  270. return sqlgraph.NewStep(
  271. sqlgraph.From(Table, FieldID),
  272. sqlgraph.To(UsageLogsInverseTable, FieldID),
  273. sqlgraph.Edge(sqlgraph.O2M, false, UsageLogsTable, UsageLogsColumn),
  274. )
  275. }