Files
ent/entc/integration/migrate/entv1/user/user.go
Ariel Mashraki da69615bd0 entc/gen: rename <type>.Order to <type>.OrderOption (#3468)
Also, avoid generting predicate without op in case a field named: order_option
2023-04-11 08:23:29 +03:00

279 lines
9.1 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 (
"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 = "oid"
// FieldAge holds the string denoting the age field in the database.
FieldAge = "age"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldDescription holds the string denoting the description field in the database.
FieldDescription = "description"
// FieldNickname holds the string denoting the nickname field in the database.
FieldNickname = "nickname"
// FieldAddress holds the string denoting the address field in the database.
FieldAddress = "address"
// FieldRenamed holds the string denoting the renamed field in the database.
FieldRenamed = "renamed"
// FieldOldToken holds the string denoting the old_token field in the database.
FieldOldToken = "old_token"
// FieldBlob holds the string denoting the blob field in the database.
FieldBlob = "blob"
// FieldState holds the string denoting the state field in the database.
FieldState = "state"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldWorkplace holds the string denoting the workplace field in the database.
FieldWorkplace = "workplace"
// FieldDropOptional holds the string denoting the drop_optional field in the database.
FieldDropOptional = "drop_optional"
// EdgeParent holds the string denoting the parent edge name in mutations.
EdgeParent = "parent"
// EdgeChildren holds the string denoting the children edge name in mutations.
EdgeChildren = "children"
// EdgeSpouse holds the string denoting the spouse edge name in mutations.
EdgeSpouse = "spouse"
// EdgeCar holds the string denoting the car edge name in mutations.
EdgeCar = "car"
// CarFieldID holds the string denoting the ID field of the Car.
CarFieldID = "id"
// Table holds the table name of the user in the database.
Table = "users"
// ParentTable is the table that holds the parent relation/edge.
ParentTable = "users"
// ParentColumn is the table column denoting the parent relation/edge.
ParentColumn = "user_children"
// ChildrenTable is the table that holds the children relation/edge.
ChildrenTable = "users"
// ChildrenColumn is the table column denoting the children relation/edge.
ChildrenColumn = "user_children"
// SpouseTable is the table that holds the spouse relation/edge.
SpouseTable = "users"
// SpouseColumn is the table column denoting the spouse relation/edge.
SpouseColumn = "user_spouse"
// CarTable is the table that holds the car relation/edge.
CarTable = "Car"
// CarInverseTable is the table name for the Car entity.
// It exists in this package in order to avoid circular dependency with the "car" package.
CarInverseTable = "Car"
// CarColumn is the table column denoting the car relation/edge.
CarColumn = "user_car"
)
// Columns holds all SQL columns for user fields.
var Columns = []string{
FieldID,
FieldAge,
FieldName,
FieldDescription,
FieldNickname,
FieldAddress,
FieldRenamed,
FieldOldToken,
FieldBlob,
FieldState,
FieldStatus,
FieldWorkplace,
FieldDropOptional,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "users"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"user_children",
"user_spouse",
}
// 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
}
}
for i := range ForeignKeys {
if column == ForeignKeys[i] {
return true
}
}
return false
}
var (
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator func(string) error
// DefaultOldToken holds the default value on creation for the "old_token" field.
DefaultOldToken func() string
// BlobValidator is a validator for the "blob" field. It is called by the builders before save.
BlobValidator func([]byte) error
// WorkplaceValidator is a validator for the "workplace" field. It is called by the builders before save.
WorkplaceValidator func(string) error
)
// State defines the type for the "state" enum field.
type State string
// StateLoggedIn is the default value of the State enum.
const DefaultState = StateLoggedIn
// State values.
const (
StateLoggedIn State = "logged_in"
StateLoggedOut State = "logged_out"
)
func (s State) String() string {
return string(s)
}
// StateValidator is a validator for the "state" field enum values. It is called by the builders before save.
func StateValidator(s State) error {
switch s {
case StateLoggedIn, StateLoggedOut:
return nil
default:
return fmt.Errorf("user: invalid enum value for state 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()
}
// ByAge orders the results by the age field.
func ByAge(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAge, opts...).ToFunc()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByDescription orders the results by the description field.
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDescription, opts...).ToFunc()
}
// ByNickname orders the results by the nickname field.
func ByNickname(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldNickname, opts...).ToFunc()
}
// ByAddress orders the results by the address field.
func ByAddress(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAddress, opts...).ToFunc()
}
// ByRenamed orders the results by the renamed field.
func ByRenamed(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRenamed, opts...).ToFunc()
}
// ByOldToken orders the results by the old_token field.
func ByOldToken(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOldToken, opts...).ToFunc()
}
// ByState orders the results by the state field.
func ByState(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldState, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByWorkplace orders the results by the workplace field.
func ByWorkplace(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldWorkplace, opts...).ToFunc()
}
// ByDropOptional orders the results by the drop_optional field.
func ByDropOptional(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDropOptional, opts...).ToFunc()
}
// ByParentField orders the results by parent field.
func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...))
}
}
// ByChildrenCount orders the results by children count.
func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...)
}
}
// ByChildren orders the results by children terms.
func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// BySpouseField orders the results by spouse field.
func BySpouseField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newSpouseStep(), sql.OrderByField(field, opts...))
}
}
// ByCarField orders the results by car field.
func ByCarField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newCarStep(), sql.OrderByField(field, opts...))
}
}
func newParentStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
)
}
func newChildrenStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn),
)
}
func newSpouseStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2O, false, SpouseTable, SpouseColumn),
)
}
func newCarStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(CarInverseTable, CarFieldID),
sqlgraph.Edge(sqlgraph.O2O, false, CarTable, CarColumn),
)
}