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

120 lines
3.9 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 parent
import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the parent type in the database.
Label = "parent"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldByAdoption holds the string denoting the by_adoption field in the database.
FieldByAdoption = "by_adoption"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldParentID holds the string denoting the parent_id field in the database.
FieldParentID = "parent_id"
// EdgeChild holds the string denoting the child edge name in mutations.
EdgeChild = "child"
// EdgeParent holds the string denoting the parent edge name in mutations.
EdgeParent = "parent"
// Table holds the table name of the parent in the database.
Table = "parents"
// ChildTable is the table that holds the child relation/edge.
ChildTable = "parents"
// ChildInverseTable is the table name for the User entity.
// It exists in this package in order to avoid circular dependency with the "user" package.
ChildInverseTable = "users"
// ChildColumn is the table column denoting the child relation/edge.
ChildColumn = "user_id"
// ParentTable is the table that holds the parent relation/edge.
ParentTable = "parents"
// ParentInverseTable is the table name for the User entity.
// It exists in this package in order to avoid circular dependency with the "user" package.
ParentInverseTable = "users"
// ParentColumn is the table column denoting the parent relation/edge.
ParentColumn = "parent_id"
)
// Columns holds all SQL columns for parent fields.
var Columns = []string{
FieldID,
FieldByAdoption,
FieldUserID,
FieldParentID,
}
// 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 (
// DefaultByAdoption holds the default value on creation for the "by_adoption" field.
DefaultByAdoption bool
)
// OrderOption defines the ordering options for the Parent 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()
}
// ByByAdoption orders the results by the by_adoption field.
func ByByAdoption(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldByAdoption, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByParentID orders the results by the parent_id field.
func ByParentID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldParentID, opts...).ToFunc()
}
// ByChildField orders the results by child field.
func ByChildField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newChildStep(), sql.OrderByField(field, opts...))
}
}
// 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...))
}
}
func newChildStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ChildInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, ChildTable, ChildColumn),
)
}
func newParentStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ParentInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, ParentTable, ParentColumn),
)
}