ka/ent/post/post.go

167 lines
5.7 KiB
Go
Raw Normal View History

2024-10-04 20:22:25 +02:00
// Code generated by ent, DO NOT EDIT.
package post
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/google/uuid"
)
const (
// Label holds the string label denoting the post type in the database.
Label = "post"
// 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"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldExpires holds the string denoting the expires field in the database.
FieldExpires = "expires"
// FieldExpireTime holds the string denoting the expire_time field in the database.
FieldExpireTime = "expire_time"
// FieldTitle holds the string denoting the title field in the database.
FieldTitle = "title"
// FieldBody holds the string denoting the body field in the database.
FieldBody = "body"
// EdgeCategory holds the string denoting the category edge name in mutations.
EdgeCategory = "category"
// EdgeProfile holds the string denoting the profile edge name in mutations.
EdgeProfile = "profile"
// Table holds the table name of the post in the database.
Table = "posts"
// CategoryTable is the table that holds the category relation/edge.
CategoryTable = "posts"
// CategoryInverseTable is the table name for the Category entity.
// It exists in this package in order to avoid circular dependency with the "category" package.
CategoryInverseTable = "categories"
// CategoryColumn is the table column denoting the category relation/edge.
CategoryColumn = "category_posts"
// ProfileTable is the table that holds the profile relation/edge.
ProfileTable = "posts"
// ProfileInverseTable is the table name for the Profile entity.
// It exists in this package in order to avoid circular dependency with the "profile" package.
ProfileInverseTable = "profiles"
// ProfileColumn is the table column denoting the profile relation/edge.
ProfileColumn = "profile_posts"
)
// Columns holds all SQL columns for post fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldExpires,
FieldExpireTime,
FieldTitle,
FieldBody,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "posts"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"category_posts",
"profile_posts",
}
// 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 (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultExpires holds the default value on creation for the "expires" field.
DefaultExpires bool
// TitleValidator is a validator for the "title" field. It is called by the builders before save.
TitleValidator func(string) error
// BodyValidator is a validator for the "body" field. It is called by the builders before save.
BodyValidator func(string) error
// DefaultID holds the default value on creation for the "id" field.
DefaultID func() uuid.UUID
)
// OrderOption defines the ordering options for the Post 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()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByExpires orders the results by the expires field.
func ByExpires(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldExpires, opts...).ToFunc()
}
// ByExpireTime orders the results by the expire_time field.
func ByExpireTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldExpireTime, opts...).ToFunc()
}
// ByTitle orders the results by the title field.
func ByTitle(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTitle, opts...).ToFunc()
}
// ByBody orders the results by the body field.
func ByBody(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBody, opts...).ToFunc()
}
// ByCategoryField orders the results by category field.
func ByCategoryField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newCategoryStep(), sql.OrderByField(field, opts...))
}
}
// ByProfileField orders the results by profile field.
func ByProfileField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newProfileStep(), sql.OrderByField(field, opts...))
}
}
func newCategoryStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(CategoryInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, CategoryTable, CategoryColumn),
)
}
func newProfileStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ProfileInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ProfileTable, ProfileColumn),
)
}