// 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 doc import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/customid/ent/schema" ) const ( // Label holds the string label denoting the doc type in the database. Label = "doc" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldText holds the string denoting the text field in the database. FieldText = "text" // 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" // EdgeRelated holds the string denoting the related edge name in mutations. EdgeRelated = "related" // Table holds the table name of the doc in the database. Table = "docs" // ParentTable is the table that holds the parent relation/edge. ParentTable = "docs" // ParentColumn is the table column denoting the parent relation/edge. ParentColumn = "doc_children" // ChildrenTable is the table that holds the children relation/edge. ChildrenTable = "docs" // ChildrenColumn is the table column denoting the children relation/edge. ChildrenColumn = "doc_children" // RelatedTable is the table that holds the related relation/edge. The primary key declared below. RelatedTable = "doc_related" ) // Columns holds all SQL columns for doc fields. var Columns = []string{ FieldID, FieldText, } // ForeignKeys holds the SQL foreign-keys that are owned by the "docs" // table and are not defined as standalone fields in the schema. var ForeignKeys = []string{ "doc_children", } var ( // RelatedPrimaryKey and RelatedColumn2 are the table columns denoting the // primary key for the related relation (M2M). RelatedPrimaryKey = []string{"doc_id", "related_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 } } for i := range ForeignKeys { if column == ForeignKeys[i] { return true } } return false } var ( // DefaultID holds the default value on creation for the "id" field. DefaultID func() schema.DocID // IDValidator is a validator for the "id" field. It is called by the builders before save. IDValidator func(string) error ) // OrderOption defines the ordering options for the Doc 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() } // ByText orders the results by the text field. func ByText(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldText, 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...)...) } } // ByRelatedCount orders the results by related count. func ByRelatedCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborsCount(s, newRelatedStep(), opts...) } } // ByRelated orders the results by related terms. func ByRelated(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newRelatedStep(), append([]sql.OrderTerm{term}, terms...)...) } } 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 newRelatedStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(Table, FieldID), sqlgraph.Edge(sqlgraph.M2M, false, RelatedTable, RelatedPrimaryKey...), ) }