question.go•6.45 kB
// Code generated by ent, DO NOT EDIT.
package question
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/rs/xid"
)
const (
// Label holds the string label denoting the question type in the database.
Label = "question"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldIndexedAt holds the string denoting the indexed_at field in the database.
FieldIndexedAt = "indexed_at"
// FieldSlug holds the string denoting the slug field in the database.
FieldSlug = "slug"
// FieldQuery holds the string denoting the query field in the database.
FieldQuery = "query"
// FieldResult holds the string denoting the result field in the database.
FieldResult = "result"
// FieldMetadata holds the string denoting the metadata field in the database.
FieldMetadata = "metadata"
// FieldAccountID holds the string denoting the account_id field in the database.
FieldAccountID = "account_id"
// FieldParentQuestionID holds the string denoting the parent_question_id field in the database.
FieldParentQuestionID = "parent_question_id"
// EdgeAuthor holds the string denoting the author edge name in mutations.
EdgeAuthor = "author"
// EdgeParent holds the string denoting the parent edge name in mutations.
EdgeParent = "parent"
// EdgeParentQuestion holds the string denoting the parent_question edge name in mutations.
EdgeParentQuestion = "parent_question"
// Table holds the table name of the question in the database.
Table = "questions"
// AuthorTable is the table that holds the author relation/edge.
AuthorTable = "questions"
// AuthorInverseTable is the table name for the Account entity.
// It exists in this package in order to avoid circular dependency with the "account" package.
AuthorInverseTable = "accounts"
// AuthorColumn is the table column denoting the author relation/edge.
AuthorColumn = "account_id"
// ParentTable is the table that holds the parent relation/edge.
ParentTable = "questions"
// ParentColumn is the table column denoting the parent relation/edge.
ParentColumn = "parent_question_id"
// ParentQuestionTable is the table that holds the parent_question relation/edge.
ParentQuestionTable = "questions"
// ParentQuestionColumn is the table column denoting the parent_question relation/edge.
ParentQuestionColumn = "parent_question_id"
)
// Columns holds all SQL columns for question fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldIndexedAt,
FieldSlug,
FieldQuery,
FieldResult,
FieldMetadata,
FieldAccountID,
FieldParentQuestionID,
}
// 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 (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// DefaultID holds the default value on creation for the "id" field.
DefaultID func() xid.ID
// 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 Question 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()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByIndexedAt orders the results by the indexed_at field.
func ByIndexedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIndexedAt, opts...).ToFunc()
}
// BySlug orders the results by the slug field.
func BySlug(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSlug, opts...).ToFunc()
}
// ByQuery orders the results by the query field.
func ByQuery(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldQuery, opts...).ToFunc()
}
// ByResult orders the results by the result field.
func ByResult(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldResult, opts...).ToFunc()
}
// ByAccountID orders the results by the account_id field.
func ByAccountID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAccountID, opts...).ToFunc()
}
// ByParentQuestionID orders the results by the parent_question_id field.
func ByParentQuestionID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldParentQuestionID, opts...).ToFunc()
}
// ByAuthorField orders the results by author field.
func ByAuthorField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newAuthorStep(), 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...))
}
}
// ByParentQuestionCount orders the results by parent_question count.
func ByParentQuestionCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newParentQuestionStep(), opts...)
}
}
// ByParentQuestion orders the results by parent_question terms.
func ByParentQuestion(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newParentQuestionStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newAuthorStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(AuthorInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, AuthorTable, AuthorColumn),
)
}
func newParentStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
)
}
func newParentQuestionStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ParentQuestionTable, ParentQuestionColumn),
)
}