164 lines
5.0 KiB
Go
Raw Normal View History

2024-03-13 14:39:45 +01:00
// Code generated by ent, DO NOT EDIT.
package user
import (
"fmt"
"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"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
2024-05-19 17:04:15 +02:00
// FieldEmail holds the string denoting the email field in the database.
FieldEmail = "email"
2024-05-15 15:27:18 +02:00
// FieldPassword holds the string denoting the password field in the database.
FieldPassword = "password"
2024-03-13 14:39:45 +01:00
// FieldRole holds the string denoting the role field in the database.
FieldRole = "role"
// EdgeTeams holds the string denoting the teams edge name in mutations.
EdgeTeams = "teams"
2024-05-19 17:04:15 +02:00
// EdgeProjects holds the string denoting the projects edge name in mutations.
EdgeProjects = "projects"
2024-03-13 14:39:45 +01:00
// Table holds the table name of the user in the database.
Table = "users"
// TeamsTable is the table that holds the teams relation/edge. The primary key declared below.
TeamsTable = "user_teams"
// TeamsInverseTable is the table name for the Team entity.
// It exists in this package in order to avoid circular dependency with the "team" package.
TeamsInverseTable = "teams"
2024-05-19 17:04:15 +02:00
// ProjectsTable is the table that holds the projects relation/edge. The primary key declared below.
ProjectsTable = "user_projects"
// ProjectsInverseTable is the table name for the Project entity.
// It exists in this package in order to avoid circular dependency with the "project" package.
ProjectsInverseTable = "projects"
2024-03-13 14:39:45 +01:00
)
// Columns holds all SQL columns for user fields.
var Columns = []string{
FieldID,
FieldName,
2024-05-19 17:04:15 +02:00
FieldEmail,
2024-05-15 15:27:18 +02:00
FieldPassword,
2024-03-13 14:39:45 +01:00
FieldRole,
}
var (
// TeamsPrimaryKey and TeamsColumn2 are the table columns denoting the
// primary key for the teams relation (M2M).
TeamsPrimaryKey = []string{"user_id", "team_id"}
2024-05-19 17:04:15 +02:00
// ProjectsPrimaryKey and ProjectsColumn2 are the table columns denoting the
// primary key for the projects relation (M2M).
ProjectsPrimaryKey = []string{"user_id", "project_id"}
2024-03-13 14:39:45 +01:00
)
// 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
}
// Role defines the type for the "role" enum field.
type Role string
// Role values.
const (
RoleAdmin Role = "admin"
RoleUser Role = "user"
RoleVisitor Role = "visitor"
)
func (r Role) String() string {
return string(r)
}
// RoleValidator is a validator for the "role" field enum values. It is called by the builders before save.
func RoleValidator(r Role) error {
switch r {
case RoleAdmin, RoleUser, RoleVisitor:
return nil
default:
return fmt.Errorf("user: invalid enum value for role field: %q", r)
}
}
// 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()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
2024-05-19 17:04:15 +02:00
// ByEmail orders the results by the email field.
func ByEmail(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEmail, opts...).ToFunc()
}
2024-05-15 15:27:18 +02:00
// ByPassword orders the results by the password field.
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPassword, opts...).ToFunc()
}
2024-03-13 14:39:45 +01:00
// ByRole orders the results by the role field.
func ByRole(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRole, opts...).ToFunc()
}
// ByTeamsCount orders the results by teams count.
func ByTeamsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newTeamsStep(), opts...)
}
}
// ByTeams orders the results by teams terms.
func ByTeams(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newTeamsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
2024-05-19 17:04:15 +02:00
// ByProjectsCount orders the results by projects count.
func ByProjectsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newProjectsStep(), opts...)
}
}
// ByProjects orders the results by projects terms.
func ByProjects(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newProjectsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
2024-03-13 14:39:45 +01:00
func newTeamsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(TeamsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, TeamsTable, TeamsPrimaryKey...),
)
}
2024-05-19 17:04:15 +02:00
func newProjectsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ProjectsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, ProjectsTable, ProjectsPrimaryKey...),
)
}