1120 lines
31 KiB
Go
1120 lines
31 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/predicate"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/settings"
|
|
)
|
|
|
|
// SettingsUpdate is the builder for updating Settings entities.
|
|
type SettingsUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *SettingsMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the SettingsUpdate builder.
|
|
func (su *SettingsUpdate) Where(ps ...predicate.Settings) *SettingsUpdate {
|
|
su.mutation.Where(ps...)
|
|
return su
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (su *SettingsUpdate) SetServerid(s string) *SettingsUpdate {
|
|
su.mutation.SetServerid(s)
|
|
return su
|
|
}
|
|
|
|
// SetServername sets the "servername" field.
|
|
func (su *SettingsUpdate) SetServername(s string) *SettingsUpdate {
|
|
su.mutation.SetServername(s)
|
|
return su
|
|
}
|
|
|
|
// SetOwnerid sets the "ownerid" field.
|
|
func (su *SettingsUpdate) SetOwnerid(s string) *SettingsUpdate {
|
|
su.mutation.SetOwnerid(s)
|
|
return su
|
|
}
|
|
|
|
// SetPermtoken sets the "permtoken" field.
|
|
func (su *SettingsUpdate) SetPermtoken(s string) *SettingsUpdate {
|
|
su.mutation.SetPermtoken(s)
|
|
return su
|
|
}
|
|
|
|
// SetApitoken sets the "apitoken" field.
|
|
func (su *SettingsUpdate) SetApitoken(s string) *SettingsUpdate {
|
|
su.mutation.SetApitoken(s)
|
|
return su
|
|
}
|
|
|
|
// SetStatspagemode sets the "statspagemode" field.
|
|
func (su *SettingsUpdate) SetStatspagemode(s string) *SettingsUpdate {
|
|
su.mutation.SetStatspagemode(s)
|
|
return su
|
|
}
|
|
|
|
// SetLoggerchannel sets the "loggerchannel" field.
|
|
func (su *SettingsUpdate) SetLoggerchannel(s string) *SettingsUpdate {
|
|
su.mutation.SetLoggerchannel(s)
|
|
return su
|
|
}
|
|
|
|
// SetSpamchannel sets the "spamchannel" field.
|
|
func (su *SettingsUpdate) SetSpamchannel(s string) *SettingsUpdate {
|
|
su.mutation.SetSpamchannel(s)
|
|
return su
|
|
}
|
|
|
|
// SetGreeterchannel sets the "greeterchannel" field.
|
|
func (su *SettingsUpdate) SetGreeterchannel(s string) *SettingsUpdate {
|
|
su.mutation.SetGreeterchannel(s)
|
|
return su
|
|
}
|
|
|
|
// SetGreetermode sets the "greetermode" field.
|
|
func (su *SettingsUpdate) SetGreetermode(s string) *SettingsUpdate {
|
|
su.mutation.SetGreetermode(s)
|
|
return su
|
|
}
|
|
|
|
// SetAnnouncechannel sets the "announcechannel" field.
|
|
func (su *SettingsUpdate) SetAnnouncechannel(s string) *SettingsUpdate {
|
|
su.mutation.SetAnnouncechannel(s)
|
|
return su
|
|
}
|
|
|
|
// SetLogger sets the "logger" field.
|
|
func (su *SettingsUpdate) SetLogger(b bool) *SettingsUpdate {
|
|
su.mutation.SetLogger(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableLogger sets the "logger" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableLogger(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetLogger(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetSpamprotection sets the "spamprotection" field.
|
|
func (su *SettingsUpdate) SetSpamprotection(b bool) *SettingsUpdate {
|
|
su.mutation.SetSpamprotection(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableSpamprotection sets the "spamprotection" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableSpamprotection(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetSpamprotection(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetLinkprotection sets the "linkprotection" field.
|
|
func (su *SettingsUpdate) SetLinkprotection(b bool) *SettingsUpdate {
|
|
su.mutation.SetLinkprotection(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableLinkprotection sets the "linkprotection" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableLinkprotection(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetLinkprotection(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetWordfilter sets the "wordfilter" field.
|
|
func (su *SettingsUpdate) SetWordfilter(b bool) *SettingsUpdate {
|
|
su.mutation.SetWordfilter(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableWordfilter sets the "wordfilter" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableWordfilter(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetWordfilter(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetGreetings sets the "greetings" field.
|
|
func (su *SettingsUpdate) SetGreetings(b bool) *SettingsUpdate {
|
|
su.mutation.SetGreetings(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableGreetings sets the "greetings" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableGreetings(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetGreetings(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetApitoggle sets the "apitoggle" field.
|
|
func (su *SettingsUpdate) SetApitoggle(b bool) *SettingsUpdate {
|
|
su.mutation.SetApitoggle(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableApitoggle sets the "apitoggle" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableApitoggle(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetApitoggle(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetModeration sets the "moderation" field.
|
|
func (su *SettingsUpdate) SetModeration(b bool) *SettingsUpdate {
|
|
su.mutation.SetModeration(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableModeration sets the "moderation" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableModeration(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetModeration(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetAutomatedmoderation sets the "automatedmoderation" field.
|
|
func (su *SettingsUpdate) SetAutomatedmoderation(b bool) *SettingsUpdate {
|
|
su.mutation.SetAutomatedmoderation(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableAutomatedmoderation sets the "automatedmoderation" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableAutomatedmoderation(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetAutomatedmoderation(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetTwitchannounce sets the "twitchannounce" field.
|
|
func (su *SettingsUpdate) SetTwitchannounce(b bool) *SettingsUpdate {
|
|
su.mutation.SetTwitchannounce(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableTwitchannounce sets the "twitchannounce" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableTwitchannounce(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetTwitchannounce(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetTwitterannounce sets the "twitterannounce" field.
|
|
func (su *SettingsUpdate) SetTwitterannounce(b bool) *SettingsUpdate {
|
|
su.mutation.SetTwitterannounce(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableTwitterannounce sets the "twitterannounce" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableTwitterannounce(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetTwitterannounce(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetMusic sets the "music" field.
|
|
func (su *SettingsUpdate) SetMusic(b bool) *SettingsUpdate {
|
|
su.mutation.SetMusic(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableMusic sets the "music" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableMusic(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetMusic(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetStatspage sets the "statspage" field.
|
|
func (su *SettingsUpdate) SetStatspage(b bool) *SettingsUpdate {
|
|
su.mutation.SetStatspage(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableStatspage sets the "statspage" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableStatspage(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetStatspage(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetStatsprivate sets the "statsprivate" field.
|
|
func (su *SettingsUpdate) SetStatsprivate(b bool) *SettingsUpdate {
|
|
su.mutation.SetStatsprivate(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableStatsprivate sets the "statsprivate" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableStatsprivate(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetStatsprivate(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetStats sets the "stats" field.
|
|
func (su *SettingsUpdate) SetStats(b bool) *SettingsUpdate {
|
|
su.mutation.SetStats(b)
|
|
return su
|
|
}
|
|
|
|
// SetNillableStats sets the "stats" field if the given value is not nil.
|
|
func (su *SettingsUpdate) SetNillableStats(b *bool) *SettingsUpdate {
|
|
if b != nil {
|
|
su.SetStats(*b)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// Mutation returns the SettingsMutation object of the builder.
|
|
func (su *SettingsUpdate) Mutation() *SettingsMutation {
|
|
return su.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (su *SettingsUpdate) Save(ctx context.Context) (int, error) {
|
|
var (
|
|
err error
|
|
affected int
|
|
)
|
|
if len(su.hooks) == 0 {
|
|
affected, err = su.sqlSave(ctx)
|
|
} else {
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*SettingsMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
su.mutation = mutation
|
|
affected, err = su.sqlSave(ctx)
|
|
mutation.done = true
|
|
return affected, err
|
|
})
|
|
for i := len(su.hooks) - 1; i >= 0; i-- {
|
|
if su.hooks[i] == nil {
|
|
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
|
}
|
|
mut = su.hooks[i](mut)
|
|
}
|
|
if _, err := mut.Mutate(ctx, su.mutation); err != nil {
|
|
return 0, err
|
|
}
|
|
}
|
|
return affected, err
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (su *SettingsUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := su.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (su *SettingsUpdate) Exec(ctx context.Context) error {
|
|
_, err := su.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (su *SettingsUpdate) ExecX(ctx context.Context) {
|
|
if err := su.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (su *SettingsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
_spec := &sqlgraph.UpdateSpec{
|
|
Node: &sqlgraph.NodeSpec{
|
|
Table: settings.Table,
|
|
Columns: settings.Columns,
|
|
ID: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: settings.FieldID,
|
|
},
|
|
},
|
|
}
|
|
if ps := su.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := su.mutation.Serverid(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldServerid,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Servername(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldServername,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Ownerid(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldOwnerid,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Permtoken(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldPermtoken,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Apitoken(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldApitoken,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Statspagemode(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldStatspagemode,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Loggerchannel(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldLoggerchannel,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Spamchannel(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldSpamchannel,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Greeterchannel(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldGreeterchannel,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Greetermode(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldGreetermode,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Announcechannel(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldAnnouncechannel,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Logger(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldLogger,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Spamprotection(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldSpamprotection,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Linkprotection(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldLinkprotection,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Wordfilter(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldWordfilter,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Greetings(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldGreetings,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Apitoggle(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldApitoggle,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Moderation(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldModeration,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Automatedmoderation(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldAutomatedmoderation,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Twitchannounce(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldTwitchannounce,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Twitterannounce(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldTwitterannounce,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Music(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldMusic,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Statspage(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldStatspage,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Statsprivate(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldStatsprivate,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Stats(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldStats,
|
|
})
|
|
}
|
|
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{settings.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
return n, nil
|
|
}
|
|
|
|
// SettingsUpdateOne is the builder for updating a single Settings entity.
|
|
type SettingsUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *SettingsMutation
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (suo *SettingsUpdateOne) SetServerid(s string) *SettingsUpdateOne {
|
|
suo.mutation.SetServerid(s)
|
|
return suo
|
|
}
|
|
|
|
// SetServername sets the "servername" field.
|
|
func (suo *SettingsUpdateOne) SetServername(s string) *SettingsUpdateOne {
|
|
suo.mutation.SetServername(s)
|
|
return suo
|
|
}
|
|
|
|
// SetOwnerid sets the "ownerid" field.
|
|
func (suo *SettingsUpdateOne) SetOwnerid(s string) *SettingsUpdateOne {
|
|
suo.mutation.SetOwnerid(s)
|
|
return suo
|
|
}
|
|
|
|
// SetPermtoken sets the "permtoken" field.
|
|
func (suo *SettingsUpdateOne) SetPermtoken(s string) *SettingsUpdateOne {
|
|
suo.mutation.SetPermtoken(s)
|
|
return suo
|
|
}
|
|
|
|
// SetApitoken sets the "apitoken" field.
|
|
func (suo *SettingsUpdateOne) SetApitoken(s string) *SettingsUpdateOne {
|
|
suo.mutation.SetApitoken(s)
|
|
return suo
|
|
}
|
|
|
|
// SetStatspagemode sets the "statspagemode" field.
|
|
func (suo *SettingsUpdateOne) SetStatspagemode(s string) *SettingsUpdateOne {
|
|
suo.mutation.SetStatspagemode(s)
|
|
return suo
|
|
}
|
|
|
|
// SetLoggerchannel sets the "loggerchannel" field.
|
|
func (suo *SettingsUpdateOne) SetLoggerchannel(s string) *SettingsUpdateOne {
|
|
suo.mutation.SetLoggerchannel(s)
|
|
return suo
|
|
}
|
|
|
|
// SetSpamchannel sets the "spamchannel" field.
|
|
func (suo *SettingsUpdateOne) SetSpamchannel(s string) *SettingsUpdateOne {
|
|
suo.mutation.SetSpamchannel(s)
|
|
return suo
|
|
}
|
|
|
|
// SetGreeterchannel sets the "greeterchannel" field.
|
|
func (suo *SettingsUpdateOne) SetGreeterchannel(s string) *SettingsUpdateOne {
|
|
suo.mutation.SetGreeterchannel(s)
|
|
return suo
|
|
}
|
|
|
|
// SetGreetermode sets the "greetermode" field.
|
|
func (suo *SettingsUpdateOne) SetGreetermode(s string) *SettingsUpdateOne {
|
|
suo.mutation.SetGreetermode(s)
|
|
return suo
|
|
}
|
|
|
|
// SetAnnouncechannel sets the "announcechannel" field.
|
|
func (suo *SettingsUpdateOne) SetAnnouncechannel(s string) *SettingsUpdateOne {
|
|
suo.mutation.SetAnnouncechannel(s)
|
|
return suo
|
|
}
|
|
|
|
// SetLogger sets the "logger" field.
|
|
func (suo *SettingsUpdateOne) SetLogger(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetLogger(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableLogger sets the "logger" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableLogger(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetLogger(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetSpamprotection sets the "spamprotection" field.
|
|
func (suo *SettingsUpdateOne) SetSpamprotection(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetSpamprotection(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableSpamprotection sets the "spamprotection" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableSpamprotection(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetSpamprotection(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetLinkprotection sets the "linkprotection" field.
|
|
func (suo *SettingsUpdateOne) SetLinkprotection(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetLinkprotection(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableLinkprotection sets the "linkprotection" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableLinkprotection(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetLinkprotection(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetWordfilter sets the "wordfilter" field.
|
|
func (suo *SettingsUpdateOne) SetWordfilter(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetWordfilter(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableWordfilter sets the "wordfilter" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableWordfilter(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetWordfilter(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetGreetings sets the "greetings" field.
|
|
func (suo *SettingsUpdateOne) SetGreetings(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetGreetings(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableGreetings sets the "greetings" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableGreetings(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetGreetings(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetApitoggle sets the "apitoggle" field.
|
|
func (suo *SettingsUpdateOne) SetApitoggle(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetApitoggle(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableApitoggle sets the "apitoggle" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableApitoggle(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetApitoggle(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetModeration sets the "moderation" field.
|
|
func (suo *SettingsUpdateOne) SetModeration(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetModeration(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableModeration sets the "moderation" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableModeration(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetModeration(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetAutomatedmoderation sets the "automatedmoderation" field.
|
|
func (suo *SettingsUpdateOne) SetAutomatedmoderation(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetAutomatedmoderation(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableAutomatedmoderation sets the "automatedmoderation" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableAutomatedmoderation(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetAutomatedmoderation(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetTwitchannounce sets the "twitchannounce" field.
|
|
func (suo *SettingsUpdateOne) SetTwitchannounce(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetTwitchannounce(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableTwitchannounce sets the "twitchannounce" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableTwitchannounce(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetTwitchannounce(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetTwitterannounce sets the "twitterannounce" field.
|
|
func (suo *SettingsUpdateOne) SetTwitterannounce(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetTwitterannounce(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableTwitterannounce sets the "twitterannounce" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableTwitterannounce(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetTwitterannounce(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetMusic sets the "music" field.
|
|
func (suo *SettingsUpdateOne) SetMusic(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetMusic(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableMusic sets the "music" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableMusic(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetMusic(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetStatspage sets the "statspage" field.
|
|
func (suo *SettingsUpdateOne) SetStatspage(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetStatspage(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableStatspage sets the "statspage" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableStatspage(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetStatspage(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetStatsprivate sets the "statsprivate" field.
|
|
func (suo *SettingsUpdateOne) SetStatsprivate(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetStatsprivate(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableStatsprivate sets the "statsprivate" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableStatsprivate(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetStatsprivate(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetStats sets the "stats" field.
|
|
func (suo *SettingsUpdateOne) SetStats(b bool) *SettingsUpdateOne {
|
|
suo.mutation.SetStats(b)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableStats sets the "stats" field if the given value is not nil.
|
|
func (suo *SettingsUpdateOne) SetNillableStats(b *bool) *SettingsUpdateOne {
|
|
if b != nil {
|
|
suo.SetStats(*b)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// Mutation returns the SettingsMutation object of the builder.
|
|
func (suo *SettingsUpdateOne) Mutation() *SettingsMutation {
|
|
return suo.mutation
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (suo *SettingsUpdateOne) Select(field string, fields ...string) *SettingsUpdateOne {
|
|
suo.fields = append([]string{field}, fields...)
|
|
return suo
|
|
}
|
|
|
|
// Save executes the query and returns the updated Settings entity.
|
|
func (suo *SettingsUpdateOne) Save(ctx context.Context) (*Settings, error) {
|
|
var (
|
|
err error
|
|
node *Settings
|
|
)
|
|
if len(suo.hooks) == 0 {
|
|
node, err = suo.sqlSave(ctx)
|
|
} else {
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*SettingsMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
suo.mutation = mutation
|
|
node, err = suo.sqlSave(ctx)
|
|
mutation.done = true
|
|
return node, err
|
|
})
|
|
for i := len(suo.hooks) - 1; i >= 0; i-- {
|
|
if suo.hooks[i] == nil {
|
|
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
|
}
|
|
mut = suo.hooks[i](mut)
|
|
}
|
|
v, err := mut.Mutate(ctx, suo.mutation)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
nv, ok := v.(*Settings)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected node type %T returned from SettingsMutation", v)
|
|
}
|
|
node = nv
|
|
}
|
|
return node, err
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (suo *SettingsUpdateOne) SaveX(ctx context.Context) *Settings {
|
|
node, err := suo.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (suo *SettingsUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := suo.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (suo *SettingsUpdateOne) ExecX(ctx context.Context) {
|
|
if err := suo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (suo *SettingsUpdateOne) sqlSave(ctx context.Context) (_node *Settings, err error) {
|
|
_spec := &sqlgraph.UpdateSpec{
|
|
Node: &sqlgraph.NodeSpec{
|
|
Table: settings.Table,
|
|
Columns: settings.Columns,
|
|
ID: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: settings.FieldID,
|
|
},
|
|
},
|
|
}
|
|
id, ok := suo.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Settings.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := suo.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, settings.FieldID)
|
|
for _, f := range fields {
|
|
if !settings.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != settings.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := suo.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := suo.mutation.Serverid(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldServerid,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Servername(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldServername,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Ownerid(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldOwnerid,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Permtoken(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldPermtoken,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Apitoken(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldApitoken,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Statspagemode(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldStatspagemode,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Loggerchannel(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldLoggerchannel,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Spamchannel(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldSpamchannel,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Greeterchannel(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldGreeterchannel,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Greetermode(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldGreetermode,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Announcechannel(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldAnnouncechannel,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Logger(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldLogger,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Spamprotection(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldSpamprotection,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Linkprotection(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldLinkprotection,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Wordfilter(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldWordfilter,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Greetings(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldGreetings,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Apitoggle(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldApitoggle,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Moderation(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldModeration,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Automatedmoderation(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldAutomatedmoderation,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Twitchannounce(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldTwitchannounce,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Twitterannounce(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldTwitterannounce,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Music(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldMusic,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Statspage(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldStatspage,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Statsprivate(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldStatsprivate,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Stats(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldStats,
|
|
})
|
|
}
|
|
_node = &Settings{config: suo.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{settings.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
return _node, nil
|
|
}
|