7731 lines
232 KiB
Go
7731 lines
232 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"sync"
|
|
"time"
|
|
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/actions"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/authorizables"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/blacklist"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/logging"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/predicate"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/punishments"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/servers"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/settings"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/socialmedia"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/support"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/supportresponse"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/user"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/warns"
|
|
|
|
"entgo.io/ent"
|
|
)
|
|
|
|
const (
|
|
// Operation types.
|
|
OpCreate = ent.OpCreate
|
|
OpDelete = ent.OpDelete
|
|
OpDeleteOne = ent.OpDeleteOne
|
|
OpUpdate = ent.OpUpdate
|
|
OpUpdateOne = ent.OpUpdateOne
|
|
|
|
// Node types.
|
|
TypeActions = "Actions"
|
|
TypeAuthorizables = "Authorizables"
|
|
TypeBlacklist = "Blacklist"
|
|
TypeLogging = "Logging"
|
|
TypePunishments = "Punishments"
|
|
TypeServers = "Servers"
|
|
TypeSettings = "Settings"
|
|
TypeSocialmedia = "Socialmedia"
|
|
TypeSupport = "Support"
|
|
TypeSupportResponse = "SupportResponse"
|
|
TypeUser = "User"
|
|
TypeWarns = "Warns"
|
|
)
|
|
|
|
// ActionsMutation represents an operation that mutates the Actions nodes in the graph.
|
|
type ActionsMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
refid *string
|
|
commiter *string
|
|
serverid *string
|
|
target *string
|
|
_type *string
|
|
duration *string
|
|
reason *string
|
|
temp *bool
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Actions, error)
|
|
predicates []predicate.Actions
|
|
}
|
|
|
|
var _ ent.Mutation = (*ActionsMutation)(nil)
|
|
|
|
// actionsOption allows management of the mutation configuration using functional options.
|
|
type actionsOption func(*ActionsMutation)
|
|
|
|
// newActionsMutation creates new mutation for the Actions entity.
|
|
func newActionsMutation(c config, op Op, opts ...actionsOption) *ActionsMutation {
|
|
m := &ActionsMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeActions,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withActionsID sets the ID field of the mutation.
|
|
func withActionsID(id int) actionsOption {
|
|
return func(m *ActionsMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Actions
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Actions, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Actions.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withActions sets the old Actions of the mutation.
|
|
func withActions(node *Actions) actionsOption {
|
|
return func(m *ActionsMutation) {
|
|
m.oldValue = func(context.Context) (*Actions, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m ActionsMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m ActionsMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// SetID sets the value of the id field. Note that this
|
|
// operation is only accepted on creation of Actions entities.
|
|
func (m *ActionsMutation) SetID(id int) {
|
|
m.id = &id
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *ActionsMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *ActionsMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Actions.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetRefid sets the "refid" field.
|
|
func (m *ActionsMutation) SetRefid(s string) {
|
|
m.refid = &s
|
|
}
|
|
|
|
// Refid returns the value of the "refid" field in the mutation.
|
|
func (m *ActionsMutation) Refid() (r string, exists bool) {
|
|
v := m.refid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldRefid returns the old "refid" field's value of the Actions entity.
|
|
// If the Actions object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *ActionsMutation) OldRefid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldRefid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldRefid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldRefid: %w", err)
|
|
}
|
|
return oldValue.Refid, nil
|
|
}
|
|
|
|
// ResetRefid resets all changes to the "refid" field.
|
|
func (m *ActionsMutation) ResetRefid() {
|
|
m.refid = nil
|
|
}
|
|
|
|
// SetCommiter sets the "commiter" field.
|
|
func (m *ActionsMutation) SetCommiter(s string) {
|
|
m.commiter = &s
|
|
}
|
|
|
|
// Commiter returns the value of the "commiter" field in the mutation.
|
|
func (m *ActionsMutation) Commiter() (r string, exists bool) {
|
|
v := m.commiter
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCommiter returns the old "commiter" field's value of the Actions entity.
|
|
// If the Actions object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *ActionsMutation) OldCommiter(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldCommiter is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldCommiter requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldCommiter: %w", err)
|
|
}
|
|
return oldValue.Commiter, nil
|
|
}
|
|
|
|
// ResetCommiter resets all changes to the "commiter" field.
|
|
func (m *ActionsMutation) ResetCommiter() {
|
|
m.commiter = nil
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (m *ActionsMutation) SetServerid(s string) {
|
|
m.serverid = &s
|
|
}
|
|
|
|
// Serverid returns the value of the "serverid" field in the mutation.
|
|
func (m *ActionsMutation) Serverid() (r string, exists bool) {
|
|
v := m.serverid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldServerid returns the old "serverid" field's value of the Actions entity.
|
|
// If the Actions object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *ActionsMutation) OldServerid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldServerid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldServerid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldServerid: %w", err)
|
|
}
|
|
return oldValue.Serverid, nil
|
|
}
|
|
|
|
// ResetServerid resets all changes to the "serverid" field.
|
|
func (m *ActionsMutation) ResetServerid() {
|
|
m.serverid = nil
|
|
}
|
|
|
|
// SetTarget sets the "target" field.
|
|
func (m *ActionsMutation) SetTarget(s string) {
|
|
m.target = &s
|
|
}
|
|
|
|
// Target returns the value of the "target" field in the mutation.
|
|
func (m *ActionsMutation) Target() (r string, exists bool) {
|
|
v := m.target
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTarget returns the old "target" field's value of the Actions entity.
|
|
// If the Actions object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *ActionsMutation) OldTarget(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTarget is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTarget requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTarget: %w", err)
|
|
}
|
|
return oldValue.Target, nil
|
|
}
|
|
|
|
// ResetTarget resets all changes to the "target" field.
|
|
func (m *ActionsMutation) ResetTarget() {
|
|
m.target = nil
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (m *ActionsMutation) SetType(s string) {
|
|
m._type = &s
|
|
}
|
|
|
|
// GetType returns the value of the "type" field in the mutation.
|
|
func (m *ActionsMutation) GetType() (r string, exists bool) {
|
|
v := m._type
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldType returns the old "type" field's value of the Actions entity.
|
|
// If the Actions object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *ActionsMutation) OldType(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldType is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldType requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldType: %w", err)
|
|
}
|
|
return oldValue.Type, nil
|
|
}
|
|
|
|
// ResetType resets all changes to the "type" field.
|
|
func (m *ActionsMutation) ResetType() {
|
|
m._type = nil
|
|
}
|
|
|
|
// SetDuration sets the "duration" field.
|
|
func (m *ActionsMutation) SetDuration(s string) {
|
|
m.duration = &s
|
|
}
|
|
|
|
// Duration returns the value of the "duration" field in the mutation.
|
|
func (m *ActionsMutation) Duration() (r string, exists bool) {
|
|
v := m.duration
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldDuration returns the old "duration" field's value of the Actions entity.
|
|
// If the Actions object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *ActionsMutation) OldDuration(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldDuration is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldDuration requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldDuration: %w", err)
|
|
}
|
|
return oldValue.Duration, nil
|
|
}
|
|
|
|
// ResetDuration resets all changes to the "duration" field.
|
|
func (m *ActionsMutation) ResetDuration() {
|
|
m.duration = nil
|
|
}
|
|
|
|
// SetReason sets the "reason" field.
|
|
func (m *ActionsMutation) SetReason(s string) {
|
|
m.reason = &s
|
|
}
|
|
|
|
// Reason returns the value of the "reason" field in the mutation.
|
|
func (m *ActionsMutation) Reason() (r string, exists bool) {
|
|
v := m.reason
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldReason returns the old "reason" field's value of the Actions entity.
|
|
// If the Actions object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *ActionsMutation) OldReason(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldReason is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldReason requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldReason: %w", err)
|
|
}
|
|
return oldValue.Reason, nil
|
|
}
|
|
|
|
// ResetReason resets all changes to the "reason" field.
|
|
func (m *ActionsMutation) ResetReason() {
|
|
m.reason = nil
|
|
}
|
|
|
|
// SetTemp sets the "temp" field.
|
|
func (m *ActionsMutation) SetTemp(b bool) {
|
|
m.temp = &b
|
|
}
|
|
|
|
// Temp returns the value of the "temp" field in the mutation.
|
|
func (m *ActionsMutation) Temp() (r bool, exists bool) {
|
|
v := m.temp
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTemp returns the old "temp" field's value of the Actions entity.
|
|
// If the Actions object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *ActionsMutation) OldTemp(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTemp is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTemp requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTemp: %w", err)
|
|
}
|
|
return oldValue.Temp, nil
|
|
}
|
|
|
|
// ResetTemp resets all changes to the "temp" field.
|
|
func (m *ActionsMutation) ResetTemp() {
|
|
m.temp = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the ActionsMutation builder.
|
|
func (m *ActionsMutation) Where(ps ...predicate.Actions) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *ActionsMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Actions).
|
|
func (m *ActionsMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *ActionsMutation) Fields() []string {
|
|
fields := make([]string, 0, 8)
|
|
if m.refid != nil {
|
|
fields = append(fields, actions.FieldRefid)
|
|
}
|
|
if m.commiter != nil {
|
|
fields = append(fields, actions.FieldCommiter)
|
|
}
|
|
if m.serverid != nil {
|
|
fields = append(fields, actions.FieldServerid)
|
|
}
|
|
if m.target != nil {
|
|
fields = append(fields, actions.FieldTarget)
|
|
}
|
|
if m._type != nil {
|
|
fields = append(fields, actions.FieldType)
|
|
}
|
|
if m.duration != nil {
|
|
fields = append(fields, actions.FieldDuration)
|
|
}
|
|
if m.reason != nil {
|
|
fields = append(fields, actions.FieldReason)
|
|
}
|
|
if m.temp != nil {
|
|
fields = append(fields, actions.FieldTemp)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *ActionsMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case actions.FieldRefid:
|
|
return m.Refid()
|
|
case actions.FieldCommiter:
|
|
return m.Commiter()
|
|
case actions.FieldServerid:
|
|
return m.Serverid()
|
|
case actions.FieldTarget:
|
|
return m.Target()
|
|
case actions.FieldType:
|
|
return m.GetType()
|
|
case actions.FieldDuration:
|
|
return m.Duration()
|
|
case actions.FieldReason:
|
|
return m.Reason()
|
|
case actions.FieldTemp:
|
|
return m.Temp()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *ActionsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case actions.FieldRefid:
|
|
return m.OldRefid(ctx)
|
|
case actions.FieldCommiter:
|
|
return m.OldCommiter(ctx)
|
|
case actions.FieldServerid:
|
|
return m.OldServerid(ctx)
|
|
case actions.FieldTarget:
|
|
return m.OldTarget(ctx)
|
|
case actions.FieldType:
|
|
return m.OldType(ctx)
|
|
case actions.FieldDuration:
|
|
return m.OldDuration(ctx)
|
|
case actions.FieldReason:
|
|
return m.OldReason(ctx)
|
|
case actions.FieldTemp:
|
|
return m.OldTemp(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Actions field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *ActionsMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case actions.FieldRefid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetRefid(v)
|
|
return nil
|
|
case actions.FieldCommiter:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCommiter(v)
|
|
return nil
|
|
case actions.FieldServerid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetServerid(v)
|
|
return nil
|
|
case actions.FieldTarget:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTarget(v)
|
|
return nil
|
|
case actions.FieldType:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetType(v)
|
|
return nil
|
|
case actions.FieldDuration:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetDuration(v)
|
|
return nil
|
|
case actions.FieldReason:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetReason(v)
|
|
return nil
|
|
case actions.FieldTemp:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTemp(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Actions field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *ActionsMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *ActionsMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *ActionsMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Actions numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *ActionsMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *ActionsMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *ActionsMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown Actions nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *ActionsMutation) ResetField(name string) error {
|
|
switch name {
|
|
case actions.FieldRefid:
|
|
m.ResetRefid()
|
|
return nil
|
|
case actions.FieldCommiter:
|
|
m.ResetCommiter()
|
|
return nil
|
|
case actions.FieldServerid:
|
|
m.ResetServerid()
|
|
return nil
|
|
case actions.FieldTarget:
|
|
m.ResetTarget()
|
|
return nil
|
|
case actions.FieldType:
|
|
m.ResetType()
|
|
return nil
|
|
case actions.FieldDuration:
|
|
m.ResetDuration()
|
|
return nil
|
|
case actions.FieldReason:
|
|
m.ResetReason()
|
|
return nil
|
|
case actions.FieldTemp:
|
|
m.ResetTemp()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Actions field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *ActionsMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *ActionsMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *ActionsMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *ActionsMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *ActionsMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *ActionsMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *ActionsMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Actions unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *ActionsMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Actions edge %s", name)
|
|
}
|
|
|
|
// AuthorizablesMutation represents an operation that mutates the Authorizables nodes in the graph.
|
|
type AuthorizablesMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
username *string
|
|
password *string
|
|
serverid *string
|
|
userid *string
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Authorizables, error)
|
|
predicates []predicate.Authorizables
|
|
}
|
|
|
|
var _ ent.Mutation = (*AuthorizablesMutation)(nil)
|
|
|
|
// authorizablesOption allows management of the mutation configuration using functional options.
|
|
type authorizablesOption func(*AuthorizablesMutation)
|
|
|
|
// newAuthorizablesMutation creates new mutation for the Authorizables entity.
|
|
func newAuthorizablesMutation(c config, op Op, opts ...authorizablesOption) *AuthorizablesMutation {
|
|
m := &AuthorizablesMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeAuthorizables,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withAuthorizablesID sets the ID field of the mutation.
|
|
func withAuthorizablesID(id int) authorizablesOption {
|
|
return func(m *AuthorizablesMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Authorizables
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Authorizables, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Authorizables.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withAuthorizables sets the old Authorizables of the mutation.
|
|
func withAuthorizables(node *Authorizables) authorizablesOption {
|
|
return func(m *AuthorizablesMutation) {
|
|
m.oldValue = func(context.Context) (*Authorizables, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m AuthorizablesMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m AuthorizablesMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *AuthorizablesMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *AuthorizablesMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Authorizables.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (m *AuthorizablesMutation) SetUsername(s string) {
|
|
m.username = &s
|
|
}
|
|
|
|
// Username returns the value of the "username" field in the mutation.
|
|
func (m *AuthorizablesMutation) Username() (r string, exists bool) {
|
|
v := m.username
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUsername returns the old "username" field's value of the Authorizables entity.
|
|
// If the Authorizables object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *AuthorizablesMutation) OldUsername(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldUsername is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldUsername requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldUsername: %w", err)
|
|
}
|
|
return oldValue.Username, nil
|
|
}
|
|
|
|
// ResetUsername resets all changes to the "username" field.
|
|
func (m *AuthorizablesMutation) ResetUsername() {
|
|
m.username = nil
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (m *AuthorizablesMutation) SetPassword(s string) {
|
|
m.password = &s
|
|
}
|
|
|
|
// Password returns the value of the "password" field in the mutation.
|
|
func (m *AuthorizablesMutation) Password() (r string, exists bool) {
|
|
v := m.password
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldPassword returns the old "password" field's value of the Authorizables entity.
|
|
// If the Authorizables object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *AuthorizablesMutation) OldPassword(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldPassword is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldPassword requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldPassword: %w", err)
|
|
}
|
|
return oldValue.Password, nil
|
|
}
|
|
|
|
// ResetPassword resets all changes to the "password" field.
|
|
func (m *AuthorizablesMutation) ResetPassword() {
|
|
m.password = nil
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (m *AuthorizablesMutation) SetServerid(s string) {
|
|
m.serverid = &s
|
|
}
|
|
|
|
// Serverid returns the value of the "serverid" field in the mutation.
|
|
func (m *AuthorizablesMutation) Serverid() (r string, exists bool) {
|
|
v := m.serverid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldServerid returns the old "serverid" field's value of the Authorizables entity.
|
|
// If the Authorizables object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *AuthorizablesMutation) OldServerid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldServerid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldServerid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldServerid: %w", err)
|
|
}
|
|
return oldValue.Serverid, nil
|
|
}
|
|
|
|
// ResetServerid resets all changes to the "serverid" field.
|
|
func (m *AuthorizablesMutation) ResetServerid() {
|
|
m.serverid = nil
|
|
}
|
|
|
|
// SetUserid sets the "userid" field.
|
|
func (m *AuthorizablesMutation) SetUserid(s string) {
|
|
m.userid = &s
|
|
}
|
|
|
|
// Userid returns the value of the "userid" field in the mutation.
|
|
func (m *AuthorizablesMutation) Userid() (r string, exists bool) {
|
|
v := m.userid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUserid returns the old "userid" field's value of the Authorizables entity.
|
|
// If the Authorizables object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *AuthorizablesMutation) OldUserid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldUserid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldUserid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldUserid: %w", err)
|
|
}
|
|
return oldValue.Userid, nil
|
|
}
|
|
|
|
// ResetUserid resets all changes to the "userid" field.
|
|
func (m *AuthorizablesMutation) ResetUserid() {
|
|
m.userid = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the AuthorizablesMutation builder.
|
|
func (m *AuthorizablesMutation) Where(ps ...predicate.Authorizables) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *AuthorizablesMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Authorizables).
|
|
func (m *AuthorizablesMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *AuthorizablesMutation) Fields() []string {
|
|
fields := make([]string, 0, 4)
|
|
if m.username != nil {
|
|
fields = append(fields, authorizables.FieldUsername)
|
|
}
|
|
if m.password != nil {
|
|
fields = append(fields, authorizables.FieldPassword)
|
|
}
|
|
if m.serverid != nil {
|
|
fields = append(fields, authorizables.FieldServerid)
|
|
}
|
|
if m.userid != nil {
|
|
fields = append(fields, authorizables.FieldUserid)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *AuthorizablesMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case authorizables.FieldUsername:
|
|
return m.Username()
|
|
case authorizables.FieldPassword:
|
|
return m.Password()
|
|
case authorizables.FieldServerid:
|
|
return m.Serverid()
|
|
case authorizables.FieldUserid:
|
|
return m.Userid()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *AuthorizablesMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case authorizables.FieldUsername:
|
|
return m.OldUsername(ctx)
|
|
case authorizables.FieldPassword:
|
|
return m.OldPassword(ctx)
|
|
case authorizables.FieldServerid:
|
|
return m.OldServerid(ctx)
|
|
case authorizables.FieldUserid:
|
|
return m.OldUserid(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Authorizables field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *AuthorizablesMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case authorizables.FieldUsername:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUsername(v)
|
|
return nil
|
|
case authorizables.FieldPassword:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetPassword(v)
|
|
return nil
|
|
case authorizables.FieldServerid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetServerid(v)
|
|
return nil
|
|
case authorizables.FieldUserid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUserid(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Authorizables field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *AuthorizablesMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *AuthorizablesMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *AuthorizablesMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Authorizables numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *AuthorizablesMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *AuthorizablesMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *AuthorizablesMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown Authorizables nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *AuthorizablesMutation) ResetField(name string) error {
|
|
switch name {
|
|
case authorizables.FieldUsername:
|
|
m.ResetUsername()
|
|
return nil
|
|
case authorizables.FieldPassword:
|
|
m.ResetPassword()
|
|
return nil
|
|
case authorizables.FieldServerid:
|
|
m.ResetServerid()
|
|
return nil
|
|
case authorizables.FieldUserid:
|
|
m.ResetUserid()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Authorizables field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *AuthorizablesMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *AuthorizablesMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *AuthorizablesMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *AuthorizablesMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *AuthorizablesMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *AuthorizablesMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *AuthorizablesMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Authorizables unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *AuthorizablesMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Authorizables edge %s", name)
|
|
}
|
|
|
|
// BlacklistMutation represents an operation that mutates the Blacklist nodes in the graph.
|
|
type BlacklistMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
serverid *string
|
|
word *string
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Blacklist, error)
|
|
predicates []predicate.Blacklist
|
|
}
|
|
|
|
var _ ent.Mutation = (*BlacklistMutation)(nil)
|
|
|
|
// blacklistOption allows management of the mutation configuration using functional options.
|
|
type blacklistOption func(*BlacklistMutation)
|
|
|
|
// newBlacklistMutation creates new mutation for the Blacklist entity.
|
|
func newBlacklistMutation(c config, op Op, opts ...blacklistOption) *BlacklistMutation {
|
|
m := &BlacklistMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeBlacklist,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withBlacklistID sets the ID field of the mutation.
|
|
func withBlacklistID(id int) blacklistOption {
|
|
return func(m *BlacklistMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Blacklist
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Blacklist, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Blacklist.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withBlacklist sets the old Blacklist of the mutation.
|
|
func withBlacklist(node *Blacklist) blacklistOption {
|
|
return func(m *BlacklistMutation) {
|
|
m.oldValue = func(context.Context) (*Blacklist, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m BlacklistMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m BlacklistMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// SetID sets the value of the id field. Note that this
|
|
// operation is only accepted on creation of Blacklist entities.
|
|
func (m *BlacklistMutation) SetID(id int) {
|
|
m.id = &id
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *BlacklistMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *BlacklistMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Blacklist.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (m *BlacklistMutation) SetServerid(s string) {
|
|
m.serverid = &s
|
|
}
|
|
|
|
// Serverid returns the value of the "serverid" field in the mutation.
|
|
func (m *BlacklistMutation) Serverid() (r string, exists bool) {
|
|
v := m.serverid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldServerid returns the old "serverid" field's value of the Blacklist entity.
|
|
// If the Blacklist object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *BlacklistMutation) OldServerid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldServerid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldServerid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldServerid: %w", err)
|
|
}
|
|
return oldValue.Serverid, nil
|
|
}
|
|
|
|
// ResetServerid resets all changes to the "serverid" field.
|
|
func (m *BlacklistMutation) ResetServerid() {
|
|
m.serverid = nil
|
|
}
|
|
|
|
// SetWord sets the "word" field.
|
|
func (m *BlacklistMutation) SetWord(s string) {
|
|
m.word = &s
|
|
}
|
|
|
|
// Word returns the value of the "word" field in the mutation.
|
|
func (m *BlacklistMutation) Word() (r string, exists bool) {
|
|
v := m.word
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldWord returns the old "word" field's value of the Blacklist entity.
|
|
// If the Blacklist object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *BlacklistMutation) OldWord(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldWord is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldWord requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldWord: %w", err)
|
|
}
|
|
return oldValue.Word, nil
|
|
}
|
|
|
|
// ResetWord resets all changes to the "word" field.
|
|
func (m *BlacklistMutation) ResetWord() {
|
|
m.word = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the BlacklistMutation builder.
|
|
func (m *BlacklistMutation) Where(ps ...predicate.Blacklist) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *BlacklistMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Blacklist).
|
|
func (m *BlacklistMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *BlacklistMutation) Fields() []string {
|
|
fields := make([]string, 0, 2)
|
|
if m.serverid != nil {
|
|
fields = append(fields, blacklist.FieldServerid)
|
|
}
|
|
if m.word != nil {
|
|
fields = append(fields, blacklist.FieldWord)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *BlacklistMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case blacklist.FieldServerid:
|
|
return m.Serverid()
|
|
case blacklist.FieldWord:
|
|
return m.Word()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *BlacklistMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case blacklist.FieldServerid:
|
|
return m.OldServerid(ctx)
|
|
case blacklist.FieldWord:
|
|
return m.OldWord(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Blacklist field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *BlacklistMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case blacklist.FieldServerid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetServerid(v)
|
|
return nil
|
|
case blacklist.FieldWord:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetWord(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Blacklist field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *BlacklistMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *BlacklistMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *BlacklistMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Blacklist numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *BlacklistMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *BlacklistMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *BlacklistMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown Blacklist nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *BlacklistMutation) ResetField(name string) error {
|
|
switch name {
|
|
case blacklist.FieldServerid:
|
|
m.ResetServerid()
|
|
return nil
|
|
case blacklist.FieldWord:
|
|
m.ResetWord()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Blacklist field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *BlacklistMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *BlacklistMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *BlacklistMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *BlacklistMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *BlacklistMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *BlacklistMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *BlacklistMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Blacklist unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *BlacklistMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Blacklist edge %s", name)
|
|
}
|
|
|
|
// LoggingMutation represents an operation that mutates the Logging nodes in the graph.
|
|
type LoggingMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
serverid *string
|
|
_type *string
|
|
commiter *string
|
|
description *string
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Logging, error)
|
|
predicates []predicate.Logging
|
|
}
|
|
|
|
var _ ent.Mutation = (*LoggingMutation)(nil)
|
|
|
|
// loggingOption allows management of the mutation configuration using functional options.
|
|
type loggingOption func(*LoggingMutation)
|
|
|
|
// newLoggingMutation creates new mutation for the Logging entity.
|
|
func newLoggingMutation(c config, op Op, opts ...loggingOption) *LoggingMutation {
|
|
m := &LoggingMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeLogging,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withLoggingID sets the ID field of the mutation.
|
|
func withLoggingID(id int) loggingOption {
|
|
return func(m *LoggingMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Logging
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Logging, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Logging.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withLogging sets the old Logging of the mutation.
|
|
func withLogging(node *Logging) loggingOption {
|
|
return func(m *LoggingMutation) {
|
|
m.oldValue = func(context.Context) (*Logging, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m LoggingMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m LoggingMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// SetID sets the value of the id field. Note that this
|
|
// operation is only accepted on creation of Logging entities.
|
|
func (m *LoggingMutation) SetID(id int) {
|
|
m.id = &id
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *LoggingMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *LoggingMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Logging.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (m *LoggingMutation) SetServerid(s string) {
|
|
m.serverid = &s
|
|
}
|
|
|
|
// Serverid returns the value of the "serverid" field in the mutation.
|
|
func (m *LoggingMutation) Serverid() (r string, exists bool) {
|
|
v := m.serverid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldServerid returns the old "serverid" field's value of the Logging entity.
|
|
// If the Logging object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *LoggingMutation) OldServerid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldServerid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldServerid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldServerid: %w", err)
|
|
}
|
|
return oldValue.Serverid, nil
|
|
}
|
|
|
|
// ResetServerid resets all changes to the "serverid" field.
|
|
func (m *LoggingMutation) ResetServerid() {
|
|
m.serverid = nil
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (m *LoggingMutation) SetType(s string) {
|
|
m._type = &s
|
|
}
|
|
|
|
// GetType returns the value of the "type" field in the mutation.
|
|
func (m *LoggingMutation) GetType() (r string, exists bool) {
|
|
v := m._type
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldType returns the old "type" field's value of the Logging entity.
|
|
// If the Logging object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *LoggingMutation) OldType(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldType is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldType requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldType: %w", err)
|
|
}
|
|
return oldValue.Type, nil
|
|
}
|
|
|
|
// ResetType resets all changes to the "type" field.
|
|
func (m *LoggingMutation) ResetType() {
|
|
m._type = nil
|
|
}
|
|
|
|
// SetCommiter sets the "commiter" field.
|
|
func (m *LoggingMutation) SetCommiter(s string) {
|
|
m.commiter = &s
|
|
}
|
|
|
|
// Commiter returns the value of the "commiter" field in the mutation.
|
|
func (m *LoggingMutation) Commiter() (r string, exists bool) {
|
|
v := m.commiter
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCommiter returns the old "commiter" field's value of the Logging entity.
|
|
// If the Logging object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *LoggingMutation) OldCommiter(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldCommiter is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldCommiter requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldCommiter: %w", err)
|
|
}
|
|
return oldValue.Commiter, nil
|
|
}
|
|
|
|
// ResetCommiter resets all changes to the "commiter" field.
|
|
func (m *LoggingMutation) ResetCommiter() {
|
|
m.commiter = nil
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (m *LoggingMutation) SetDescription(s string) {
|
|
m.description = &s
|
|
}
|
|
|
|
// Description returns the value of the "description" field in the mutation.
|
|
func (m *LoggingMutation) Description() (r string, exists bool) {
|
|
v := m.description
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldDescription returns the old "description" field's value of the Logging entity.
|
|
// If the Logging object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *LoggingMutation) OldDescription(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldDescription is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldDescription requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldDescription: %w", err)
|
|
}
|
|
return oldValue.Description, nil
|
|
}
|
|
|
|
// ResetDescription resets all changes to the "description" field.
|
|
func (m *LoggingMutation) ResetDescription() {
|
|
m.description = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the LoggingMutation builder.
|
|
func (m *LoggingMutation) Where(ps ...predicate.Logging) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *LoggingMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Logging).
|
|
func (m *LoggingMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *LoggingMutation) Fields() []string {
|
|
fields := make([]string, 0, 4)
|
|
if m.serverid != nil {
|
|
fields = append(fields, logging.FieldServerid)
|
|
}
|
|
if m._type != nil {
|
|
fields = append(fields, logging.FieldType)
|
|
}
|
|
if m.commiter != nil {
|
|
fields = append(fields, logging.FieldCommiter)
|
|
}
|
|
if m.description != nil {
|
|
fields = append(fields, logging.FieldDescription)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *LoggingMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case logging.FieldServerid:
|
|
return m.Serverid()
|
|
case logging.FieldType:
|
|
return m.GetType()
|
|
case logging.FieldCommiter:
|
|
return m.Commiter()
|
|
case logging.FieldDescription:
|
|
return m.Description()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *LoggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case logging.FieldServerid:
|
|
return m.OldServerid(ctx)
|
|
case logging.FieldType:
|
|
return m.OldType(ctx)
|
|
case logging.FieldCommiter:
|
|
return m.OldCommiter(ctx)
|
|
case logging.FieldDescription:
|
|
return m.OldDescription(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Logging field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *LoggingMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case logging.FieldServerid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetServerid(v)
|
|
return nil
|
|
case logging.FieldType:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetType(v)
|
|
return nil
|
|
case logging.FieldCommiter:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCommiter(v)
|
|
return nil
|
|
case logging.FieldDescription:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetDescription(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Logging field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *LoggingMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *LoggingMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *LoggingMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Logging numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *LoggingMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *LoggingMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *LoggingMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown Logging nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *LoggingMutation) ResetField(name string) error {
|
|
switch name {
|
|
case logging.FieldServerid:
|
|
m.ResetServerid()
|
|
return nil
|
|
case logging.FieldType:
|
|
m.ResetType()
|
|
return nil
|
|
case logging.FieldCommiter:
|
|
m.ResetCommiter()
|
|
return nil
|
|
case logging.FieldDescription:
|
|
m.ResetDescription()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Logging field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *LoggingMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *LoggingMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *LoggingMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *LoggingMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *LoggingMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *LoggingMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *LoggingMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Logging unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *LoggingMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Logging edge %s", name)
|
|
}
|
|
|
|
// PunishmentsMutation represents an operation that mutates the Punishments nodes in the graph.
|
|
type PunishmentsMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
serverid *string
|
|
warnamount *string
|
|
actiontype *string
|
|
duration *string
|
|
reason *string
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Punishments, error)
|
|
predicates []predicate.Punishments
|
|
}
|
|
|
|
var _ ent.Mutation = (*PunishmentsMutation)(nil)
|
|
|
|
// punishmentsOption allows management of the mutation configuration using functional options.
|
|
type punishmentsOption func(*PunishmentsMutation)
|
|
|
|
// newPunishmentsMutation creates new mutation for the Punishments entity.
|
|
func newPunishmentsMutation(c config, op Op, opts ...punishmentsOption) *PunishmentsMutation {
|
|
m := &PunishmentsMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypePunishments,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withPunishmentsID sets the ID field of the mutation.
|
|
func withPunishmentsID(id int) punishmentsOption {
|
|
return func(m *PunishmentsMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Punishments
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Punishments, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Punishments.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withPunishments sets the old Punishments of the mutation.
|
|
func withPunishments(node *Punishments) punishmentsOption {
|
|
return func(m *PunishmentsMutation) {
|
|
m.oldValue = func(context.Context) (*Punishments, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m PunishmentsMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m PunishmentsMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// SetID sets the value of the id field. Note that this
|
|
// operation is only accepted on creation of Punishments entities.
|
|
func (m *PunishmentsMutation) SetID(id int) {
|
|
m.id = &id
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *PunishmentsMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *PunishmentsMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Punishments.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (m *PunishmentsMutation) SetServerid(s string) {
|
|
m.serverid = &s
|
|
}
|
|
|
|
// Serverid returns the value of the "serverid" field in the mutation.
|
|
func (m *PunishmentsMutation) Serverid() (r string, exists bool) {
|
|
v := m.serverid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldServerid returns the old "serverid" field's value of the Punishments entity.
|
|
// If the Punishments object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *PunishmentsMutation) OldServerid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldServerid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldServerid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldServerid: %w", err)
|
|
}
|
|
return oldValue.Serverid, nil
|
|
}
|
|
|
|
// ResetServerid resets all changes to the "serverid" field.
|
|
func (m *PunishmentsMutation) ResetServerid() {
|
|
m.serverid = nil
|
|
}
|
|
|
|
// SetWarnamount sets the "warnamount" field.
|
|
func (m *PunishmentsMutation) SetWarnamount(s string) {
|
|
m.warnamount = &s
|
|
}
|
|
|
|
// Warnamount returns the value of the "warnamount" field in the mutation.
|
|
func (m *PunishmentsMutation) Warnamount() (r string, exists bool) {
|
|
v := m.warnamount
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldWarnamount returns the old "warnamount" field's value of the Punishments entity.
|
|
// If the Punishments object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *PunishmentsMutation) OldWarnamount(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldWarnamount is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldWarnamount requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldWarnamount: %w", err)
|
|
}
|
|
return oldValue.Warnamount, nil
|
|
}
|
|
|
|
// ResetWarnamount resets all changes to the "warnamount" field.
|
|
func (m *PunishmentsMutation) ResetWarnamount() {
|
|
m.warnamount = nil
|
|
}
|
|
|
|
// SetActiontype sets the "actiontype" field.
|
|
func (m *PunishmentsMutation) SetActiontype(s string) {
|
|
m.actiontype = &s
|
|
}
|
|
|
|
// Actiontype returns the value of the "actiontype" field in the mutation.
|
|
func (m *PunishmentsMutation) Actiontype() (r string, exists bool) {
|
|
v := m.actiontype
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldActiontype returns the old "actiontype" field's value of the Punishments entity.
|
|
// If the Punishments object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *PunishmentsMutation) OldActiontype(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldActiontype is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldActiontype requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldActiontype: %w", err)
|
|
}
|
|
return oldValue.Actiontype, nil
|
|
}
|
|
|
|
// ResetActiontype resets all changes to the "actiontype" field.
|
|
func (m *PunishmentsMutation) ResetActiontype() {
|
|
m.actiontype = nil
|
|
}
|
|
|
|
// SetDuration sets the "duration" field.
|
|
func (m *PunishmentsMutation) SetDuration(s string) {
|
|
m.duration = &s
|
|
}
|
|
|
|
// Duration returns the value of the "duration" field in the mutation.
|
|
func (m *PunishmentsMutation) Duration() (r string, exists bool) {
|
|
v := m.duration
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldDuration returns the old "duration" field's value of the Punishments entity.
|
|
// If the Punishments object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *PunishmentsMutation) OldDuration(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldDuration is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldDuration requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldDuration: %w", err)
|
|
}
|
|
return oldValue.Duration, nil
|
|
}
|
|
|
|
// ResetDuration resets all changes to the "duration" field.
|
|
func (m *PunishmentsMutation) ResetDuration() {
|
|
m.duration = nil
|
|
}
|
|
|
|
// SetReason sets the "reason" field.
|
|
func (m *PunishmentsMutation) SetReason(s string) {
|
|
m.reason = &s
|
|
}
|
|
|
|
// Reason returns the value of the "reason" field in the mutation.
|
|
func (m *PunishmentsMutation) Reason() (r string, exists bool) {
|
|
v := m.reason
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldReason returns the old "reason" field's value of the Punishments entity.
|
|
// If the Punishments object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *PunishmentsMutation) OldReason(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldReason is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldReason requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldReason: %w", err)
|
|
}
|
|
return oldValue.Reason, nil
|
|
}
|
|
|
|
// ResetReason resets all changes to the "reason" field.
|
|
func (m *PunishmentsMutation) ResetReason() {
|
|
m.reason = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the PunishmentsMutation builder.
|
|
func (m *PunishmentsMutation) Where(ps ...predicate.Punishments) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *PunishmentsMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Punishments).
|
|
func (m *PunishmentsMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *PunishmentsMutation) Fields() []string {
|
|
fields := make([]string, 0, 5)
|
|
if m.serverid != nil {
|
|
fields = append(fields, punishments.FieldServerid)
|
|
}
|
|
if m.warnamount != nil {
|
|
fields = append(fields, punishments.FieldWarnamount)
|
|
}
|
|
if m.actiontype != nil {
|
|
fields = append(fields, punishments.FieldActiontype)
|
|
}
|
|
if m.duration != nil {
|
|
fields = append(fields, punishments.FieldDuration)
|
|
}
|
|
if m.reason != nil {
|
|
fields = append(fields, punishments.FieldReason)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *PunishmentsMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case punishments.FieldServerid:
|
|
return m.Serverid()
|
|
case punishments.FieldWarnamount:
|
|
return m.Warnamount()
|
|
case punishments.FieldActiontype:
|
|
return m.Actiontype()
|
|
case punishments.FieldDuration:
|
|
return m.Duration()
|
|
case punishments.FieldReason:
|
|
return m.Reason()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *PunishmentsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case punishments.FieldServerid:
|
|
return m.OldServerid(ctx)
|
|
case punishments.FieldWarnamount:
|
|
return m.OldWarnamount(ctx)
|
|
case punishments.FieldActiontype:
|
|
return m.OldActiontype(ctx)
|
|
case punishments.FieldDuration:
|
|
return m.OldDuration(ctx)
|
|
case punishments.FieldReason:
|
|
return m.OldReason(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Punishments field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *PunishmentsMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case punishments.FieldServerid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetServerid(v)
|
|
return nil
|
|
case punishments.FieldWarnamount:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetWarnamount(v)
|
|
return nil
|
|
case punishments.FieldActiontype:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetActiontype(v)
|
|
return nil
|
|
case punishments.FieldDuration:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetDuration(v)
|
|
return nil
|
|
case punishments.FieldReason:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetReason(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Punishments field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *PunishmentsMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *PunishmentsMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *PunishmentsMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Punishments numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *PunishmentsMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *PunishmentsMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *PunishmentsMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown Punishments nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *PunishmentsMutation) ResetField(name string) error {
|
|
switch name {
|
|
case punishments.FieldServerid:
|
|
m.ResetServerid()
|
|
return nil
|
|
case punishments.FieldWarnamount:
|
|
m.ResetWarnamount()
|
|
return nil
|
|
case punishments.FieldActiontype:
|
|
m.ResetActiontype()
|
|
return nil
|
|
case punishments.FieldDuration:
|
|
m.ResetDuration()
|
|
return nil
|
|
case punishments.FieldReason:
|
|
m.ResetReason()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Punishments field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *PunishmentsMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *PunishmentsMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *PunishmentsMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *PunishmentsMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *PunishmentsMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *PunishmentsMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *PunishmentsMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Punishments unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *PunishmentsMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Punishments edge %s", name)
|
|
}
|
|
|
|
// ServersMutation represents an operation that mutates the Servers nodes in the graph.
|
|
type ServersMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
userid *string
|
|
serverid *string
|
|
isOwner *bool
|
|
permission *string
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Servers, error)
|
|
predicates []predicate.Servers
|
|
}
|
|
|
|
var _ ent.Mutation = (*ServersMutation)(nil)
|
|
|
|
// serversOption allows management of the mutation configuration using functional options.
|
|
type serversOption func(*ServersMutation)
|
|
|
|
// newServersMutation creates new mutation for the Servers entity.
|
|
func newServersMutation(c config, op Op, opts ...serversOption) *ServersMutation {
|
|
m := &ServersMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeServers,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withServersID sets the ID field of the mutation.
|
|
func withServersID(id int) serversOption {
|
|
return func(m *ServersMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Servers
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Servers, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Servers.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withServers sets the old Servers of the mutation.
|
|
func withServers(node *Servers) serversOption {
|
|
return func(m *ServersMutation) {
|
|
m.oldValue = func(context.Context) (*Servers, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m ServersMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m ServersMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// SetID sets the value of the id field. Note that this
|
|
// operation is only accepted on creation of Servers entities.
|
|
func (m *ServersMutation) SetID(id int) {
|
|
m.id = &id
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *ServersMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *ServersMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Servers.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetUserid sets the "userid" field.
|
|
func (m *ServersMutation) SetUserid(s string) {
|
|
m.userid = &s
|
|
}
|
|
|
|
// Userid returns the value of the "userid" field in the mutation.
|
|
func (m *ServersMutation) Userid() (r string, exists bool) {
|
|
v := m.userid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUserid returns the old "userid" field's value of the Servers entity.
|
|
// If the Servers object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *ServersMutation) OldUserid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldUserid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldUserid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldUserid: %w", err)
|
|
}
|
|
return oldValue.Userid, nil
|
|
}
|
|
|
|
// ResetUserid resets all changes to the "userid" field.
|
|
func (m *ServersMutation) ResetUserid() {
|
|
m.userid = nil
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (m *ServersMutation) SetServerid(s string) {
|
|
m.serverid = &s
|
|
}
|
|
|
|
// Serverid returns the value of the "serverid" field in the mutation.
|
|
func (m *ServersMutation) Serverid() (r string, exists bool) {
|
|
v := m.serverid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldServerid returns the old "serverid" field's value of the Servers entity.
|
|
// If the Servers object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *ServersMutation) OldServerid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldServerid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldServerid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldServerid: %w", err)
|
|
}
|
|
return oldValue.Serverid, nil
|
|
}
|
|
|
|
// ResetServerid resets all changes to the "serverid" field.
|
|
func (m *ServersMutation) ResetServerid() {
|
|
m.serverid = nil
|
|
}
|
|
|
|
// SetIsOwner sets the "isOwner" field.
|
|
func (m *ServersMutation) SetIsOwner(b bool) {
|
|
m.isOwner = &b
|
|
}
|
|
|
|
// IsOwner returns the value of the "isOwner" field in the mutation.
|
|
func (m *ServersMutation) IsOwner() (r bool, exists bool) {
|
|
v := m.isOwner
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldIsOwner returns the old "isOwner" field's value of the Servers entity.
|
|
// If the Servers object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *ServersMutation) OldIsOwner(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldIsOwner requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
|
|
}
|
|
return oldValue.IsOwner, nil
|
|
}
|
|
|
|
// ResetIsOwner resets all changes to the "isOwner" field.
|
|
func (m *ServersMutation) ResetIsOwner() {
|
|
m.isOwner = nil
|
|
}
|
|
|
|
// SetPermission sets the "permission" field.
|
|
func (m *ServersMutation) SetPermission(s string) {
|
|
m.permission = &s
|
|
}
|
|
|
|
// Permission returns the value of the "permission" field in the mutation.
|
|
func (m *ServersMutation) Permission() (r string, exists bool) {
|
|
v := m.permission
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldPermission returns the old "permission" field's value of the Servers entity.
|
|
// If the Servers object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *ServersMutation) OldPermission(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldPermission is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldPermission requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldPermission: %w", err)
|
|
}
|
|
return oldValue.Permission, nil
|
|
}
|
|
|
|
// ResetPermission resets all changes to the "permission" field.
|
|
func (m *ServersMutation) ResetPermission() {
|
|
m.permission = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the ServersMutation builder.
|
|
func (m *ServersMutation) Where(ps ...predicate.Servers) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *ServersMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Servers).
|
|
func (m *ServersMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *ServersMutation) Fields() []string {
|
|
fields := make([]string, 0, 4)
|
|
if m.userid != nil {
|
|
fields = append(fields, servers.FieldUserid)
|
|
}
|
|
if m.serverid != nil {
|
|
fields = append(fields, servers.FieldServerid)
|
|
}
|
|
if m.isOwner != nil {
|
|
fields = append(fields, servers.FieldIsOwner)
|
|
}
|
|
if m.permission != nil {
|
|
fields = append(fields, servers.FieldPermission)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *ServersMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case servers.FieldUserid:
|
|
return m.Userid()
|
|
case servers.FieldServerid:
|
|
return m.Serverid()
|
|
case servers.FieldIsOwner:
|
|
return m.IsOwner()
|
|
case servers.FieldPermission:
|
|
return m.Permission()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *ServersMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case servers.FieldUserid:
|
|
return m.OldUserid(ctx)
|
|
case servers.FieldServerid:
|
|
return m.OldServerid(ctx)
|
|
case servers.FieldIsOwner:
|
|
return m.OldIsOwner(ctx)
|
|
case servers.FieldPermission:
|
|
return m.OldPermission(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Servers field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *ServersMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case servers.FieldUserid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUserid(v)
|
|
return nil
|
|
case servers.FieldServerid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetServerid(v)
|
|
return nil
|
|
case servers.FieldIsOwner:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetIsOwner(v)
|
|
return nil
|
|
case servers.FieldPermission:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetPermission(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Servers field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *ServersMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *ServersMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *ServersMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Servers numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *ServersMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *ServersMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *ServersMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown Servers nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *ServersMutation) ResetField(name string) error {
|
|
switch name {
|
|
case servers.FieldUserid:
|
|
m.ResetUserid()
|
|
return nil
|
|
case servers.FieldServerid:
|
|
m.ResetServerid()
|
|
return nil
|
|
case servers.FieldIsOwner:
|
|
m.ResetIsOwner()
|
|
return nil
|
|
case servers.FieldPermission:
|
|
m.ResetPermission()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Servers field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *ServersMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *ServersMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *ServersMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *ServersMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *ServersMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *ServersMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *ServersMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Servers unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *ServersMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Servers edge %s", name)
|
|
}
|
|
|
|
// SettingsMutation represents an operation that mutates the Settings nodes in the graph.
|
|
type SettingsMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
serverid *string
|
|
servername *string
|
|
ownerid *string
|
|
permtoken *string
|
|
apitoken *string
|
|
statspagemode *string
|
|
loggerchannel *string
|
|
spamchannel *string
|
|
greeterchannel *string
|
|
greetermode *string
|
|
announcechannel *string
|
|
logger *bool
|
|
spamprotection *bool
|
|
linkprotection *bool
|
|
wordfilter *bool
|
|
greetings *bool
|
|
apitoggle *bool
|
|
moderation *bool
|
|
automatedmoderation *bool
|
|
twitchannounce *bool
|
|
twitterannounce *bool
|
|
music *bool
|
|
statspage *bool
|
|
statsprivate *bool
|
|
stats *bool
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Settings, error)
|
|
predicates []predicate.Settings
|
|
}
|
|
|
|
var _ ent.Mutation = (*SettingsMutation)(nil)
|
|
|
|
// settingsOption allows management of the mutation configuration using functional options.
|
|
type settingsOption func(*SettingsMutation)
|
|
|
|
// newSettingsMutation creates new mutation for the Settings entity.
|
|
func newSettingsMutation(c config, op Op, opts ...settingsOption) *SettingsMutation {
|
|
m := &SettingsMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeSettings,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withSettingsID sets the ID field of the mutation.
|
|
func withSettingsID(id int) settingsOption {
|
|
return func(m *SettingsMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Settings
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Settings, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Settings.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withSettings sets the old Settings of the mutation.
|
|
func withSettings(node *Settings) settingsOption {
|
|
return func(m *SettingsMutation) {
|
|
m.oldValue = func(context.Context) (*Settings, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m SettingsMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m SettingsMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// SetID sets the value of the id field. Note that this
|
|
// operation is only accepted on creation of Settings entities.
|
|
func (m *SettingsMutation) SetID(id int) {
|
|
m.id = &id
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *SettingsMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *SettingsMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Settings.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (m *SettingsMutation) SetServerid(s string) {
|
|
m.serverid = &s
|
|
}
|
|
|
|
// Serverid returns the value of the "serverid" field in the mutation.
|
|
func (m *SettingsMutation) Serverid() (r string, exists bool) {
|
|
v := m.serverid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldServerid returns the old "serverid" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldServerid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldServerid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldServerid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldServerid: %w", err)
|
|
}
|
|
return oldValue.Serverid, nil
|
|
}
|
|
|
|
// ResetServerid resets all changes to the "serverid" field.
|
|
func (m *SettingsMutation) ResetServerid() {
|
|
m.serverid = nil
|
|
}
|
|
|
|
// SetServername sets the "servername" field.
|
|
func (m *SettingsMutation) SetServername(s string) {
|
|
m.servername = &s
|
|
}
|
|
|
|
// Servername returns the value of the "servername" field in the mutation.
|
|
func (m *SettingsMutation) Servername() (r string, exists bool) {
|
|
v := m.servername
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldServername returns the old "servername" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldServername(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldServername is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldServername requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldServername: %w", err)
|
|
}
|
|
return oldValue.Servername, nil
|
|
}
|
|
|
|
// ResetServername resets all changes to the "servername" field.
|
|
func (m *SettingsMutation) ResetServername() {
|
|
m.servername = nil
|
|
}
|
|
|
|
// SetOwnerid sets the "ownerid" field.
|
|
func (m *SettingsMutation) SetOwnerid(s string) {
|
|
m.ownerid = &s
|
|
}
|
|
|
|
// Ownerid returns the value of the "ownerid" field in the mutation.
|
|
func (m *SettingsMutation) Ownerid() (r string, exists bool) {
|
|
v := m.ownerid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldOwnerid returns the old "ownerid" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldOwnerid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldOwnerid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldOwnerid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldOwnerid: %w", err)
|
|
}
|
|
return oldValue.Ownerid, nil
|
|
}
|
|
|
|
// ResetOwnerid resets all changes to the "ownerid" field.
|
|
func (m *SettingsMutation) ResetOwnerid() {
|
|
m.ownerid = nil
|
|
}
|
|
|
|
// SetPermtoken sets the "permtoken" field.
|
|
func (m *SettingsMutation) SetPermtoken(s string) {
|
|
m.permtoken = &s
|
|
}
|
|
|
|
// Permtoken returns the value of the "permtoken" field in the mutation.
|
|
func (m *SettingsMutation) Permtoken() (r string, exists bool) {
|
|
v := m.permtoken
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldPermtoken returns the old "permtoken" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldPermtoken(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldPermtoken is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldPermtoken requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldPermtoken: %w", err)
|
|
}
|
|
return oldValue.Permtoken, nil
|
|
}
|
|
|
|
// ResetPermtoken resets all changes to the "permtoken" field.
|
|
func (m *SettingsMutation) ResetPermtoken() {
|
|
m.permtoken = nil
|
|
}
|
|
|
|
// SetApitoken sets the "apitoken" field.
|
|
func (m *SettingsMutation) SetApitoken(s string) {
|
|
m.apitoken = &s
|
|
}
|
|
|
|
// Apitoken returns the value of the "apitoken" field in the mutation.
|
|
func (m *SettingsMutation) Apitoken() (r string, exists bool) {
|
|
v := m.apitoken
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldApitoken returns the old "apitoken" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldApitoken(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldApitoken is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldApitoken requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldApitoken: %w", err)
|
|
}
|
|
return oldValue.Apitoken, nil
|
|
}
|
|
|
|
// ResetApitoken resets all changes to the "apitoken" field.
|
|
func (m *SettingsMutation) ResetApitoken() {
|
|
m.apitoken = nil
|
|
}
|
|
|
|
// SetStatspagemode sets the "statspagemode" field.
|
|
func (m *SettingsMutation) SetStatspagemode(s string) {
|
|
m.statspagemode = &s
|
|
}
|
|
|
|
// Statspagemode returns the value of the "statspagemode" field in the mutation.
|
|
func (m *SettingsMutation) Statspagemode() (r string, exists bool) {
|
|
v := m.statspagemode
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldStatspagemode returns the old "statspagemode" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldStatspagemode(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldStatspagemode is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldStatspagemode requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldStatspagemode: %w", err)
|
|
}
|
|
return oldValue.Statspagemode, nil
|
|
}
|
|
|
|
// ResetStatspagemode resets all changes to the "statspagemode" field.
|
|
func (m *SettingsMutation) ResetStatspagemode() {
|
|
m.statspagemode = nil
|
|
}
|
|
|
|
// SetLoggerchannel sets the "loggerchannel" field.
|
|
func (m *SettingsMutation) SetLoggerchannel(s string) {
|
|
m.loggerchannel = &s
|
|
}
|
|
|
|
// Loggerchannel returns the value of the "loggerchannel" field in the mutation.
|
|
func (m *SettingsMutation) Loggerchannel() (r string, exists bool) {
|
|
v := m.loggerchannel
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldLoggerchannel returns the old "loggerchannel" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldLoggerchannel(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldLoggerchannel is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldLoggerchannel requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldLoggerchannel: %w", err)
|
|
}
|
|
return oldValue.Loggerchannel, nil
|
|
}
|
|
|
|
// ResetLoggerchannel resets all changes to the "loggerchannel" field.
|
|
func (m *SettingsMutation) ResetLoggerchannel() {
|
|
m.loggerchannel = nil
|
|
}
|
|
|
|
// SetSpamchannel sets the "spamchannel" field.
|
|
func (m *SettingsMutation) SetSpamchannel(s string) {
|
|
m.spamchannel = &s
|
|
}
|
|
|
|
// Spamchannel returns the value of the "spamchannel" field in the mutation.
|
|
func (m *SettingsMutation) Spamchannel() (r string, exists bool) {
|
|
v := m.spamchannel
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldSpamchannel returns the old "spamchannel" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldSpamchannel(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldSpamchannel is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldSpamchannel requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldSpamchannel: %w", err)
|
|
}
|
|
return oldValue.Spamchannel, nil
|
|
}
|
|
|
|
// ResetSpamchannel resets all changes to the "spamchannel" field.
|
|
func (m *SettingsMutation) ResetSpamchannel() {
|
|
m.spamchannel = nil
|
|
}
|
|
|
|
// SetGreeterchannel sets the "greeterchannel" field.
|
|
func (m *SettingsMutation) SetGreeterchannel(s string) {
|
|
m.greeterchannel = &s
|
|
}
|
|
|
|
// Greeterchannel returns the value of the "greeterchannel" field in the mutation.
|
|
func (m *SettingsMutation) Greeterchannel() (r string, exists bool) {
|
|
v := m.greeterchannel
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldGreeterchannel returns the old "greeterchannel" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldGreeterchannel(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldGreeterchannel is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldGreeterchannel requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldGreeterchannel: %w", err)
|
|
}
|
|
return oldValue.Greeterchannel, nil
|
|
}
|
|
|
|
// ResetGreeterchannel resets all changes to the "greeterchannel" field.
|
|
func (m *SettingsMutation) ResetGreeterchannel() {
|
|
m.greeterchannel = nil
|
|
}
|
|
|
|
// SetGreetermode sets the "greetermode" field.
|
|
func (m *SettingsMutation) SetGreetermode(s string) {
|
|
m.greetermode = &s
|
|
}
|
|
|
|
// Greetermode returns the value of the "greetermode" field in the mutation.
|
|
func (m *SettingsMutation) Greetermode() (r string, exists bool) {
|
|
v := m.greetermode
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldGreetermode returns the old "greetermode" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldGreetermode(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldGreetermode is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldGreetermode requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldGreetermode: %w", err)
|
|
}
|
|
return oldValue.Greetermode, nil
|
|
}
|
|
|
|
// ResetGreetermode resets all changes to the "greetermode" field.
|
|
func (m *SettingsMutation) ResetGreetermode() {
|
|
m.greetermode = nil
|
|
}
|
|
|
|
// SetAnnouncechannel sets the "announcechannel" field.
|
|
func (m *SettingsMutation) SetAnnouncechannel(s string) {
|
|
m.announcechannel = &s
|
|
}
|
|
|
|
// Announcechannel returns the value of the "announcechannel" field in the mutation.
|
|
func (m *SettingsMutation) Announcechannel() (r string, exists bool) {
|
|
v := m.announcechannel
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldAnnouncechannel returns the old "announcechannel" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldAnnouncechannel(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldAnnouncechannel is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldAnnouncechannel requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldAnnouncechannel: %w", err)
|
|
}
|
|
return oldValue.Announcechannel, nil
|
|
}
|
|
|
|
// ResetAnnouncechannel resets all changes to the "announcechannel" field.
|
|
func (m *SettingsMutation) ResetAnnouncechannel() {
|
|
m.announcechannel = nil
|
|
}
|
|
|
|
// SetLogger sets the "logger" field.
|
|
func (m *SettingsMutation) SetLogger(b bool) {
|
|
m.logger = &b
|
|
}
|
|
|
|
// Logger returns the value of the "logger" field in the mutation.
|
|
func (m *SettingsMutation) Logger() (r bool, exists bool) {
|
|
v := m.logger
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldLogger returns the old "logger" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldLogger(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldLogger is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldLogger requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldLogger: %w", err)
|
|
}
|
|
return oldValue.Logger, nil
|
|
}
|
|
|
|
// ResetLogger resets all changes to the "logger" field.
|
|
func (m *SettingsMutation) ResetLogger() {
|
|
m.logger = nil
|
|
}
|
|
|
|
// SetSpamprotection sets the "spamprotection" field.
|
|
func (m *SettingsMutation) SetSpamprotection(b bool) {
|
|
m.spamprotection = &b
|
|
}
|
|
|
|
// Spamprotection returns the value of the "spamprotection" field in the mutation.
|
|
func (m *SettingsMutation) Spamprotection() (r bool, exists bool) {
|
|
v := m.spamprotection
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldSpamprotection returns the old "spamprotection" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldSpamprotection(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldSpamprotection is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldSpamprotection requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldSpamprotection: %w", err)
|
|
}
|
|
return oldValue.Spamprotection, nil
|
|
}
|
|
|
|
// ResetSpamprotection resets all changes to the "spamprotection" field.
|
|
func (m *SettingsMutation) ResetSpamprotection() {
|
|
m.spamprotection = nil
|
|
}
|
|
|
|
// SetLinkprotection sets the "linkprotection" field.
|
|
func (m *SettingsMutation) SetLinkprotection(b bool) {
|
|
m.linkprotection = &b
|
|
}
|
|
|
|
// Linkprotection returns the value of the "linkprotection" field in the mutation.
|
|
func (m *SettingsMutation) Linkprotection() (r bool, exists bool) {
|
|
v := m.linkprotection
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldLinkprotection returns the old "linkprotection" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldLinkprotection(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldLinkprotection is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldLinkprotection requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldLinkprotection: %w", err)
|
|
}
|
|
return oldValue.Linkprotection, nil
|
|
}
|
|
|
|
// ResetLinkprotection resets all changes to the "linkprotection" field.
|
|
func (m *SettingsMutation) ResetLinkprotection() {
|
|
m.linkprotection = nil
|
|
}
|
|
|
|
// SetWordfilter sets the "wordfilter" field.
|
|
func (m *SettingsMutation) SetWordfilter(b bool) {
|
|
m.wordfilter = &b
|
|
}
|
|
|
|
// Wordfilter returns the value of the "wordfilter" field in the mutation.
|
|
func (m *SettingsMutation) Wordfilter() (r bool, exists bool) {
|
|
v := m.wordfilter
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldWordfilter returns the old "wordfilter" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldWordfilter(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldWordfilter is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldWordfilter requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldWordfilter: %w", err)
|
|
}
|
|
return oldValue.Wordfilter, nil
|
|
}
|
|
|
|
// ResetWordfilter resets all changes to the "wordfilter" field.
|
|
func (m *SettingsMutation) ResetWordfilter() {
|
|
m.wordfilter = nil
|
|
}
|
|
|
|
// SetGreetings sets the "greetings" field.
|
|
func (m *SettingsMutation) SetGreetings(b bool) {
|
|
m.greetings = &b
|
|
}
|
|
|
|
// Greetings returns the value of the "greetings" field in the mutation.
|
|
func (m *SettingsMutation) Greetings() (r bool, exists bool) {
|
|
v := m.greetings
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldGreetings returns the old "greetings" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldGreetings(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldGreetings is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldGreetings requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldGreetings: %w", err)
|
|
}
|
|
return oldValue.Greetings, nil
|
|
}
|
|
|
|
// ResetGreetings resets all changes to the "greetings" field.
|
|
func (m *SettingsMutation) ResetGreetings() {
|
|
m.greetings = nil
|
|
}
|
|
|
|
// SetApitoggle sets the "apitoggle" field.
|
|
func (m *SettingsMutation) SetApitoggle(b bool) {
|
|
m.apitoggle = &b
|
|
}
|
|
|
|
// Apitoggle returns the value of the "apitoggle" field in the mutation.
|
|
func (m *SettingsMutation) Apitoggle() (r bool, exists bool) {
|
|
v := m.apitoggle
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldApitoggle returns the old "apitoggle" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldApitoggle(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldApitoggle is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldApitoggle requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldApitoggle: %w", err)
|
|
}
|
|
return oldValue.Apitoggle, nil
|
|
}
|
|
|
|
// ResetApitoggle resets all changes to the "apitoggle" field.
|
|
func (m *SettingsMutation) ResetApitoggle() {
|
|
m.apitoggle = nil
|
|
}
|
|
|
|
// SetModeration sets the "moderation" field.
|
|
func (m *SettingsMutation) SetModeration(b bool) {
|
|
m.moderation = &b
|
|
}
|
|
|
|
// Moderation returns the value of the "moderation" field in the mutation.
|
|
func (m *SettingsMutation) Moderation() (r bool, exists bool) {
|
|
v := m.moderation
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldModeration returns the old "moderation" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldModeration(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldModeration is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldModeration requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldModeration: %w", err)
|
|
}
|
|
return oldValue.Moderation, nil
|
|
}
|
|
|
|
// ResetModeration resets all changes to the "moderation" field.
|
|
func (m *SettingsMutation) ResetModeration() {
|
|
m.moderation = nil
|
|
}
|
|
|
|
// SetAutomatedmoderation sets the "automatedmoderation" field.
|
|
func (m *SettingsMutation) SetAutomatedmoderation(b bool) {
|
|
m.automatedmoderation = &b
|
|
}
|
|
|
|
// Automatedmoderation returns the value of the "automatedmoderation" field in the mutation.
|
|
func (m *SettingsMutation) Automatedmoderation() (r bool, exists bool) {
|
|
v := m.automatedmoderation
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldAutomatedmoderation returns the old "automatedmoderation" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldAutomatedmoderation(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldAutomatedmoderation is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldAutomatedmoderation requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldAutomatedmoderation: %w", err)
|
|
}
|
|
return oldValue.Automatedmoderation, nil
|
|
}
|
|
|
|
// ResetAutomatedmoderation resets all changes to the "automatedmoderation" field.
|
|
func (m *SettingsMutation) ResetAutomatedmoderation() {
|
|
m.automatedmoderation = nil
|
|
}
|
|
|
|
// SetTwitchannounce sets the "twitchannounce" field.
|
|
func (m *SettingsMutation) SetTwitchannounce(b bool) {
|
|
m.twitchannounce = &b
|
|
}
|
|
|
|
// Twitchannounce returns the value of the "twitchannounce" field in the mutation.
|
|
func (m *SettingsMutation) Twitchannounce() (r bool, exists bool) {
|
|
v := m.twitchannounce
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTwitchannounce returns the old "twitchannounce" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldTwitchannounce(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTwitchannounce is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTwitchannounce requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTwitchannounce: %w", err)
|
|
}
|
|
return oldValue.Twitchannounce, nil
|
|
}
|
|
|
|
// ResetTwitchannounce resets all changes to the "twitchannounce" field.
|
|
func (m *SettingsMutation) ResetTwitchannounce() {
|
|
m.twitchannounce = nil
|
|
}
|
|
|
|
// SetTwitterannounce sets the "twitterannounce" field.
|
|
func (m *SettingsMutation) SetTwitterannounce(b bool) {
|
|
m.twitterannounce = &b
|
|
}
|
|
|
|
// Twitterannounce returns the value of the "twitterannounce" field in the mutation.
|
|
func (m *SettingsMutation) Twitterannounce() (r bool, exists bool) {
|
|
v := m.twitterannounce
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTwitterannounce returns the old "twitterannounce" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldTwitterannounce(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTwitterannounce is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTwitterannounce requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTwitterannounce: %w", err)
|
|
}
|
|
return oldValue.Twitterannounce, nil
|
|
}
|
|
|
|
// ResetTwitterannounce resets all changes to the "twitterannounce" field.
|
|
func (m *SettingsMutation) ResetTwitterannounce() {
|
|
m.twitterannounce = nil
|
|
}
|
|
|
|
// SetMusic sets the "music" field.
|
|
func (m *SettingsMutation) SetMusic(b bool) {
|
|
m.music = &b
|
|
}
|
|
|
|
// Music returns the value of the "music" field in the mutation.
|
|
func (m *SettingsMutation) Music() (r bool, exists bool) {
|
|
v := m.music
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldMusic returns the old "music" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldMusic(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldMusic is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldMusic requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldMusic: %w", err)
|
|
}
|
|
return oldValue.Music, nil
|
|
}
|
|
|
|
// ResetMusic resets all changes to the "music" field.
|
|
func (m *SettingsMutation) ResetMusic() {
|
|
m.music = nil
|
|
}
|
|
|
|
// SetStatspage sets the "statspage" field.
|
|
func (m *SettingsMutation) SetStatspage(b bool) {
|
|
m.statspage = &b
|
|
}
|
|
|
|
// Statspage returns the value of the "statspage" field in the mutation.
|
|
func (m *SettingsMutation) Statspage() (r bool, exists bool) {
|
|
v := m.statspage
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldStatspage returns the old "statspage" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldStatspage(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldStatspage is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldStatspage requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldStatspage: %w", err)
|
|
}
|
|
return oldValue.Statspage, nil
|
|
}
|
|
|
|
// ResetStatspage resets all changes to the "statspage" field.
|
|
func (m *SettingsMutation) ResetStatspage() {
|
|
m.statspage = nil
|
|
}
|
|
|
|
// SetStatsprivate sets the "statsprivate" field.
|
|
func (m *SettingsMutation) SetStatsprivate(b bool) {
|
|
m.statsprivate = &b
|
|
}
|
|
|
|
// Statsprivate returns the value of the "statsprivate" field in the mutation.
|
|
func (m *SettingsMutation) Statsprivate() (r bool, exists bool) {
|
|
v := m.statsprivate
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldStatsprivate returns the old "statsprivate" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldStatsprivate(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldStatsprivate is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldStatsprivate requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldStatsprivate: %w", err)
|
|
}
|
|
return oldValue.Statsprivate, nil
|
|
}
|
|
|
|
// ResetStatsprivate resets all changes to the "statsprivate" field.
|
|
func (m *SettingsMutation) ResetStatsprivate() {
|
|
m.statsprivate = nil
|
|
}
|
|
|
|
// SetStats sets the "stats" field.
|
|
func (m *SettingsMutation) SetStats(b bool) {
|
|
m.stats = &b
|
|
}
|
|
|
|
// Stats returns the value of the "stats" field in the mutation.
|
|
func (m *SettingsMutation) Stats() (r bool, exists bool) {
|
|
v := m.stats
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldStats returns the old "stats" field's value of the Settings entity.
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SettingsMutation) OldStats(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldStats is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldStats requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldStats: %w", err)
|
|
}
|
|
return oldValue.Stats, nil
|
|
}
|
|
|
|
// ResetStats resets all changes to the "stats" field.
|
|
func (m *SettingsMutation) ResetStats() {
|
|
m.stats = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the SettingsMutation builder.
|
|
func (m *SettingsMutation) Where(ps ...predicate.Settings) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *SettingsMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Settings).
|
|
func (m *SettingsMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *SettingsMutation) Fields() []string {
|
|
fields := make([]string, 0, 25)
|
|
if m.serverid != nil {
|
|
fields = append(fields, settings.FieldServerid)
|
|
}
|
|
if m.servername != nil {
|
|
fields = append(fields, settings.FieldServername)
|
|
}
|
|
if m.ownerid != nil {
|
|
fields = append(fields, settings.FieldOwnerid)
|
|
}
|
|
if m.permtoken != nil {
|
|
fields = append(fields, settings.FieldPermtoken)
|
|
}
|
|
if m.apitoken != nil {
|
|
fields = append(fields, settings.FieldApitoken)
|
|
}
|
|
if m.statspagemode != nil {
|
|
fields = append(fields, settings.FieldStatspagemode)
|
|
}
|
|
if m.loggerchannel != nil {
|
|
fields = append(fields, settings.FieldLoggerchannel)
|
|
}
|
|
if m.spamchannel != nil {
|
|
fields = append(fields, settings.FieldSpamchannel)
|
|
}
|
|
if m.greeterchannel != nil {
|
|
fields = append(fields, settings.FieldGreeterchannel)
|
|
}
|
|
if m.greetermode != nil {
|
|
fields = append(fields, settings.FieldGreetermode)
|
|
}
|
|
if m.announcechannel != nil {
|
|
fields = append(fields, settings.FieldAnnouncechannel)
|
|
}
|
|
if m.logger != nil {
|
|
fields = append(fields, settings.FieldLogger)
|
|
}
|
|
if m.spamprotection != nil {
|
|
fields = append(fields, settings.FieldSpamprotection)
|
|
}
|
|
if m.linkprotection != nil {
|
|
fields = append(fields, settings.FieldLinkprotection)
|
|
}
|
|
if m.wordfilter != nil {
|
|
fields = append(fields, settings.FieldWordfilter)
|
|
}
|
|
if m.greetings != nil {
|
|
fields = append(fields, settings.FieldGreetings)
|
|
}
|
|
if m.apitoggle != nil {
|
|
fields = append(fields, settings.FieldApitoggle)
|
|
}
|
|
if m.moderation != nil {
|
|
fields = append(fields, settings.FieldModeration)
|
|
}
|
|
if m.automatedmoderation != nil {
|
|
fields = append(fields, settings.FieldAutomatedmoderation)
|
|
}
|
|
if m.twitchannounce != nil {
|
|
fields = append(fields, settings.FieldTwitchannounce)
|
|
}
|
|
if m.twitterannounce != nil {
|
|
fields = append(fields, settings.FieldTwitterannounce)
|
|
}
|
|
if m.music != nil {
|
|
fields = append(fields, settings.FieldMusic)
|
|
}
|
|
if m.statspage != nil {
|
|
fields = append(fields, settings.FieldStatspage)
|
|
}
|
|
if m.statsprivate != nil {
|
|
fields = append(fields, settings.FieldStatsprivate)
|
|
}
|
|
if m.stats != nil {
|
|
fields = append(fields, settings.FieldStats)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *SettingsMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case settings.FieldServerid:
|
|
return m.Serverid()
|
|
case settings.FieldServername:
|
|
return m.Servername()
|
|
case settings.FieldOwnerid:
|
|
return m.Ownerid()
|
|
case settings.FieldPermtoken:
|
|
return m.Permtoken()
|
|
case settings.FieldApitoken:
|
|
return m.Apitoken()
|
|
case settings.FieldStatspagemode:
|
|
return m.Statspagemode()
|
|
case settings.FieldLoggerchannel:
|
|
return m.Loggerchannel()
|
|
case settings.FieldSpamchannel:
|
|
return m.Spamchannel()
|
|
case settings.FieldGreeterchannel:
|
|
return m.Greeterchannel()
|
|
case settings.FieldGreetermode:
|
|
return m.Greetermode()
|
|
case settings.FieldAnnouncechannel:
|
|
return m.Announcechannel()
|
|
case settings.FieldLogger:
|
|
return m.Logger()
|
|
case settings.FieldSpamprotection:
|
|
return m.Spamprotection()
|
|
case settings.FieldLinkprotection:
|
|
return m.Linkprotection()
|
|
case settings.FieldWordfilter:
|
|
return m.Wordfilter()
|
|
case settings.FieldGreetings:
|
|
return m.Greetings()
|
|
case settings.FieldApitoggle:
|
|
return m.Apitoggle()
|
|
case settings.FieldModeration:
|
|
return m.Moderation()
|
|
case settings.FieldAutomatedmoderation:
|
|
return m.Automatedmoderation()
|
|
case settings.FieldTwitchannounce:
|
|
return m.Twitchannounce()
|
|
case settings.FieldTwitterannounce:
|
|
return m.Twitterannounce()
|
|
case settings.FieldMusic:
|
|
return m.Music()
|
|
case settings.FieldStatspage:
|
|
return m.Statspage()
|
|
case settings.FieldStatsprivate:
|
|
return m.Statsprivate()
|
|
case settings.FieldStats:
|
|
return m.Stats()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *SettingsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case settings.FieldServerid:
|
|
return m.OldServerid(ctx)
|
|
case settings.FieldServername:
|
|
return m.OldServername(ctx)
|
|
case settings.FieldOwnerid:
|
|
return m.OldOwnerid(ctx)
|
|
case settings.FieldPermtoken:
|
|
return m.OldPermtoken(ctx)
|
|
case settings.FieldApitoken:
|
|
return m.OldApitoken(ctx)
|
|
case settings.FieldStatspagemode:
|
|
return m.OldStatspagemode(ctx)
|
|
case settings.FieldLoggerchannel:
|
|
return m.OldLoggerchannel(ctx)
|
|
case settings.FieldSpamchannel:
|
|
return m.OldSpamchannel(ctx)
|
|
case settings.FieldGreeterchannel:
|
|
return m.OldGreeterchannel(ctx)
|
|
case settings.FieldGreetermode:
|
|
return m.OldGreetermode(ctx)
|
|
case settings.FieldAnnouncechannel:
|
|
return m.OldAnnouncechannel(ctx)
|
|
case settings.FieldLogger:
|
|
return m.OldLogger(ctx)
|
|
case settings.FieldSpamprotection:
|
|
return m.OldSpamprotection(ctx)
|
|
case settings.FieldLinkprotection:
|
|
return m.OldLinkprotection(ctx)
|
|
case settings.FieldWordfilter:
|
|
return m.OldWordfilter(ctx)
|
|
case settings.FieldGreetings:
|
|
return m.OldGreetings(ctx)
|
|
case settings.FieldApitoggle:
|
|
return m.OldApitoggle(ctx)
|
|
case settings.FieldModeration:
|
|
return m.OldModeration(ctx)
|
|
case settings.FieldAutomatedmoderation:
|
|
return m.OldAutomatedmoderation(ctx)
|
|
case settings.FieldTwitchannounce:
|
|
return m.OldTwitchannounce(ctx)
|
|
case settings.FieldTwitterannounce:
|
|
return m.OldTwitterannounce(ctx)
|
|
case settings.FieldMusic:
|
|
return m.OldMusic(ctx)
|
|
case settings.FieldStatspage:
|
|
return m.OldStatspage(ctx)
|
|
case settings.FieldStatsprivate:
|
|
return m.OldStatsprivate(ctx)
|
|
case settings.FieldStats:
|
|
return m.OldStats(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Settings field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *SettingsMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case settings.FieldServerid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetServerid(v)
|
|
return nil
|
|
case settings.FieldServername:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetServername(v)
|
|
return nil
|
|
case settings.FieldOwnerid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetOwnerid(v)
|
|
return nil
|
|
case settings.FieldPermtoken:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetPermtoken(v)
|
|
return nil
|
|
case settings.FieldApitoken:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetApitoken(v)
|
|
return nil
|
|
case settings.FieldStatspagemode:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetStatspagemode(v)
|
|
return nil
|
|
case settings.FieldLoggerchannel:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetLoggerchannel(v)
|
|
return nil
|
|
case settings.FieldSpamchannel:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetSpamchannel(v)
|
|
return nil
|
|
case settings.FieldGreeterchannel:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetGreeterchannel(v)
|
|
return nil
|
|
case settings.FieldGreetermode:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetGreetermode(v)
|
|
return nil
|
|
case settings.FieldAnnouncechannel:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetAnnouncechannel(v)
|
|
return nil
|
|
case settings.FieldLogger:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetLogger(v)
|
|
return nil
|
|
case settings.FieldSpamprotection:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetSpamprotection(v)
|
|
return nil
|
|
case settings.FieldLinkprotection:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetLinkprotection(v)
|
|
return nil
|
|
case settings.FieldWordfilter:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetWordfilter(v)
|
|
return nil
|
|
case settings.FieldGreetings:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetGreetings(v)
|
|
return nil
|
|
case settings.FieldApitoggle:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetApitoggle(v)
|
|
return nil
|
|
case settings.FieldModeration:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetModeration(v)
|
|
return nil
|
|
case settings.FieldAutomatedmoderation:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetAutomatedmoderation(v)
|
|
return nil
|
|
case settings.FieldTwitchannounce:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTwitchannounce(v)
|
|
return nil
|
|
case settings.FieldTwitterannounce:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTwitterannounce(v)
|
|
return nil
|
|
case settings.FieldMusic:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetMusic(v)
|
|
return nil
|
|
case settings.FieldStatspage:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetStatspage(v)
|
|
return nil
|
|
case settings.FieldStatsprivate:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetStatsprivate(v)
|
|
return nil
|
|
case settings.FieldStats:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetStats(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Settings field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *SettingsMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *SettingsMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *SettingsMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Settings numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *SettingsMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *SettingsMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *SettingsMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown Settings nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *SettingsMutation) ResetField(name string) error {
|
|
switch name {
|
|
case settings.FieldServerid:
|
|
m.ResetServerid()
|
|
return nil
|
|
case settings.FieldServername:
|
|
m.ResetServername()
|
|
return nil
|
|
case settings.FieldOwnerid:
|
|
m.ResetOwnerid()
|
|
return nil
|
|
case settings.FieldPermtoken:
|
|
m.ResetPermtoken()
|
|
return nil
|
|
case settings.FieldApitoken:
|
|
m.ResetApitoken()
|
|
return nil
|
|
case settings.FieldStatspagemode:
|
|
m.ResetStatspagemode()
|
|
return nil
|
|
case settings.FieldLoggerchannel:
|
|
m.ResetLoggerchannel()
|
|
return nil
|
|
case settings.FieldSpamchannel:
|
|
m.ResetSpamchannel()
|
|
return nil
|
|
case settings.FieldGreeterchannel:
|
|
m.ResetGreeterchannel()
|
|
return nil
|
|
case settings.FieldGreetermode:
|
|
m.ResetGreetermode()
|
|
return nil
|
|
case settings.FieldAnnouncechannel:
|
|
m.ResetAnnouncechannel()
|
|
return nil
|
|
case settings.FieldLogger:
|
|
m.ResetLogger()
|
|
return nil
|
|
case settings.FieldSpamprotection:
|
|
m.ResetSpamprotection()
|
|
return nil
|
|
case settings.FieldLinkprotection:
|
|
m.ResetLinkprotection()
|
|
return nil
|
|
case settings.FieldWordfilter:
|
|
m.ResetWordfilter()
|
|
return nil
|
|
case settings.FieldGreetings:
|
|
m.ResetGreetings()
|
|
return nil
|
|
case settings.FieldApitoggle:
|
|
m.ResetApitoggle()
|
|
return nil
|
|
case settings.FieldModeration:
|
|
m.ResetModeration()
|
|
return nil
|
|
case settings.FieldAutomatedmoderation:
|
|
m.ResetAutomatedmoderation()
|
|
return nil
|
|
case settings.FieldTwitchannounce:
|
|
m.ResetTwitchannounce()
|
|
return nil
|
|
case settings.FieldTwitterannounce:
|
|
m.ResetTwitterannounce()
|
|
return nil
|
|
case settings.FieldMusic:
|
|
m.ResetMusic()
|
|
return nil
|
|
case settings.FieldStatspage:
|
|
m.ResetStatspage()
|
|
return nil
|
|
case settings.FieldStatsprivate:
|
|
m.ResetStatsprivate()
|
|
return nil
|
|
case settings.FieldStats:
|
|
m.ResetStats()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Settings field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *SettingsMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *SettingsMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *SettingsMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *SettingsMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *SettingsMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *SettingsMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *SettingsMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Settings unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *SettingsMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Settings edge %s", name)
|
|
}
|
|
|
|
// SocialmediaMutation represents an operation that mutates the Socialmedia nodes in the graph.
|
|
type SocialmediaMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
serverid *string
|
|
_type *string
|
|
identificator *string
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Socialmedia, error)
|
|
predicates []predicate.Socialmedia
|
|
}
|
|
|
|
var _ ent.Mutation = (*SocialmediaMutation)(nil)
|
|
|
|
// socialmediaOption allows management of the mutation configuration using functional options.
|
|
type socialmediaOption func(*SocialmediaMutation)
|
|
|
|
// newSocialmediaMutation creates new mutation for the Socialmedia entity.
|
|
func newSocialmediaMutation(c config, op Op, opts ...socialmediaOption) *SocialmediaMutation {
|
|
m := &SocialmediaMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeSocialmedia,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withSocialmediaID sets the ID field of the mutation.
|
|
func withSocialmediaID(id int) socialmediaOption {
|
|
return func(m *SocialmediaMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Socialmedia
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Socialmedia, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Socialmedia.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withSocialmedia sets the old Socialmedia of the mutation.
|
|
func withSocialmedia(node *Socialmedia) socialmediaOption {
|
|
return func(m *SocialmediaMutation) {
|
|
m.oldValue = func(context.Context) (*Socialmedia, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m SocialmediaMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m SocialmediaMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// SetID sets the value of the id field. Note that this
|
|
// operation is only accepted on creation of Socialmedia entities.
|
|
func (m *SocialmediaMutation) SetID(id int) {
|
|
m.id = &id
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *SocialmediaMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *SocialmediaMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Socialmedia.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (m *SocialmediaMutation) SetServerid(s string) {
|
|
m.serverid = &s
|
|
}
|
|
|
|
// Serverid returns the value of the "serverid" field in the mutation.
|
|
func (m *SocialmediaMutation) Serverid() (r string, exists bool) {
|
|
v := m.serverid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldServerid returns the old "serverid" field's value of the Socialmedia entity.
|
|
// If the Socialmedia object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SocialmediaMutation) OldServerid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldServerid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldServerid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldServerid: %w", err)
|
|
}
|
|
return oldValue.Serverid, nil
|
|
}
|
|
|
|
// ResetServerid resets all changes to the "serverid" field.
|
|
func (m *SocialmediaMutation) ResetServerid() {
|
|
m.serverid = nil
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (m *SocialmediaMutation) SetType(s string) {
|
|
m._type = &s
|
|
}
|
|
|
|
// GetType returns the value of the "type" field in the mutation.
|
|
func (m *SocialmediaMutation) GetType() (r string, exists bool) {
|
|
v := m._type
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldType returns the old "type" field's value of the Socialmedia entity.
|
|
// If the Socialmedia object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SocialmediaMutation) OldType(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldType is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldType requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldType: %w", err)
|
|
}
|
|
return oldValue.Type, nil
|
|
}
|
|
|
|
// ResetType resets all changes to the "type" field.
|
|
func (m *SocialmediaMutation) ResetType() {
|
|
m._type = nil
|
|
}
|
|
|
|
// SetIdentificator sets the "identificator" field.
|
|
func (m *SocialmediaMutation) SetIdentificator(s string) {
|
|
m.identificator = &s
|
|
}
|
|
|
|
// Identificator returns the value of the "identificator" field in the mutation.
|
|
func (m *SocialmediaMutation) Identificator() (r string, exists bool) {
|
|
v := m.identificator
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldIdentificator returns the old "identificator" field's value of the Socialmedia entity.
|
|
// If the Socialmedia object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SocialmediaMutation) OldIdentificator(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldIdentificator is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldIdentificator requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldIdentificator: %w", err)
|
|
}
|
|
return oldValue.Identificator, nil
|
|
}
|
|
|
|
// ResetIdentificator resets all changes to the "identificator" field.
|
|
func (m *SocialmediaMutation) ResetIdentificator() {
|
|
m.identificator = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the SocialmediaMutation builder.
|
|
func (m *SocialmediaMutation) Where(ps ...predicate.Socialmedia) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *SocialmediaMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Socialmedia).
|
|
func (m *SocialmediaMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *SocialmediaMutation) Fields() []string {
|
|
fields := make([]string, 0, 3)
|
|
if m.serverid != nil {
|
|
fields = append(fields, socialmedia.FieldServerid)
|
|
}
|
|
if m._type != nil {
|
|
fields = append(fields, socialmedia.FieldType)
|
|
}
|
|
if m.identificator != nil {
|
|
fields = append(fields, socialmedia.FieldIdentificator)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *SocialmediaMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case socialmedia.FieldServerid:
|
|
return m.Serverid()
|
|
case socialmedia.FieldType:
|
|
return m.GetType()
|
|
case socialmedia.FieldIdentificator:
|
|
return m.Identificator()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *SocialmediaMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case socialmedia.FieldServerid:
|
|
return m.OldServerid(ctx)
|
|
case socialmedia.FieldType:
|
|
return m.OldType(ctx)
|
|
case socialmedia.FieldIdentificator:
|
|
return m.OldIdentificator(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Socialmedia field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *SocialmediaMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case socialmedia.FieldServerid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetServerid(v)
|
|
return nil
|
|
case socialmedia.FieldType:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetType(v)
|
|
return nil
|
|
case socialmedia.FieldIdentificator:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetIdentificator(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Socialmedia field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *SocialmediaMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *SocialmediaMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *SocialmediaMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Socialmedia numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *SocialmediaMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *SocialmediaMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *SocialmediaMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown Socialmedia nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *SocialmediaMutation) ResetField(name string) error {
|
|
switch name {
|
|
case socialmedia.FieldServerid:
|
|
m.ResetServerid()
|
|
return nil
|
|
case socialmedia.FieldType:
|
|
m.ResetType()
|
|
return nil
|
|
case socialmedia.FieldIdentificator:
|
|
m.ResetIdentificator()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Socialmedia field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *SocialmediaMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *SocialmediaMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *SocialmediaMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *SocialmediaMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *SocialmediaMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *SocialmediaMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *SocialmediaMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Socialmedia unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *SocialmediaMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Socialmedia edge %s", name)
|
|
}
|
|
|
|
// SupportMutation represents an operation that mutates the Support nodes in the graph.
|
|
type SupportMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
refid *string
|
|
serverid *string
|
|
creator *string
|
|
status *string
|
|
title *string
|
|
description *string
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Support, error)
|
|
predicates []predicate.Support
|
|
}
|
|
|
|
var _ ent.Mutation = (*SupportMutation)(nil)
|
|
|
|
// supportOption allows management of the mutation configuration using functional options.
|
|
type supportOption func(*SupportMutation)
|
|
|
|
// newSupportMutation creates new mutation for the Support entity.
|
|
func newSupportMutation(c config, op Op, opts ...supportOption) *SupportMutation {
|
|
m := &SupportMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeSupport,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withSupportID sets the ID field of the mutation.
|
|
func withSupportID(id int) supportOption {
|
|
return func(m *SupportMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Support
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Support, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Support.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withSupport sets the old Support of the mutation.
|
|
func withSupport(node *Support) supportOption {
|
|
return func(m *SupportMutation) {
|
|
m.oldValue = func(context.Context) (*Support, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m SupportMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m SupportMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// SetID sets the value of the id field. Note that this
|
|
// operation is only accepted on creation of Support entities.
|
|
func (m *SupportMutation) SetID(id int) {
|
|
m.id = &id
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *SupportMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *SupportMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Support.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetRefid sets the "refid" field.
|
|
func (m *SupportMutation) SetRefid(s string) {
|
|
m.refid = &s
|
|
}
|
|
|
|
// Refid returns the value of the "refid" field in the mutation.
|
|
func (m *SupportMutation) Refid() (r string, exists bool) {
|
|
v := m.refid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldRefid returns the old "refid" field's value of the Support entity.
|
|
// If the Support object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportMutation) OldRefid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldRefid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldRefid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldRefid: %w", err)
|
|
}
|
|
return oldValue.Refid, nil
|
|
}
|
|
|
|
// ResetRefid resets all changes to the "refid" field.
|
|
func (m *SupportMutation) ResetRefid() {
|
|
m.refid = nil
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (m *SupportMutation) SetServerid(s string) {
|
|
m.serverid = &s
|
|
}
|
|
|
|
// Serverid returns the value of the "serverid" field in the mutation.
|
|
func (m *SupportMutation) Serverid() (r string, exists bool) {
|
|
v := m.serverid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldServerid returns the old "serverid" field's value of the Support entity.
|
|
// If the Support object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportMutation) OldServerid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldServerid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldServerid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldServerid: %w", err)
|
|
}
|
|
return oldValue.Serverid, nil
|
|
}
|
|
|
|
// ResetServerid resets all changes to the "serverid" field.
|
|
func (m *SupportMutation) ResetServerid() {
|
|
m.serverid = nil
|
|
}
|
|
|
|
// SetCreator sets the "creator" field.
|
|
func (m *SupportMutation) SetCreator(s string) {
|
|
m.creator = &s
|
|
}
|
|
|
|
// Creator returns the value of the "creator" field in the mutation.
|
|
func (m *SupportMutation) Creator() (r string, exists bool) {
|
|
v := m.creator
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCreator returns the old "creator" field's value of the Support entity.
|
|
// If the Support object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportMutation) OldCreator(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldCreator is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldCreator requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldCreator: %w", err)
|
|
}
|
|
return oldValue.Creator, nil
|
|
}
|
|
|
|
// ResetCreator resets all changes to the "creator" field.
|
|
func (m *SupportMutation) ResetCreator() {
|
|
m.creator = nil
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (m *SupportMutation) SetStatus(s string) {
|
|
m.status = &s
|
|
}
|
|
|
|
// Status returns the value of the "status" field in the mutation.
|
|
func (m *SupportMutation) Status() (r string, exists bool) {
|
|
v := m.status
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldStatus returns the old "status" field's value of the Support entity.
|
|
// If the Support object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportMutation) OldStatus(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldStatus is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldStatus requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldStatus: %w", err)
|
|
}
|
|
return oldValue.Status, nil
|
|
}
|
|
|
|
// ResetStatus resets all changes to the "status" field.
|
|
func (m *SupportMutation) ResetStatus() {
|
|
m.status = nil
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (m *SupportMutation) SetTitle(s string) {
|
|
m.title = &s
|
|
}
|
|
|
|
// Title returns the value of the "title" field in the mutation.
|
|
func (m *SupportMutation) Title() (r string, exists bool) {
|
|
v := m.title
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTitle returns the old "title" field's value of the Support entity.
|
|
// If the Support object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportMutation) OldTitle(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTitle is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTitle requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTitle: %w", err)
|
|
}
|
|
return oldValue.Title, nil
|
|
}
|
|
|
|
// ResetTitle resets all changes to the "title" field.
|
|
func (m *SupportMutation) ResetTitle() {
|
|
m.title = nil
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (m *SupportMutation) SetDescription(s string) {
|
|
m.description = &s
|
|
}
|
|
|
|
// Description returns the value of the "description" field in the mutation.
|
|
func (m *SupportMutation) Description() (r string, exists bool) {
|
|
v := m.description
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldDescription returns the old "description" field's value of the Support entity.
|
|
// If the Support object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportMutation) OldDescription(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldDescription is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldDescription requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldDescription: %w", err)
|
|
}
|
|
return oldValue.Description, nil
|
|
}
|
|
|
|
// ResetDescription resets all changes to the "description" field.
|
|
func (m *SupportMutation) ResetDescription() {
|
|
m.description = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the SupportMutation builder.
|
|
func (m *SupportMutation) Where(ps ...predicate.Support) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *SupportMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Support).
|
|
func (m *SupportMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *SupportMutation) Fields() []string {
|
|
fields := make([]string, 0, 6)
|
|
if m.refid != nil {
|
|
fields = append(fields, support.FieldRefid)
|
|
}
|
|
if m.serverid != nil {
|
|
fields = append(fields, support.FieldServerid)
|
|
}
|
|
if m.creator != nil {
|
|
fields = append(fields, support.FieldCreator)
|
|
}
|
|
if m.status != nil {
|
|
fields = append(fields, support.FieldStatus)
|
|
}
|
|
if m.title != nil {
|
|
fields = append(fields, support.FieldTitle)
|
|
}
|
|
if m.description != nil {
|
|
fields = append(fields, support.FieldDescription)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *SupportMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case support.FieldRefid:
|
|
return m.Refid()
|
|
case support.FieldServerid:
|
|
return m.Serverid()
|
|
case support.FieldCreator:
|
|
return m.Creator()
|
|
case support.FieldStatus:
|
|
return m.Status()
|
|
case support.FieldTitle:
|
|
return m.Title()
|
|
case support.FieldDescription:
|
|
return m.Description()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *SupportMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case support.FieldRefid:
|
|
return m.OldRefid(ctx)
|
|
case support.FieldServerid:
|
|
return m.OldServerid(ctx)
|
|
case support.FieldCreator:
|
|
return m.OldCreator(ctx)
|
|
case support.FieldStatus:
|
|
return m.OldStatus(ctx)
|
|
case support.FieldTitle:
|
|
return m.OldTitle(ctx)
|
|
case support.FieldDescription:
|
|
return m.OldDescription(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Support field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *SupportMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case support.FieldRefid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetRefid(v)
|
|
return nil
|
|
case support.FieldServerid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetServerid(v)
|
|
return nil
|
|
case support.FieldCreator:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCreator(v)
|
|
return nil
|
|
case support.FieldStatus:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetStatus(v)
|
|
return nil
|
|
case support.FieldTitle:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTitle(v)
|
|
return nil
|
|
case support.FieldDescription:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetDescription(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Support field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *SupportMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *SupportMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *SupportMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Support numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *SupportMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *SupportMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *SupportMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown Support nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *SupportMutation) ResetField(name string) error {
|
|
switch name {
|
|
case support.FieldRefid:
|
|
m.ResetRefid()
|
|
return nil
|
|
case support.FieldServerid:
|
|
m.ResetServerid()
|
|
return nil
|
|
case support.FieldCreator:
|
|
m.ResetCreator()
|
|
return nil
|
|
case support.FieldStatus:
|
|
m.ResetStatus()
|
|
return nil
|
|
case support.FieldTitle:
|
|
m.ResetTitle()
|
|
return nil
|
|
case support.FieldDescription:
|
|
m.ResetDescription()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Support field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *SupportMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *SupportMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *SupportMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *SupportMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *SupportMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *SupportMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *SupportMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Support unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *SupportMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Support edge %s", name)
|
|
}
|
|
|
|
// SupportResponseMutation represents an operation that mutates the SupportResponse nodes in the graph.
|
|
type SupportResponseMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
refid *string
|
|
writer *string
|
|
message *string
|
|
_type *string
|
|
rtcchannel *string
|
|
isread *bool
|
|
created *time.Time
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*SupportResponse, error)
|
|
predicates []predicate.SupportResponse
|
|
}
|
|
|
|
var _ ent.Mutation = (*SupportResponseMutation)(nil)
|
|
|
|
// supportresponseOption allows management of the mutation configuration using functional options.
|
|
type supportresponseOption func(*SupportResponseMutation)
|
|
|
|
// newSupportResponseMutation creates new mutation for the SupportResponse entity.
|
|
func newSupportResponseMutation(c config, op Op, opts ...supportresponseOption) *SupportResponseMutation {
|
|
m := &SupportResponseMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeSupportResponse,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withSupportResponseID sets the ID field of the mutation.
|
|
func withSupportResponseID(id int) supportresponseOption {
|
|
return func(m *SupportResponseMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *SupportResponse
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*SupportResponse, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().SupportResponse.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withSupportResponse sets the old SupportResponse of the mutation.
|
|
func withSupportResponse(node *SupportResponse) supportresponseOption {
|
|
return func(m *SupportResponseMutation) {
|
|
m.oldValue = func(context.Context) (*SupportResponse, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m SupportResponseMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m SupportResponseMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// SetID sets the value of the id field. Note that this
|
|
// operation is only accepted on creation of SupportResponse entities.
|
|
func (m *SupportResponseMutation) SetID(id int) {
|
|
m.id = &id
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *SupportResponseMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *SupportResponseMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().SupportResponse.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetRefid sets the "refid" field.
|
|
func (m *SupportResponseMutation) SetRefid(s string) {
|
|
m.refid = &s
|
|
}
|
|
|
|
// Refid returns the value of the "refid" field in the mutation.
|
|
func (m *SupportResponseMutation) Refid() (r string, exists bool) {
|
|
v := m.refid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldRefid returns the old "refid" field's value of the SupportResponse entity.
|
|
// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportResponseMutation) OldRefid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldRefid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldRefid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldRefid: %w", err)
|
|
}
|
|
return oldValue.Refid, nil
|
|
}
|
|
|
|
// ResetRefid resets all changes to the "refid" field.
|
|
func (m *SupportResponseMutation) ResetRefid() {
|
|
m.refid = nil
|
|
}
|
|
|
|
// SetWriter sets the "writer" field.
|
|
func (m *SupportResponseMutation) SetWriter(s string) {
|
|
m.writer = &s
|
|
}
|
|
|
|
// Writer returns the value of the "writer" field in the mutation.
|
|
func (m *SupportResponseMutation) Writer() (r string, exists bool) {
|
|
v := m.writer
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldWriter returns the old "writer" field's value of the SupportResponse entity.
|
|
// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportResponseMutation) OldWriter(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldWriter is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldWriter requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldWriter: %w", err)
|
|
}
|
|
return oldValue.Writer, nil
|
|
}
|
|
|
|
// ResetWriter resets all changes to the "writer" field.
|
|
func (m *SupportResponseMutation) ResetWriter() {
|
|
m.writer = nil
|
|
}
|
|
|
|
// SetMessage sets the "message" field.
|
|
func (m *SupportResponseMutation) SetMessage(s string) {
|
|
m.message = &s
|
|
}
|
|
|
|
// Message returns the value of the "message" field in the mutation.
|
|
func (m *SupportResponseMutation) Message() (r string, exists bool) {
|
|
v := m.message
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldMessage returns the old "message" field's value of the SupportResponse entity.
|
|
// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportResponseMutation) OldMessage(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldMessage is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldMessage requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldMessage: %w", err)
|
|
}
|
|
return oldValue.Message, nil
|
|
}
|
|
|
|
// ResetMessage resets all changes to the "message" field.
|
|
func (m *SupportResponseMutation) ResetMessage() {
|
|
m.message = nil
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (m *SupportResponseMutation) SetType(s string) {
|
|
m._type = &s
|
|
}
|
|
|
|
// GetType returns the value of the "type" field in the mutation.
|
|
func (m *SupportResponseMutation) GetType() (r string, exists bool) {
|
|
v := m._type
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldType returns the old "type" field's value of the SupportResponse entity.
|
|
// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportResponseMutation) OldType(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldType is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldType requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldType: %w", err)
|
|
}
|
|
return oldValue.Type, nil
|
|
}
|
|
|
|
// ResetType resets all changes to the "type" field.
|
|
func (m *SupportResponseMutation) ResetType() {
|
|
m._type = nil
|
|
}
|
|
|
|
// SetRtcchannel sets the "rtcchannel" field.
|
|
func (m *SupportResponseMutation) SetRtcchannel(s string) {
|
|
m.rtcchannel = &s
|
|
}
|
|
|
|
// Rtcchannel returns the value of the "rtcchannel" field in the mutation.
|
|
func (m *SupportResponseMutation) Rtcchannel() (r string, exists bool) {
|
|
v := m.rtcchannel
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldRtcchannel returns the old "rtcchannel" field's value of the SupportResponse entity.
|
|
// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportResponseMutation) OldRtcchannel(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldRtcchannel is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldRtcchannel requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldRtcchannel: %w", err)
|
|
}
|
|
return oldValue.Rtcchannel, nil
|
|
}
|
|
|
|
// ResetRtcchannel resets all changes to the "rtcchannel" field.
|
|
func (m *SupportResponseMutation) ResetRtcchannel() {
|
|
m.rtcchannel = nil
|
|
}
|
|
|
|
// SetIsread sets the "isread" field.
|
|
func (m *SupportResponseMutation) SetIsread(b bool) {
|
|
m.isread = &b
|
|
}
|
|
|
|
// Isread returns the value of the "isread" field in the mutation.
|
|
func (m *SupportResponseMutation) Isread() (r bool, exists bool) {
|
|
v := m.isread
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldIsread returns the old "isread" field's value of the SupportResponse entity.
|
|
// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportResponseMutation) OldIsread(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldIsread is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldIsread requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldIsread: %w", err)
|
|
}
|
|
return oldValue.Isread, nil
|
|
}
|
|
|
|
// ResetIsread resets all changes to the "isread" field.
|
|
func (m *SupportResponseMutation) ResetIsread() {
|
|
m.isread = nil
|
|
}
|
|
|
|
// SetCreated sets the "created" field.
|
|
func (m *SupportResponseMutation) SetCreated(t time.Time) {
|
|
m.created = &t
|
|
}
|
|
|
|
// Created returns the value of the "created" field in the mutation.
|
|
func (m *SupportResponseMutation) Created() (r time.Time, exists bool) {
|
|
v := m.created
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCreated returns the old "created" field's value of the SupportResponse entity.
|
|
// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *SupportResponseMutation) OldCreated(ctx context.Context) (v time.Time, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldCreated is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldCreated requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldCreated: %w", err)
|
|
}
|
|
return oldValue.Created, nil
|
|
}
|
|
|
|
// ResetCreated resets all changes to the "created" field.
|
|
func (m *SupportResponseMutation) ResetCreated() {
|
|
m.created = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the SupportResponseMutation builder.
|
|
func (m *SupportResponseMutation) Where(ps ...predicate.SupportResponse) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *SupportResponseMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (SupportResponse).
|
|
func (m *SupportResponseMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *SupportResponseMutation) Fields() []string {
|
|
fields := make([]string, 0, 7)
|
|
if m.refid != nil {
|
|
fields = append(fields, supportresponse.FieldRefid)
|
|
}
|
|
if m.writer != nil {
|
|
fields = append(fields, supportresponse.FieldWriter)
|
|
}
|
|
if m.message != nil {
|
|
fields = append(fields, supportresponse.FieldMessage)
|
|
}
|
|
if m._type != nil {
|
|
fields = append(fields, supportresponse.FieldType)
|
|
}
|
|
if m.rtcchannel != nil {
|
|
fields = append(fields, supportresponse.FieldRtcchannel)
|
|
}
|
|
if m.isread != nil {
|
|
fields = append(fields, supportresponse.FieldIsread)
|
|
}
|
|
if m.created != nil {
|
|
fields = append(fields, supportresponse.FieldCreated)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *SupportResponseMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case supportresponse.FieldRefid:
|
|
return m.Refid()
|
|
case supportresponse.FieldWriter:
|
|
return m.Writer()
|
|
case supportresponse.FieldMessage:
|
|
return m.Message()
|
|
case supportresponse.FieldType:
|
|
return m.GetType()
|
|
case supportresponse.FieldRtcchannel:
|
|
return m.Rtcchannel()
|
|
case supportresponse.FieldIsread:
|
|
return m.Isread()
|
|
case supportresponse.FieldCreated:
|
|
return m.Created()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *SupportResponseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case supportresponse.FieldRefid:
|
|
return m.OldRefid(ctx)
|
|
case supportresponse.FieldWriter:
|
|
return m.OldWriter(ctx)
|
|
case supportresponse.FieldMessage:
|
|
return m.OldMessage(ctx)
|
|
case supportresponse.FieldType:
|
|
return m.OldType(ctx)
|
|
case supportresponse.FieldRtcchannel:
|
|
return m.OldRtcchannel(ctx)
|
|
case supportresponse.FieldIsread:
|
|
return m.OldIsread(ctx)
|
|
case supportresponse.FieldCreated:
|
|
return m.OldCreated(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown SupportResponse field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *SupportResponseMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case supportresponse.FieldRefid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetRefid(v)
|
|
return nil
|
|
case supportresponse.FieldWriter:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetWriter(v)
|
|
return nil
|
|
case supportresponse.FieldMessage:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetMessage(v)
|
|
return nil
|
|
case supportresponse.FieldType:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetType(v)
|
|
return nil
|
|
case supportresponse.FieldRtcchannel:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetRtcchannel(v)
|
|
return nil
|
|
case supportresponse.FieldIsread:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetIsread(v)
|
|
return nil
|
|
case supportresponse.FieldCreated:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCreated(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown SupportResponse field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *SupportResponseMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *SupportResponseMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *SupportResponseMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown SupportResponse numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *SupportResponseMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *SupportResponseMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *SupportResponseMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown SupportResponse nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *SupportResponseMutation) ResetField(name string) error {
|
|
switch name {
|
|
case supportresponse.FieldRefid:
|
|
m.ResetRefid()
|
|
return nil
|
|
case supportresponse.FieldWriter:
|
|
m.ResetWriter()
|
|
return nil
|
|
case supportresponse.FieldMessage:
|
|
m.ResetMessage()
|
|
return nil
|
|
case supportresponse.FieldType:
|
|
m.ResetType()
|
|
return nil
|
|
case supportresponse.FieldRtcchannel:
|
|
m.ResetRtcchannel()
|
|
return nil
|
|
case supportresponse.FieldIsread:
|
|
m.ResetIsread()
|
|
return nil
|
|
case supportresponse.FieldCreated:
|
|
m.ResetCreated()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown SupportResponse field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *SupportResponseMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *SupportResponseMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *SupportResponseMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *SupportResponseMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *SupportResponseMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *SupportResponseMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *SupportResponseMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown SupportResponse unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *SupportResponseMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown SupportResponse edge %s", name)
|
|
}
|
|
|
|
// UserMutation represents an operation that mutates the User nodes in the graph.
|
|
type UserMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
serverid *string
|
|
userid *string
|
|
username *string
|
|
xp *int
|
|
addxp *int
|
|
level *int
|
|
addlevel *int
|
|
msgs *int
|
|
addmsgs *int
|
|
created *time.Time
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*User, error)
|
|
predicates []predicate.User
|
|
}
|
|
|
|
var _ ent.Mutation = (*UserMutation)(nil)
|
|
|
|
// userOption allows management of the mutation configuration using functional options.
|
|
type userOption func(*UserMutation)
|
|
|
|
// newUserMutation creates new mutation for the User entity.
|
|
func newUserMutation(c config, op Op, opts ...userOption) *UserMutation {
|
|
m := &UserMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeUser,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withUserID sets the ID field of the mutation.
|
|
func withUserID(id int) userOption {
|
|
return func(m *UserMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *User
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*User, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().User.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withUser sets the old User of the mutation.
|
|
func withUser(node *User) userOption {
|
|
return func(m *UserMutation) {
|
|
m.oldValue = func(context.Context) (*User, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m UserMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m UserMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// SetID sets the value of the id field. Note that this
|
|
// operation is only accepted on creation of User entities.
|
|
func (m *UserMutation) SetID(id int) {
|
|
m.id = &id
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *UserMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *UserMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().User.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (m *UserMutation) SetServerid(s string) {
|
|
m.serverid = &s
|
|
}
|
|
|
|
// Serverid returns the value of the "serverid" field in the mutation.
|
|
func (m *UserMutation) Serverid() (r string, exists bool) {
|
|
v := m.serverid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldServerid returns the old "serverid" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldServerid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldServerid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldServerid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldServerid: %w", err)
|
|
}
|
|
return oldValue.Serverid, nil
|
|
}
|
|
|
|
// ResetServerid resets all changes to the "serverid" field.
|
|
func (m *UserMutation) ResetServerid() {
|
|
m.serverid = nil
|
|
}
|
|
|
|
// SetUserid sets the "userid" field.
|
|
func (m *UserMutation) SetUserid(s string) {
|
|
m.userid = &s
|
|
}
|
|
|
|
// Userid returns the value of the "userid" field in the mutation.
|
|
func (m *UserMutation) Userid() (r string, exists bool) {
|
|
v := m.userid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUserid returns the old "userid" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldUserid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldUserid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldUserid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldUserid: %w", err)
|
|
}
|
|
return oldValue.Userid, nil
|
|
}
|
|
|
|
// ResetUserid resets all changes to the "userid" field.
|
|
func (m *UserMutation) ResetUserid() {
|
|
m.userid = nil
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (m *UserMutation) SetUsername(s string) {
|
|
m.username = &s
|
|
}
|
|
|
|
// Username returns the value of the "username" field in the mutation.
|
|
func (m *UserMutation) Username() (r string, exists bool) {
|
|
v := m.username
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUsername returns the old "username" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldUsername is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldUsername requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldUsername: %w", err)
|
|
}
|
|
return oldValue.Username, nil
|
|
}
|
|
|
|
// ResetUsername resets all changes to the "username" field.
|
|
func (m *UserMutation) ResetUsername() {
|
|
m.username = nil
|
|
}
|
|
|
|
// SetXp sets the "xp" field.
|
|
func (m *UserMutation) SetXp(i int) {
|
|
m.xp = &i
|
|
m.addxp = nil
|
|
}
|
|
|
|
// Xp returns the value of the "xp" field in the mutation.
|
|
func (m *UserMutation) Xp() (r int, exists bool) {
|
|
v := m.xp
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldXp returns the old "xp" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldXp(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldXp is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldXp requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldXp: %w", err)
|
|
}
|
|
return oldValue.Xp, nil
|
|
}
|
|
|
|
// AddXp adds i to the "xp" field.
|
|
func (m *UserMutation) AddXp(i int) {
|
|
if m.addxp != nil {
|
|
*m.addxp += i
|
|
} else {
|
|
m.addxp = &i
|
|
}
|
|
}
|
|
|
|
// AddedXp returns the value that was added to the "xp" field in this mutation.
|
|
func (m *UserMutation) AddedXp() (r int, exists bool) {
|
|
v := m.addxp
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ResetXp resets all changes to the "xp" field.
|
|
func (m *UserMutation) ResetXp() {
|
|
m.xp = nil
|
|
m.addxp = nil
|
|
}
|
|
|
|
// SetLevel sets the "level" field.
|
|
func (m *UserMutation) SetLevel(i int) {
|
|
m.level = &i
|
|
m.addlevel = nil
|
|
}
|
|
|
|
// Level returns the value of the "level" field in the mutation.
|
|
func (m *UserMutation) Level() (r int, exists bool) {
|
|
v := m.level
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldLevel returns the old "level" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldLevel(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldLevel is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldLevel requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldLevel: %w", err)
|
|
}
|
|
return oldValue.Level, nil
|
|
}
|
|
|
|
// AddLevel adds i to the "level" field.
|
|
func (m *UserMutation) AddLevel(i int) {
|
|
if m.addlevel != nil {
|
|
*m.addlevel += i
|
|
} else {
|
|
m.addlevel = &i
|
|
}
|
|
}
|
|
|
|
// AddedLevel returns the value that was added to the "level" field in this mutation.
|
|
func (m *UserMutation) AddedLevel() (r int, exists bool) {
|
|
v := m.addlevel
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ResetLevel resets all changes to the "level" field.
|
|
func (m *UserMutation) ResetLevel() {
|
|
m.level = nil
|
|
m.addlevel = nil
|
|
}
|
|
|
|
// SetMsgs sets the "msgs" field.
|
|
func (m *UserMutation) SetMsgs(i int) {
|
|
m.msgs = &i
|
|
m.addmsgs = nil
|
|
}
|
|
|
|
// Msgs returns the value of the "msgs" field in the mutation.
|
|
func (m *UserMutation) Msgs() (r int, exists bool) {
|
|
v := m.msgs
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldMsgs returns the old "msgs" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldMsgs(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldMsgs is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldMsgs requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldMsgs: %w", err)
|
|
}
|
|
return oldValue.Msgs, nil
|
|
}
|
|
|
|
// AddMsgs adds i to the "msgs" field.
|
|
func (m *UserMutation) AddMsgs(i int) {
|
|
if m.addmsgs != nil {
|
|
*m.addmsgs += i
|
|
} else {
|
|
m.addmsgs = &i
|
|
}
|
|
}
|
|
|
|
// AddedMsgs returns the value that was added to the "msgs" field in this mutation.
|
|
func (m *UserMutation) AddedMsgs() (r int, exists bool) {
|
|
v := m.addmsgs
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ResetMsgs resets all changes to the "msgs" field.
|
|
func (m *UserMutation) ResetMsgs() {
|
|
m.msgs = nil
|
|
m.addmsgs = nil
|
|
}
|
|
|
|
// SetCreated sets the "created" field.
|
|
func (m *UserMutation) SetCreated(t time.Time) {
|
|
m.created = &t
|
|
}
|
|
|
|
// Created returns the value of the "created" field in the mutation.
|
|
func (m *UserMutation) Created() (r time.Time, exists bool) {
|
|
v := m.created
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCreated returns the old "created" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldCreated(ctx context.Context) (v time.Time, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldCreated is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldCreated requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldCreated: %w", err)
|
|
}
|
|
return oldValue.Created, nil
|
|
}
|
|
|
|
// ResetCreated resets all changes to the "created" field.
|
|
func (m *UserMutation) ResetCreated() {
|
|
m.created = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the UserMutation builder.
|
|
func (m *UserMutation) Where(ps ...predicate.User) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *UserMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (User).
|
|
func (m *UserMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *UserMutation) Fields() []string {
|
|
fields := make([]string, 0, 7)
|
|
if m.serverid != nil {
|
|
fields = append(fields, user.FieldServerid)
|
|
}
|
|
if m.userid != nil {
|
|
fields = append(fields, user.FieldUserid)
|
|
}
|
|
if m.username != nil {
|
|
fields = append(fields, user.FieldUsername)
|
|
}
|
|
if m.xp != nil {
|
|
fields = append(fields, user.FieldXp)
|
|
}
|
|
if m.level != nil {
|
|
fields = append(fields, user.FieldLevel)
|
|
}
|
|
if m.msgs != nil {
|
|
fields = append(fields, user.FieldMsgs)
|
|
}
|
|
if m.created != nil {
|
|
fields = append(fields, user.FieldCreated)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *UserMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case user.FieldServerid:
|
|
return m.Serverid()
|
|
case user.FieldUserid:
|
|
return m.Userid()
|
|
case user.FieldUsername:
|
|
return m.Username()
|
|
case user.FieldXp:
|
|
return m.Xp()
|
|
case user.FieldLevel:
|
|
return m.Level()
|
|
case user.FieldMsgs:
|
|
return m.Msgs()
|
|
case user.FieldCreated:
|
|
return m.Created()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case user.FieldServerid:
|
|
return m.OldServerid(ctx)
|
|
case user.FieldUserid:
|
|
return m.OldUserid(ctx)
|
|
case user.FieldUsername:
|
|
return m.OldUsername(ctx)
|
|
case user.FieldXp:
|
|
return m.OldXp(ctx)
|
|
case user.FieldLevel:
|
|
return m.OldLevel(ctx)
|
|
case user.FieldMsgs:
|
|
return m.OldMsgs(ctx)
|
|
case user.FieldCreated:
|
|
return m.OldCreated(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown User field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *UserMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case user.FieldServerid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetServerid(v)
|
|
return nil
|
|
case user.FieldUserid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUserid(v)
|
|
return nil
|
|
case user.FieldUsername:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUsername(v)
|
|
return nil
|
|
case user.FieldXp:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetXp(v)
|
|
return nil
|
|
case user.FieldLevel:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetLevel(v)
|
|
return nil
|
|
case user.FieldMsgs:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetMsgs(v)
|
|
return nil
|
|
case user.FieldCreated:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCreated(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown User field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *UserMutation) AddedFields() []string {
|
|
var fields []string
|
|
if m.addxp != nil {
|
|
fields = append(fields, user.FieldXp)
|
|
}
|
|
if m.addlevel != nil {
|
|
fields = append(fields, user.FieldLevel)
|
|
}
|
|
if m.addmsgs != nil {
|
|
fields = append(fields, user.FieldMsgs)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *UserMutation) AddedField(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case user.FieldXp:
|
|
return m.AddedXp()
|
|
case user.FieldLevel:
|
|
return m.AddedLevel()
|
|
case user.FieldMsgs:
|
|
return m.AddedMsgs()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *UserMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
case user.FieldXp:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddXp(v)
|
|
return nil
|
|
case user.FieldLevel:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddLevel(v)
|
|
return nil
|
|
case user.FieldMsgs:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddMsgs(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown User numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *UserMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *UserMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *UserMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown User nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *UserMutation) ResetField(name string) error {
|
|
switch name {
|
|
case user.FieldServerid:
|
|
m.ResetServerid()
|
|
return nil
|
|
case user.FieldUserid:
|
|
m.ResetUserid()
|
|
return nil
|
|
case user.FieldUsername:
|
|
m.ResetUsername()
|
|
return nil
|
|
case user.FieldXp:
|
|
m.ResetXp()
|
|
return nil
|
|
case user.FieldLevel:
|
|
m.ResetLevel()
|
|
return nil
|
|
case user.FieldMsgs:
|
|
m.ResetMsgs()
|
|
return nil
|
|
case user.FieldCreated:
|
|
m.ResetCreated()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown User field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *UserMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *UserMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *UserMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *UserMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *UserMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *UserMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *UserMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown User unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *UserMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown User edge %s", name)
|
|
}
|
|
|
|
// WarnsMutation represents an operation that mutates the Warns nodes in the graph.
|
|
type WarnsMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
emitter *string
|
|
serverid *string
|
|
target *string
|
|
_type *string
|
|
duration *string
|
|
reason *string
|
|
refid *string
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Warns, error)
|
|
predicates []predicate.Warns
|
|
}
|
|
|
|
var _ ent.Mutation = (*WarnsMutation)(nil)
|
|
|
|
// warnsOption allows management of the mutation configuration using functional options.
|
|
type warnsOption func(*WarnsMutation)
|
|
|
|
// newWarnsMutation creates new mutation for the Warns entity.
|
|
func newWarnsMutation(c config, op Op, opts ...warnsOption) *WarnsMutation {
|
|
m := &WarnsMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeWarns,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withWarnsID sets the ID field of the mutation.
|
|
func withWarnsID(id int) warnsOption {
|
|
return func(m *WarnsMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Warns
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Warns, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Warns.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withWarns sets the old Warns of the mutation.
|
|
func withWarns(node *Warns) warnsOption {
|
|
return func(m *WarnsMutation) {
|
|
m.oldValue = func(context.Context) (*Warns, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m WarnsMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m WarnsMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// SetID sets the value of the id field. Note that this
|
|
// operation is only accepted on creation of Warns entities.
|
|
func (m *WarnsMutation) SetID(id int) {
|
|
m.id = &id
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *WarnsMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *WarnsMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Warns.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetEmitter sets the "emitter" field.
|
|
func (m *WarnsMutation) SetEmitter(s string) {
|
|
m.emitter = &s
|
|
}
|
|
|
|
// Emitter returns the value of the "emitter" field in the mutation.
|
|
func (m *WarnsMutation) Emitter() (r string, exists bool) {
|
|
v := m.emitter
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldEmitter returns the old "emitter" field's value of the Warns entity.
|
|
// If the Warns object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *WarnsMutation) OldEmitter(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldEmitter is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldEmitter requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldEmitter: %w", err)
|
|
}
|
|
return oldValue.Emitter, nil
|
|
}
|
|
|
|
// ResetEmitter resets all changes to the "emitter" field.
|
|
func (m *WarnsMutation) ResetEmitter() {
|
|
m.emitter = nil
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (m *WarnsMutation) SetServerid(s string) {
|
|
m.serverid = &s
|
|
}
|
|
|
|
// Serverid returns the value of the "serverid" field in the mutation.
|
|
func (m *WarnsMutation) Serverid() (r string, exists bool) {
|
|
v := m.serverid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldServerid returns the old "serverid" field's value of the Warns entity.
|
|
// If the Warns object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *WarnsMutation) OldServerid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldServerid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldServerid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldServerid: %w", err)
|
|
}
|
|
return oldValue.Serverid, nil
|
|
}
|
|
|
|
// ResetServerid resets all changes to the "serverid" field.
|
|
func (m *WarnsMutation) ResetServerid() {
|
|
m.serverid = nil
|
|
}
|
|
|
|
// SetTarget sets the "target" field.
|
|
func (m *WarnsMutation) SetTarget(s string) {
|
|
m.target = &s
|
|
}
|
|
|
|
// Target returns the value of the "target" field in the mutation.
|
|
func (m *WarnsMutation) Target() (r string, exists bool) {
|
|
v := m.target
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTarget returns the old "target" field's value of the Warns entity.
|
|
// If the Warns object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *WarnsMutation) OldTarget(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTarget is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTarget requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTarget: %w", err)
|
|
}
|
|
return oldValue.Target, nil
|
|
}
|
|
|
|
// ResetTarget resets all changes to the "target" field.
|
|
func (m *WarnsMutation) ResetTarget() {
|
|
m.target = nil
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (m *WarnsMutation) SetType(s string) {
|
|
m._type = &s
|
|
}
|
|
|
|
// GetType returns the value of the "type" field in the mutation.
|
|
func (m *WarnsMutation) GetType() (r string, exists bool) {
|
|
v := m._type
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldType returns the old "type" field's value of the Warns entity.
|
|
// If the Warns object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *WarnsMutation) OldType(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldType is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldType requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldType: %w", err)
|
|
}
|
|
return oldValue.Type, nil
|
|
}
|
|
|
|
// ResetType resets all changes to the "type" field.
|
|
func (m *WarnsMutation) ResetType() {
|
|
m._type = nil
|
|
}
|
|
|
|
// SetDuration sets the "duration" field.
|
|
func (m *WarnsMutation) SetDuration(s string) {
|
|
m.duration = &s
|
|
}
|
|
|
|
// Duration returns the value of the "duration" field in the mutation.
|
|
func (m *WarnsMutation) Duration() (r string, exists bool) {
|
|
v := m.duration
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldDuration returns the old "duration" field's value of the Warns entity.
|
|
// If the Warns object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *WarnsMutation) OldDuration(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldDuration is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldDuration requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldDuration: %w", err)
|
|
}
|
|
return oldValue.Duration, nil
|
|
}
|
|
|
|
// ResetDuration resets all changes to the "duration" field.
|
|
func (m *WarnsMutation) ResetDuration() {
|
|
m.duration = nil
|
|
}
|
|
|
|
// SetReason sets the "reason" field.
|
|
func (m *WarnsMutation) SetReason(s string) {
|
|
m.reason = &s
|
|
}
|
|
|
|
// Reason returns the value of the "reason" field in the mutation.
|
|
func (m *WarnsMutation) Reason() (r string, exists bool) {
|
|
v := m.reason
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldReason returns the old "reason" field's value of the Warns entity.
|
|
// If the Warns object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *WarnsMutation) OldReason(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldReason is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldReason requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldReason: %w", err)
|
|
}
|
|
return oldValue.Reason, nil
|
|
}
|
|
|
|
// ResetReason resets all changes to the "reason" field.
|
|
func (m *WarnsMutation) ResetReason() {
|
|
m.reason = nil
|
|
}
|
|
|
|
// SetRefid sets the "refid" field.
|
|
func (m *WarnsMutation) SetRefid(s string) {
|
|
m.refid = &s
|
|
}
|
|
|
|
// Refid returns the value of the "refid" field in the mutation.
|
|
func (m *WarnsMutation) Refid() (r string, exists bool) {
|
|
v := m.refid
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldRefid returns the old "refid" field's value of the Warns entity.
|
|
// If the Warns object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *WarnsMutation) OldRefid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldRefid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldRefid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldRefid: %w", err)
|
|
}
|
|
return oldValue.Refid, nil
|
|
}
|
|
|
|
// ResetRefid resets all changes to the "refid" field.
|
|
func (m *WarnsMutation) ResetRefid() {
|
|
m.refid = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the WarnsMutation builder.
|
|
func (m *WarnsMutation) Where(ps ...predicate.Warns) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *WarnsMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Warns).
|
|
func (m *WarnsMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *WarnsMutation) Fields() []string {
|
|
fields := make([]string, 0, 7)
|
|
if m.emitter != nil {
|
|
fields = append(fields, warns.FieldEmitter)
|
|
}
|
|
if m.serverid != nil {
|
|
fields = append(fields, warns.FieldServerid)
|
|
}
|
|
if m.target != nil {
|
|
fields = append(fields, warns.FieldTarget)
|
|
}
|
|
if m._type != nil {
|
|
fields = append(fields, warns.FieldType)
|
|
}
|
|
if m.duration != nil {
|
|
fields = append(fields, warns.FieldDuration)
|
|
}
|
|
if m.reason != nil {
|
|
fields = append(fields, warns.FieldReason)
|
|
}
|
|
if m.refid != nil {
|
|
fields = append(fields, warns.FieldRefid)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *WarnsMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case warns.FieldEmitter:
|
|
return m.Emitter()
|
|
case warns.FieldServerid:
|
|
return m.Serverid()
|
|
case warns.FieldTarget:
|
|
return m.Target()
|
|
case warns.FieldType:
|
|
return m.GetType()
|
|
case warns.FieldDuration:
|
|
return m.Duration()
|
|
case warns.FieldReason:
|
|
return m.Reason()
|
|
case warns.FieldRefid:
|
|
return m.Refid()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *WarnsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case warns.FieldEmitter:
|
|
return m.OldEmitter(ctx)
|
|
case warns.FieldServerid:
|
|
return m.OldServerid(ctx)
|
|
case warns.FieldTarget:
|
|
return m.OldTarget(ctx)
|
|
case warns.FieldType:
|
|
return m.OldType(ctx)
|
|
case warns.FieldDuration:
|
|
return m.OldDuration(ctx)
|
|
case warns.FieldReason:
|
|
return m.OldReason(ctx)
|
|
case warns.FieldRefid:
|
|
return m.OldRefid(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Warns field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *WarnsMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case warns.FieldEmitter:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetEmitter(v)
|
|
return nil
|
|
case warns.FieldServerid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetServerid(v)
|
|
return nil
|
|
case warns.FieldTarget:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTarget(v)
|
|
return nil
|
|
case warns.FieldType:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetType(v)
|
|
return nil
|
|
case warns.FieldDuration:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetDuration(v)
|
|
return nil
|
|
case warns.FieldReason:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetReason(v)
|
|
return nil
|
|
case warns.FieldRefid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetRefid(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Warns field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *WarnsMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *WarnsMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *WarnsMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Warns numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *WarnsMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *WarnsMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *WarnsMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown Warns nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *WarnsMutation) ResetField(name string) error {
|
|
switch name {
|
|
case warns.FieldEmitter:
|
|
m.ResetEmitter()
|
|
return nil
|
|
case warns.FieldServerid:
|
|
m.ResetServerid()
|
|
return nil
|
|
case warns.FieldTarget:
|
|
m.ResetTarget()
|
|
return nil
|
|
case warns.FieldType:
|
|
m.ResetType()
|
|
return nil
|
|
case warns.FieldDuration:
|
|
m.ResetDuration()
|
|
return nil
|
|
case warns.FieldReason:
|
|
m.ResetReason()
|
|
return nil
|
|
case warns.FieldRefid:
|
|
m.ResetRefid()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Warns field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *WarnsMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *WarnsMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *WarnsMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *WarnsMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *WarnsMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *WarnsMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *WarnsMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Warns unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *WarnsMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Warns edge %s", name)
|
|
}
|