// 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" // FieldEmail holds the string denoting the email field in the database. FieldEmail = "email" // FieldPassword holds the string denoting the password field in the database. FieldPassword = "password" // 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" // EdgeProjects holds the string denoting the projects edge name in mutations. EdgeProjects = "projects" // 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" // 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" ) // Columns holds all SQL columns for user fields. var Columns = []string{ FieldID, FieldName, FieldEmail, FieldPassword, FieldRole, } var ( // TeamsPrimaryKey and TeamsColumn2 are the table columns denoting the // primary key for the teams relation (M2M). TeamsPrimaryKey = []string{"user_id", "team_id"} // ProjectsPrimaryKey and ProjectsColumn2 are the table columns denoting the // primary key for the projects relation (M2M). ProjectsPrimaryKey = []string{"user_id", "project_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 } // Role defines the type for the "role" enum field. type Role string // Role values. const ( RoleOwner Role = "owner" 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 RoleOwner, 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() } // ByEmail orders the results by the email field. func ByEmail(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldEmail, opts...).ToFunc() } // ByPassword orders the results by the password field. func ByPassword(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPassword, opts...).ToFunc() } // 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...)...) } } // 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...)...) } } func newTeamsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(TeamsInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2M, false, TeamsTable, TeamsPrimaryKey...), ) } func newProjectsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(ProjectsInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2M, false, ProjectsTable, ProjectsPrimaryKey...), ) }