rano/db/ent/audit/audit.go

175 lines
5.6 KiB
Go
Raw Normal View History

2024-11-10 09:22:33 +00:00
// Code generated by ent, DO NOT EDIT.
package audit
import (
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the audit type in the database.
Label = "audit"
// 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"
// FieldEntName holds the string denoting the ent_name field in the database.
FieldEntName = "ent_name"
// FieldEntID holds the string denoting the ent_id field in the database.
FieldEntID = "ent_id"
// FieldOperation holds the string denoting the operation field in the database.
FieldOperation = "operation"
// FieldDescription holds the string denoting the description field in the database.
FieldDescription = "description"
// FieldIP holds the string denoting the ip field in the database.
FieldIP = "ip"
// FieldUserName holds the string denoting the user_name field in the database.
FieldUserName = "user_name"
// EdgeUser holds the string denoting the user edge name in mutations.
EdgeUser = "user"
// Table holds the table name of the audit in the database.
Table = "audits"
// UserTable is the table that holds the user relation/edge.
UserTable = "audits"
// UserInverseTable is the table name for the User entity.
// It exists in this package in order to avoid circular dependency with the "user" package.
UserInverseTable = "users"
// UserColumn is the table column denoting the user relation/edge.
UserColumn = "user_id"
)
// Columns holds all SQL columns for audit fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldEntName,
FieldEntID,
FieldOperation,
FieldDescription,
FieldIP,
FieldUserName,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "audits"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"user_id",
}
// 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
// EntNameValidator is a validator for the "ent_name" field. It is called by the builders before save.
EntNameValidator func(string) error
// EntIDValidator is a validator for the "ent_id" field. It is called by the builders before save.
EntIDValidator func(int64) error
// DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
DescriptionValidator func(string) error
// IPValidator is a validator for the "ip" field. It is called by the builders before save.
IPValidator func(string) error
// UserNameValidator is a validator for the "user_name" field. It is called by the builders before save.
UserNameValidator func(string) error
)
// Operation defines the type for the "operation" enum field.
type Operation string
// Operation values.
const (
OperationCreate Operation = "Create"
OperationUpdate Operation = "Update"
OperationUpdateOne Operation = "UpdateOne"
OperationDelete Operation = "Delete"
OperationDeleteOne Operation = "DeleteOne"
)
func (o Operation) String() string {
return string(o)
}
// OperationValidator is a validator for the "operation" field enum values. It is called by the builders before save.
func OperationValidator(o Operation) error {
switch o {
case OperationCreate, OperationUpdate, OperationUpdateOne, OperationDelete, OperationDeleteOne:
return nil
default:
return fmt.Errorf("audit: invalid enum value for operation field: %q", o)
}
}
// OrderOption defines the ordering options for the Audit 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()
}
// ByEntName orders the results by the ent_name field.
func ByEntName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEntName, opts...).ToFunc()
}
// ByEntID orders the results by the ent_id field.
func ByEntID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEntID, opts...).ToFunc()
}
// ByOperation orders the results by the operation field.
func ByOperation(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOperation, opts...).ToFunc()
}
// ByDescription orders the results by the description field.
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDescription, opts...).ToFunc()
}
// ByIP orders the results by the ip field.
func ByIP(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIP, opts...).ToFunc()
}
// ByUserName orders the results by the user_name field.
func ByUserName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserName, opts...).ToFunc()
}
// ByUserField orders the results by user field.
func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
}
}
func newUserStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(UserInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
)
}