user.go
1 // Code generated by ent, DO NOT EDIT. 2 3 package user 4 5 import ( 6 "time" 7 8 "entgo.io/ent/dialect/sql" 9 "entgo.io/ent/dialect/sql/sqlgraph" 10 "github.com/google/uuid" 11 ) 12 13 const ( 14 // Label holds the string label denoting the user type in the database. 15 Label = "user" 16 // FieldID holds the string denoting the id field in the database. 17 FieldID = "id" 18 // FieldUsername holds the string denoting the username field in the database. 19 FieldUsername = "username" 20 // FieldPassword holds the string denoting the password field in the database. 21 FieldPassword = "password" 22 // FieldRole holds the string denoting the role field in the database. 23 FieldRole = "role" 24 // FieldCreatedAt holds the string denoting the created_at field in the database. 25 FieldCreatedAt = "created_at" 26 // FieldUpdatedAt holds the string denoting the updated_at field in the database. 27 FieldUpdatedAt = "updated_at" 28 // FieldDeletedAt holds the string denoting the deleted_at field in the database. 29 FieldDeletedAt = "deleted_at" 30 // EdgeTokens holds the string denoting the tokens edge name in mutations. 31 EdgeTokens = "tokens" 32 // EdgeSubscribedFeeds holds the string denoting the subscribed_feeds edge name in mutations. 33 EdgeSubscribedFeeds = "subscribed_feeds" 34 // EdgeReadItems holds the string denoting the read_items edge name in mutations. 35 EdgeReadItems = "read_items" 36 // EdgeSubscriptions holds the string denoting the subscriptions edge name in mutations. 37 EdgeSubscriptions = "subscriptions" 38 // EdgeReads holds the string denoting the reads edge name in mutations. 39 EdgeReads = "reads" 40 // Table holds the table name of the user in the database. 41 Table = "users" 42 // TokensTable is the table that holds the tokens relation/edge. 43 TokensTable = "tokens" 44 // TokensInverseTable is the table name for the Token entity. 45 // It exists in this package in order to avoid circular dependency with the "token" package. 46 TokensInverseTable = "tokens" 47 // TokensColumn is the table column denoting the tokens relation/edge. 48 TokensColumn = "user_tokens" 49 // SubscribedFeedsTable is the table that holds the subscribed_feeds relation/edge. The primary key declared below. 50 SubscribedFeedsTable = "subscriptions" 51 // SubscribedFeedsInverseTable is the table name for the Feed entity. 52 // It exists in this package in order to avoid circular dependency with the "feed" package. 53 SubscribedFeedsInverseTable = "feeds" 54 // ReadItemsTable is the table that holds the read_items relation/edge. The primary key declared below. 55 ReadItemsTable = "reads" 56 // ReadItemsInverseTable is the table name for the Item entity. 57 // It exists in this package in order to avoid circular dependency with the "item" package. 58 ReadItemsInverseTable = "items" 59 // SubscriptionsTable is the table that holds the subscriptions relation/edge. 60 SubscriptionsTable = "subscriptions" 61 // SubscriptionsInverseTable is the table name for the Subscription entity. 62 // It exists in this package in order to avoid circular dependency with the "subscription" package. 63 SubscriptionsInverseTable = "subscriptions" 64 // SubscriptionsColumn is the table column denoting the subscriptions relation/edge. 65 SubscriptionsColumn = "user_id" 66 // ReadsTable is the table that holds the reads relation/edge. 67 ReadsTable = "reads" 68 // ReadsInverseTable is the table name for the Read entity. 69 // It exists in this package in order to avoid circular dependency with the "read" package. 70 ReadsInverseTable = "reads" 71 // ReadsColumn is the table column denoting the reads relation/edge. 72 ReadsColumn = "user_id" 73 ) 74 75 // Columns holds all SQL columns for user fields. 76 var Columns = []string{ 77 FieldID, 78 FieldUsername, 79 FieldPassword, 80 FieldRole, 81 FieldCreatedAt, 82 FieldUpdatedAt, 83 FieldDeletedAt, 84 } 85 86 var ( 87 // SubscribedFeedsPrimaryKey and SubscribedFeedsColumn2 are the table columns denoting the 88 // primary key for the subscribed_feeds relation (M2M). 89 SubscribedFeedsPrimaryKey = []string{"user_id", "feed_id"} 90 // ReadItemsPrimaryKey and ReadItemsColumn2 are the table columns denoting the 91 // primary key for the read_items relation (M2M). 92 ReadItemsPrimaryKey = []string{"user_id", "item_id"} 93 ) 94 95 // ValidColumn reports if the column name is valid (part of the table columns). 96 func ValidColumn(column string) bool { 97 for i := range Columns { 98 if column == Columns[i] { 99 return true 100 } 101 } 102 return false 103 } 104 105 var ( 106 // UsernameValidator is a validator for the "username" field. It is called by the builders before save. 107 UsernameValidator func(string) error 108 // PasswordValidator is a validator for the "password" field. It is called by the builders before save. 109 PasswordValidator func(string) error 110 // DefaultRole holds the default value on creation for the "role" field. 111 DefaultRole string 112 // RoleValidator is a validator for the "role" field. It is called by the builders before save. 113 RoleValidator func(string) error 114 // DefaultCreatedAt holds the default value on creation for the "created_at" field. 115 DefaultCreatedAt func() time.Time 116 // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. 117 DefaultUpdatedAt func() time.Time 118 // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. 119 UpdateDefaultUpdatedAt func() time.Time 120 // DefaultID holds the default value on creation for the "id" field. 121 DefaultID func() uuid.UUID 122 ) 123 124 // OrderOption defines the ordering options for the User queries. 125 type OrderOption func(*sql.Selector) 126 127 // ByID orders the results by the id field. 128 func ByID(opts ...sql.OrderTermOption) OrderOption { 129 return sql.OrderByField(FieldID, opts...).ToFunc() 130 } 131 132 // ByUsername orders the results by the username field. 133 func ByUsername(opts ...sql.OrderTermOption) OrderOption { 134 return sql.OrderByField(FieldUsername, opts...).ToFunc() 135 } 136 137 // ByPassword orders the results by the password field. 138 func ByPassword(opts ...sql.OrderTermOption) OrderOption { 139 return sql.OrderByField(FieldPassword, opts...).ToFunc() 140 } 141 142 // ByRole orders the results by the role field. 143 func ByRole(opts ...sql.OrderTermOption) OrderOption { 144 return sql.OrderByField(FieldRole, opts...).ToFunc() 145 } 146 147 // ByCreatedAt orders the results by the created_at field. 148 func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { 149 return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() 150 } 151 152 // ByUpdatedAt orders the results by the updated_at field. 153 func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { 154 return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() 155 } 156 157 // ByDeletedAt orders the results by the deleted_at field. 158 func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { 159 return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() 160 } 161 162 // ByTokensCount orders the results by tokens count. 163 func ByTokensCount(opts ...sql.OrderTermOption) OrderOption { 164 return func(s *sql.Selector) { 165 sqlgraph.OrderByNeighborsCount(s, newTokensStep(), opts...) 166 } 167 } 168 169 // ByTokens orders the results by tokens terms. 170 func ByTokens(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { 171 return func(s *sql.Selector) { 172 sqlgraph.OrderByNeighborTerms(s, newTokensStep(), append([]sql.OrderTerm{term}, terms...)...) 173 } 174 } 175 176 // BySubscribedFeedsCount orders the results by subscribed_feeds count. 177 func BySubscribedFeedsCount(opts ...sql.OrderTermOption) OrderOption { 178 return func(s *sql.Selector) { 179 sqlgraph.OrderByNeighborsCount(s, newSubscribedFeedsStep(), opts...) 180 } 181 } 182 183 // BySubscribedFeeds orders the results by subscribed_feeds terms. 184 func BySubscribedFeeds(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { 185 return func(s *sql.Selector) { 186 sqlgraph.OrderByNeighborTerms(s, newSubscribedFeedsStep(), append([]sql.OrderTerm{term}, terms...)...) 187 } 188 } 189 190 // ByReadItemsCount orders the results by read_items count. 191 func ByReadItemsCount(opts ...sql.OrderTermOption) OrderOption { 192 return func(s *sql.Selector) { 193 sqlgraph.OrderByNeighborsCount(s, newReadItemsStep(), opts...) 194 } 195 } 196 197 // ByReadItems orders the results by read_items terms. 198 func ByReadItems(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { 199 return func(s *sql.Selector) { 200 sqlgraph.OrderByNeighborTerms(s, newReadItemsStep(), append([]sql.OrderTerm{term}, terms...)...) 201 } 202 } 203 204 // BySubscriptionsCount orders the results by subscriptions count. 205 func BySubscriptionsCount(opts ...sql.OrderTermOption) OrderOption { 206 return func(s *sql.Selector) { 207 sqlgraph.OrderByNeighborsCount(s, newSubscriptionsStep(), opts...) 208 } 209 } 210 211 // BySubscriptions orders the results by subscriptions terms. 212 func BySubscriptions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { 213 return func(s *sql.Selector) { 214 sqlgraph.OrderByNeighborTerms(s, newSubscriptionsStep(), append([]sql.OrderTerm{term}, terms...)...) 215 } 216 } 217 218 // ByReadsCount orders the results by reads count. 219 func ByReadsCount(opts ...sql.OrderTermOption) OrderOption { 220 return func(s *sql.Selector) { 221 sqlgraph.OrderByNeighborsCount(s, newReadsStep(), opts...) 222 } 223 } 224 225 // ByReads orders the results by reads terms. 226 func ByReads(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { 227 return func(s *sql.Selector) { 228 sqlgraph.OrderByNeighborTerms(s, newReadsStep(), append([]sql.OrderTerm{term}, terms...)...) 229 } 230 } 231 func newTokensStep() *sqlgraph.Step { 232 return sqlgraph.NewStep( 233 sqlgraph.From(Table, FieldID), 234 sqlgraph.To(TokensInverseTable, FieldID), 235 sqlgraph.Edge(sqlgraph.O2M, false, TokensTable, TokensColumn), 236 ) 237 } 238 func newSubscribedFeedsStep() *sqlgraph.Step { 239 return sqlgraph.NewStep( 240 sqlgraph.From(Table, FieldID), 241 sqlgraph.To(SubscribedFeedsInverseTable, FieldID), 242 sqlgraph.Edge(sqlgraph.M2M, false, SubscribedFeedsTable, SubscribedFeedsPrimaryKey...), 243 ) 244 } 245 func newReadItemsStep() *sqlgraph.Step { 246 return sqlgraph.NewStep( 247 sqlgraph.From(Table, FieldID), 248 sqlgraph.To(ReadItemsInverseTable, FieldID), 249 sqlgraph.Edge(sqlgraph.M2M, false, ReadItemsTable, ReadItemsPrimaryKey...), 250 ) 251 } 252 func newSubscriptionsStep() *sqlgraph.Step { 253 return sqlgraph.NewStep( 254 sqlgraph.From(Table, FieldID), 255 sqlgraph.To(SubscriptionsInverseTable, FieldID), 256 sqlgraph.Edge(sqlgraph.O2M, true, SubscriptionsTable, SubscriptionsColumn), 257 ) 258 } 259 func newReadsStep() *sqlgraph.Step { 260 return sqlgraph.NewStep( 261 sqlgraph.From(Table, FieldID), 262 sqlgraph.To(ReadsInverseTable, FieldID), 263 sqlgraph.Edge(sqlgraph.O2M, true, ReadsTable, ReadsColumn), 264 ) 265 }