Files
upstream-mirror 4b3ad0b611
Some checks failed
Atlas CI Public / lint (push) Failing after 13s
Atlas CI Public / sync (push) Has been skipped
snapshot of https://github.com/ent/ent.git (master, 2026-09-15; blobs > 131072B omitted)
2026-09-15 22:12:36 +05:00

138 lines
4.4 KiB
Go

// Copyright 2019-present Facebook Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
// Code generated by ent, DO NOT EDIT.
package user
import (
"entgo.io/ent"
"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"
// FieldAge holds the string denoting the age field in the database.
FieldAge = "age"
// EdgeTeams holds the string denoting the teams edge name in mutations.
EdgeTeams = "teams"
// EdgeTasks holds the string denoting the tasks edge name in mutations.
EdgeTasks = "tasks"
// 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"
// TasksTable is the table that holds the tasks relation/edge.
TasksTable = "tasks"
// TasksInverseTable is the table name for the Task entity.
// It exists in this package in order to avoid circular dependency with the "task" package.
TasksInverseTable = "tasks"
// TasksColumn is the table column denoting the tasks relation/edge.
TasksColumn = "user_tasks"
)
// Columns holds all SQL columns for user fields.
var Columns = []string{
FieldID,
FieldName,
FieldAge,
}
var (
// TeamsPrimaryKey and TeamsColumn2 are the table columns denoting the
// primary key for the teams relation (M2M).
TeamsPrimaryKey = []string{"user_id", "team_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
}
// Note that the variables below are initialized by the runtime
// package on the initialization of the application. Therefore,
// it should be imported in the main as follows:
//
// import _ "entgo.io/ent/entc/integration/privacy/ent/runtime"
var (
Hooks [1]ent.Hook
Policy ent.Policy
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator func(string) error
)
// 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()
}
// ByAge orders the results by the age field.
func ByAge(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAge, 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...)...)
}
}
// ByTasksCount orders the results by tasks count.
func ByTasksCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newTasksStep(), opts...)
}
}
// ByTasks orders the results by tasks terms.
func ByTasks(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newTasksStep(), 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 newTasksStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(TasksInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, TasksTable, TasksColumn),
)
}