// 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 comment import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" ) const ( // Label holds the string label denoting the comment type in the database. Label = "comment" // 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" // FieldPostID holds the string denoting the post_id field in the database. FieldPostID = "post_id" // EdgePost holds the string denoting the post edge name in mutations. EdgePost = "post" // Table holds the table name of the comment in the database. Table = "comments" // PostTable is the table that holds the post relation/edge. PostTable = "comments" // PostInverseTable is the table name for the Post entity. // It exists in this package in order to avoid circular dependency with the "post" package. PostInverseTable = "posts" // PostColumn is the table column denoting the post relation/edge. PostColumn = "post_id" ) // Columns holds all SQL columns for comment fields. var Columns = []string{ FieldID, FieldText, FieldPostID, } // 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 } // OrderOption defines the ordering options for the Comment 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() } // ByPostID orders the results by the post_id field. func ByPostID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPostID, opts...).ToFunc() } // ByPostField orders the results by post field. func ByPostField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newPostStep(), sql.OrderByField(field, opts...)) } } func newPostStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(PostInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, PostTable, PostColumn), ) }