postread.go•4.15 kB
// Code generated by ent, DO NOT EDIT.
package postread
import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/rs/xid"
)
const (
// Label holds the string label denoting the postread type in the database.
Label = "post_read"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldRootPostID holds the string denoting the root_post_id field in the database.
FieldRootPostID = "root_post_id"
// FieldAccountID holds the string denoting the account_id field in the database.
FieldAccountID = "account_id"
// FieldLastSeenAt holds the string denoting the last_seen_at field in the database.
FieldLastSeenAt = "last_seen_at"
// EdgeRootPost holds the string denoting the root_post edge name in mutations.
EdgeRootPost = "root_post"
// EdgeAccount holds the string denoting the account edge name in mutations.
EdgeAccount = "account"
// Table holds the table name of the postread in the database.
Table = "post_reads"
// RootPostTable is the table that holds the root_post relation/edge.
RootPostTable = "post_reads"
// RootPostInverseTable is the table name for the Post entity.
// It exists in this package in order to avoid circular dependency with the "post" package.
RootPostInverseTable = "posts"
// RootPostColumn is the table column denoting the root_post relation/edge.
RootPostColumn = "root_post_id"
// AccountTable is the table that holds the account relation/edge.
AccountTable = "post_reads"
// AccountInverseTable is the table name for the Account entity.
// It exists in this package in order to avoid circular dependency with the "account" package.
AccountInverseTable = "accounts"
// AccountColumn is the table column denoting the account relation/edge.
AccountColumn = "account_id"
)
// Columns holds all SQL columns for postread fields.
var Columns = []string{
FieldID,
FieldRootPostID,
FieldAccountID,
FieldLastSeenAt,
}
// 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 (
// 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 PostRead 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()
}
// ByRootPostID orders the results by the root_post_id field.
func ByRootPostID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRootPostID, opts...).ToFunc()
}
// ByAccountID orders the results by the account_id field.
func ByAccountID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAccountID, opts...).ToFunc()
}
// ByLastSeenAt orders the results by the last_seen_at field.
func ByLastSeenAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLastSeenAt, opts...).ToFunc()
}
// ByRootPostField orders the results by root_post field.
func ByRootPostField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newRootPostStep(), sql.OrderByField(field, opts...))
}
}
// ByAccountField orders the results by account field.
func ByAccountField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newAccountStep(), sql.OrderByField(field, opts...))
}
}
func newRootPostStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(RootPostInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, RootPostTable, RootPostColumn),
)
}
func newAccountStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(AccountInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, AccountTable, AccountColumn),
)
}