// Code generated by ent, DO NOT EDIT.
package auditlog
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 auditlog type in the database.
Label = "audit_log"
// 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"
// FieldEnactedByID holds the string denoting the enacted_by_id field in the database.
FieldEnactedByID = "enacted_by_id"
// 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"
// FieldType holds the string denoting the type field in the database.
FieldType = "type"
// FieldError holds the string denoting the error field in the database.
FieldError = "error"
// FieldMetadata holds the string denoting the metadata field in the database.
FieldMetadata = "metadata"
// EdgeEnactedBy holds the string denoting the enacted_by edge name in mutations.
EdgeEnactedBy = "enacted_by"
// Table holds the table name of the auditlog in the database.
Table = "audit_logs"
// EnactedByTable is the table that holds the enacted_by relation/edge.
EnactedByTable = "audit_logs"
// EnactedByInverseTable is the table name for the Account entity.
// It exists in this package in order to avoid circular dependency with the "account" package.
EnactedByInverseTable = "accounts"
// EnactedByColumn is the table column denoting the enacted_by relation/edge.
EnactedByColumn = "enacted_by_id"
)
// Columns holds all SQL columns for auditlog fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldEnactedByID,
FieldTargetID,
FieldTargetKind,
FieldType,
FieldError,
FieldMetadata,
}
// 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 AuditLog 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()
}
// ByEnactedByID orders the results by the enacted_by_id field.
func ByEnactedByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEnactedByID, 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()
}
// ByType orders the results by the type field.
func ByType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldType, opts...).ToFunc()
}
// ByError orders the results by the error field.
func ByError(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldError, opts...).ToFunc()
}
// ByEnactedByField orders the results by enacted_by field.
func ByEnactedByField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newEnactedByStep(), sql.OrderByField(field, opts...))
}
}
func newEnactedByStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(EnactedByInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, EnactedByTable, EnactedByColumn),
)
}