announcementread.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // Code generated by ent, DO NOT EDIT.
  2. package announcementread
  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 announcementread type in the database.
  10. Label = "announcement_read"
  11. // FieldID holds the string denoting the id field in the database.
  12. FieldID = "id"
  13. // FieldAnnouncementID holds the string denoting the announcement_id field in the database.
  14. FieldAnnouncementID = "announcement_id"
  15. // FieldUserID holds the string denoting the user_id field in the database.
  16. FieldUserID = "user_id"
  17. // FieldReadAt holds the string denoting the read_at field in the database.
  18. FieldReadAt = "read_at"
  19. // FieldCreatedAt holds the string denoting the created_at field in the database.
  20. FieldCreatedAt = "created_at"
  21. // EdgeAnnouncement holds the string denoting the announcement edge name in mutations.
  22. EdgeAnnouncement = "announcement"
  23. // EdgeUser holds the string denoting the user edge name in mutations.
  24. EdgeUser = "user"
  25. // Table holds the table name of the announcementread in the database.
  26. Table = "announcement_reads"
  27. // AnnouncementTable is the table that holds the announcement relation/edge.
  28. AnnouncementTable = "announcement_reads"
  29. // AnnouncementInverseTable is the table name for the Announcement entity.
  30. // It exists in this package in order to avoid circular dependency with the "announcement" package.
  31. AnnouncementInverseTable = "announcements"
  32. // AnnouncementColumn is the table column denoting the announcement relation/edge.
  33. AnnouncementColumn = "announcement_id"
  34. // UserTable is the table that holds the user relation/edge.
  35. UserTable = "announcement_reads"
  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 announcementread fields.
  43. var Columns = []string{
  44. FieldID,
  45. FieldAnnouncementID,
  46. FieldUserID,
  47. FieldReadAt,
  48. FieldCreatedAt,
  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. // DefaultReadAt holds the default value on creation for the "read_at" field.
  61. DefaultReadAt func() time.Time
  62. // DefaultCreatedAt holds the default value on creation for the "created_at" field.
  63. DefaultCreatedAt func() time.Time
  64. )
  65. // OrderOption defines the ordering options for the AnnouncementRead queries.
  66. type OrderOption func(*sql.Selector)
  67. // ByID orders the results by the id field.
  68. func ByID(opts ...sql.OrderTermOption) OrderOption {
  69. return sql.OrderByField(FieldID, opts...).ToFunc()
  70. }
  71. // ByAnnouncementID orders the results by the announcement_id field.
  72. func ByAnnouncementID(opts ...sql.OrderTermOption) OrderOption {
  73. return sql.OrderByField(FieldAnnouncementID, opts...).ToFunc()
  74. }
  75. // ByUserID orders the results by the user_id field.
  76. func ByUserID(opts ...sql.OrderTermOption) OrderOption {
  77. return sql.OrderByField(FieldUserID, opts...).ToFunc()
  78. }
  79. // ByReadAt orders the results by the read_at field.
  80. func ByReadAt(opts ...sql.OrderTermOption) OrderOption {
  81. return sql.OrderByField(FieldReadAt, opts...).ToFunc()
  82. }
  83. // ByCreatedAt orders the results by the created_at field.
  84. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
  85. return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
  86. }
  87. // ByAnnouncementField orders the results by announcement field.
  88. func ByAnnouncementField(field string, opts ...sql.OrderTermOption) OrderOption {
  89. return func(s *sql.Selector) {
  90. sqlgraph.OrderByNeighborTerms(s, newAnnouncementStep(), sql.OrderByField(field, opts...))
  91. }
  92. }
  93. // ByUserField orders the results by user field.
  94. func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
  95. return func(s *sql.Selector) {
  96. sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
  97. }
  98. }
  99. func newAnnouncementStep() *sqlgraph.Step {
  100. return sqlgraph.NewStep(
  101. sqlgraph.From(Table, FieldID),
  102. sqlgraph.To(AnnouncementInverseTable, FieldID),
  103. sqlgraph.Edge(sqlgraph.M2O, true, AnnouncementTable, AnnouncementColumn),
  104. )
  105. }
  106. func newUserStep() *sqlgraph.Step {
  107. return sqlgraph.NewStep(
  108. sqlgraph.From(Table, FieldID),
  109. sqlgraph.To(UserInverseTable, FieldID),
  110. sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
  111. )
  112. }