Files
upstream-ent/examples/triggers/ent/userauditlog.go
upstream-mirror 4b3ad0b611
Some checks failed
Atlas CI Public / lint (push) Failing after 13s
Atlas CI Public / sync (push) Has been skipped
snapshot of https://github.com/ent/ent.git (master, 2026-09-15; blobs > 131072B omitted)
2026-09-15 22:12:36 +05:00

137 lines
4.5 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/examples/triggers/ent/userauditlog"
)
// UserAuditLog is the model entity for the UserAuditLog schema.
type UserAuditLog struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// OperationType holds the value of the "operation_type" field.
OperationType string `json:"operation_type,omitempty"`
// OperationTime holds the value of the "operation_time" field.
OperationTime string `json:"operation_time,omitempty"`
// OldValue holds the value of the "old_value" field.
OldValue string `json:"old_value,omitempty"`
// NewValue holds the value of the "new_value" field.
NewValue string `json:"new_value,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*UserAuditLog) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case userauditlog.FieldID:
values[i] = new(sql.NullInt64)
case userauditlog.FieldOperationType, userauditlog.FieldOperationTime, userauditlog.FieldOldValue, userauditlog.FieldNewValue:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the UserAuditLog fields.
func (_m *UserAuditLog) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case userauditlog.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int(value.Int64)
case userauditlog.FieldOperationType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field operation_type", values[i])
} else if value.Valid {
_m.OperationType = value.String
}
case userauditlog.FieldOperationTime:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field operation_time", values[i])
} else if value.Valid {
_m.OperationTime = value.String
}
case userauditlog.FieldOldValue:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field old_value", values[i])
} else if value.Valid {
_m.OldValue = value.String
}
case userauditlog.FieldNewValue:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field new_value", values[i])
} else if value.Valid {
_m.NewValue = value.String
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the UserAuditLog.
// This includes values selected through modifiers, order, etc.
func (_m *UserAuditLog) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this UserAuditLog.
// Note that you need to call UserAuditLog.Unwrap() before calling this method if this UserAuditLog
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *UserAuditLog) Update() *UserAuditLogUpdateOne {
return NewUserAuditLogClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the UserAuditLog entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *UserAuditLog) Unwrap() *UserAuditLog {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: UserAuditLog is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *UserAuditLog) String() string {
var builder strings.Builder
builder.WriteString("UserAuditLog(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("operation_type=")
builder.WriteString(_m.OperationType)
builder.WriteString(", ")
builder.WriteString("operation_time=")
builder.WriteString(_m.OperationTime)
builder.WriteString(", ")
builder.WriteString("old_value=")
builder.WriteString(_m.OldValue)
builder.WriteString(", ")
builder.WriteString("new_value=")
builder.WriteString(_m.NewValue)
builder.WriteByte(')')
return builder.String()
}
// UserAuditLogs is a parsable slice of UserAuditLog.
type UserAuditLogs []*UserAuditLog