217 lines
7.4 KiB
Go
217 lines
7.4 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package user
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
)
|
|
|
|
const (
|
|
// Label holds the string label denoting the user type in the database.
|
|
Label = "user"
|
|
// FieldID holds the string denoting the id field in the database.
|
|
FieldID = "id"
|
|
// FieldEmail holds the string denoting the email field in the database.
|
|
FieldEmail = "email"
|
|
// FieldPasswordHash holds the string denoting the password_hash field in the database.
|
|
FieldPasswordHash = "password_hash"
|
|
// FieldStatus holds the string denoting the status field in the database.
|
|
FieldStatus = "status"
|
|
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
|
FieldCreatedAt = "created_at"
|
|
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
|
FieldUpdatedAt = "updated_at"
|
|
// EdgeRoles holds the string denoting the roles edge name in mutations.
|
|
EdgeRoles = "roles"
|
|
// EdgeContributors holds the string denoting the contributors edge name in mutations.
|
|
EdgeContributors = "contributors"
|
|
// EdgeMedia holds the string denoting the media edge name in mutations.
|
|
EdgeMedia = "media"
|
|
// Table holds the table name of the user in the database.
|
|
Table = "users"
|
|
// RolesTable is the table that holds the roles relation/edge. The primary key declared below.
|
|
RolesTable = "user_roles"
|
|
// RolesInverseTable is the table name for the Role entity.
|
|
// It exists in this package in order to avoid circular dependency with the "role" package.
|
|
RolesInverseTable = "roles"
|
|
// ContributorsTable is the table that holds the contributors relation/edge.
|
|
ContributorsTable = "contributors"
|
|
// ContributorsInverseTable is the table name for the Contributor entity.
|
|
// It exists in this package in order to avoid circular dependency with the "contributor" package.
|
|
ContributorsInverseTable = "contributors"
|
|
// ContributorsColumn is the table column denoting the contributors relation/edge.
|
|
ContributorsColumn = "user_contributors"
|
|
// MediaTable is the table that holds the media relation/edge.
|
|
MediaTable = "media"
|
|
// MediaInverseTable is the table name for the Media entity.
|
|
// It exists in this package in order to avoid circular dependency with the "media" package.
|
|
MediaInverseTable = "media"
|
|
// MediaColumn is the table column denoting the media relation/edge.
|
|
MediaColumn = "user_media"
|
|
)
|
|
|
|
// Columns holds all SQL columns for user fields.
|
|
var Columns = []string{
|
|
FieldID,
|
|
FieldEmail,
|
|
FieldPasswordHash,
|
|
FieldStatus,
|
|
FieldCreatedAt,
|
|
FieldUpdatedAt,
|
|
}
|
|
|
|
var (
|
|
// RolesPrimaryKey and RolesColumn2 are the table columns denoting the
|
|
// primary key for the roles relation (M2M).
|
|
RolesPrimaryKey = []string{"user_id", "role_id"}
|
|
)
|
|
|
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
|
func ValidColumn(column string) bool {
|
|
for i := range Columns {
|
|
if column == Columns[i] {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
var (
|
|
// EmailValidator is a validator for the "email" field. It is called by the builders before save.
|
|
EmailValidator func(string) error
|
|
// PasswordHashValidator is a validator for the "password_hash" field. It is called by the builders before save.
|
|
PasswordHashValidator func(string) error
|
|
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
|
DefaultCreatedAt func() time.Time
|
|
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
|
DefaultUpdatedAt func() time.Time
|
|
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
|
UpdateDefaultUpdatedAt func() time.Time
|
|
)
|
|
|
|
// Status defines the type for the "status" enum field.
|
|
type Status string
|
|
|
|
// StatusActive is the default value of the Status enum.
|
|
const DefaultStatus = StatusActive
|
|
|
|
// Status values.
|
|
const (
|
|
StatusActive Status = "active"
|
|
StatusInactive Status = "inactive"
|
|
StatusBanned Status = "banned"
|
|
)
|
|
|
|
func (s Status) String() string {
|
|
return string(s)
|
|
}
|
|
|
|
// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
|
|
func StatusValidator(s Status) error {
|
|
switch s {
|
|
case StatusActive, StatusInactive, StatusBanned:
|
|
return nil
|
|
default:
|
|
return fmt.Errorf("user: invalid enum value for status field: %q", s)
|
|
}
|
|
}
|
|
|
|
// OrderOption defines the ordering options for the User queries.
|
|
type OrderOption func(*sql.Selector)
|
|
|
|
// ByID orders the results by the id field.
|
|
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldID, opts...).ToFunc()
|
|
}
|
|
|
|
// ByEmail orders the results by the email field.
|
|
func ByEmail(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldEmail, opts...).ToFunc()
|
|
}
|
|
|
|
// ByPasswordHash orders the results by the password_hash field.
|
|
func ByPasswordHash(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldPasswordHash, opts...).ToFunc()
|
|
}
|
|
|
|
// ByStatus orders the results by the status field.
|
|
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
|
}
|
|
|
|
// ByCreatedAt orders the results by the created_at field.
|
|
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
|
}
|
|
|
|
// ByUpdatedAt orders the results by the updated_at field.
|
|
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
|
}
|
|
|
|
// ByRolesCount orders the results by roles count.
|
|
func ByRolesCount(opts ...sql.OrderTermOption) OrderOption {
|
|
return func(s *sql.Selector) {
|
|
sqlgraph.OrderByNeighborsCount(s, newRolesStep(), opts...)
|
|
}
|
|
}
|
|
|
|
// ByRoles orders the results by roles terms.
|
|
func ByRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
|
return func(s *sql.Selector) {
|
|
sqlgraph.OrderByNeighborTerms(s, newRolesStep(), append([]sql.OrderTerm{term}, terms...)...)
|
|
}
|
|
}
|
|
|
|
// ByContributorsCount orders the results by contributors count.
|
|
func ByContributorsCount(opts ...sql.OrderTermOption) OrderOption {
|
|
return func(s *sql.Selector) {
|
|
sqlgraph.OrderByNeighborsCount(s, newContributorsStep(), opts...)
|
|
}
|
|
}
|
|
|
|
// ByContributors orders the results by contributors terms.
|
|
func ByContributors(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
|
return func(s *sql.Selector) {
|
|
sqlgraph.OrderByNeighborTerms(s, newContributorsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
|
}
|
|
}
|
|
|
|
// ByMediaCount orders the results by media count.
|
|
func ByMediaCount(opts ...sql.OrderTermOption) OrderOption {
|
|
return func(s *sql.Selector) {
|
|
sqlgraph.OrderByNeighborsCount(s, newMediaStep(), opts...)
|
|
}
|
|
}
|
|
|
|
// ByMedia orders the results by media terms.
|
|
func ByMedia(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
|
return func(s *sql.Selector) {
|
|
sqlgraph.OrderByNeighborTerms(s, newMediaStep(), append([]sql.OrderTerm{term}, terms...)...)
|
|
}
|
|
}
|
|
func newRolesStep() *sqlgraph.Step {
|
|
return sqlgraph.NewStep(
|
|
sqlgraph.From(Table, FieldID),
|
|
sqlgraph.To(RolesInverseTable, FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2M, false, RolesTable, RolesPrimaryKey...),
|
|
)
|
|
}
|
|
func newContributorsStep() *sqlgraph.Step {
|
|
return sqlgraph.NewStep(
|
|
sqlgraph.From(Table, FieldID),
|
|
sqlgraph.To(ContributorsInverseTable, FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, ContributorsTable, ContributorsColumn),
|
|
)
|
|
}
|
|
func newMediaStep() *sqlgraph.Step {
|
|
return sqlgraph.NewStep(
|
|
sqlgraph.From(Table, FieldID),
|
|
sqlgraph.To(MediaInverseTable, FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, MediaTable, MediaColumn),
|
|
)
|
|
}
|