report.go•6.52 kB
// Code generated by ent, DO NOT EDIT.
package report
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 report type in the database.
Label = "report"
// 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"
// FieldTargetID holds the string denoting the target_id field in the database.
FieldTargetID = "target_id"
// FieldTargetKind holds the string denoting the target_kind field in the database.
FieldTargetKind = "target_kind"
// FieldReportedByID holds the string denoting the reported_by_id field in the database.
FieldReportedByID = "reported_by_id"
// FieldHandledByID holds the string denoting the handled_by_id field in the database.
FieldHandledByID = "handled_by_id"
// FieldComment holds the string denoting the comment field in the database.
FieldComment = "comment"
// FieldReason holds the string denoting the reason field in the database.
FieldReason = "reason"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// EdgeReportedBy holds the string denoting the reported_by edge name in mutations.
EdgeReportedBy = "reported_by"
// EdgeHandledBy holds the string denoting the handled_by edge name in mutations.
EdgeHandledBy = "handled_by"
// Table holds the table name of the report in the database.
Table = "reports"
// ReportedByTable is the table that holds the reported_by relation/edge.
ReportedByTable = "reports"
// ReportedByInverseTable is the table name for the Account entity.
// It exists in this package in order to avoid circular dependency with the "account" package.
ReportedByInverseTable = "accounts"
// ReportedByColumn is the table column denoting the reported_by relation/edge.
ReportedByColumn = "reported_by_id"
// HandledByTable is the table that holds the handled_by relation/edge.
HandledByTable = "reports"
// HandledByInverseTable is the table name for the Account entity.
// It exists in this package in order to avoid circular dependency with the "account" package.
HandledByInverseTable = "accounts"
// HandledByColumn is the table column denoting the handled_by relation/edge.
HandledByColumn = "handled_by_id"
)
// Columns holds all SQL columns for report fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldTargetID,
FieldTargetKind,
FieldReportedByID,
FieldHandledByID,
FieldComment,
FieldReason,
FieldStatus,
}
// 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
// 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
// DefaultStatus holds the default value on creation for the "status" field.
DefaultStatus string
// 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 Report 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()
}
// ByTargetID orders the results by the target_id field.
func ByTargetID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTargetID, opts...).ToFunc()
}
// ByTargetKind orders the results by the target_kind field.
func ByTargetKind(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTargetKind, opts...).ToFunc()
}
// ByReportedByID orders the results by the reported_by_id field.
func ByReportedByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldReportedByID, opts...).ToFunc()
}
// ByHandledByID orders the results by the handled_by_id field.
func ByHandledByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldHandledByID, opts...).ToFunc()
}
// ByComment orders the results by the comment field.
func ByComment(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldComment, opts...).ToFunc()
}
// ByReason orders the results by the reason field.
func ByReason(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldReason, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByReportedByField orders the results by reported_by field.
func ByReportedByField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newReportedByStep(), sql.OrderByField(field, opts...))
}
}
// ByHandledByField orders the results by handled_by field.
func ByHandledByField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newHandledByStep(), sql.OrderByField(field, opts...))
}
}
func newReportedByStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ReportedByInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ReportedByTable, ReportedByColumn),
)
}
func newHandledByStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(HandledByInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, HandledByTable, HandledByColumn),
)
}