821 lines
24 KiB
Go
821 lines
24 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/settings"
|
|
)
|
|
|
|
// SettingsCreate is the builder for creating a Settings entity.
|
|
type SettingsCreate struct {
|
|
config
|
|
mutation *SettingsMutation
|
|
hooks []Hook
|
|
}
|
|
|
|
// SetServerid sets the "serverid" field.
|
|
func (sc *SettingsCreate) SetServerid(s string) *SettingsCreate {
|
|
sc.mutation.SetServerid(s)
|
|
return sc
|
|
}
|
|
|
|
// SetServername sets the "servername" field.
|
|
func (sc *SettingsCreate) SetServername(s string) *SettingsCreate {
|
|
sc.mutation.SetServername(s)
|
|
return sc
|
|
}
|
|
|
|
// SetOwnerid sets the "ownerid" field.
|
|
func (sc *SettingsCreate) SetOwnerid(s string) *SettingsCreate {
|
|
sc.mutation.SetOwnerid(s)
|
|
return sc
|
|
}
|
|
|
|
// SetPermtoken sets the "permtoken" field.
|
|
func (sc *SettingsCreate) SetPermtoken(s string) *SettingsCreate {
|
|
sc.mutation.SetPermtoken(s)
|
|
return sc
|
|
}
|
|
|
|
// SetApitoken sets the "apitoken" field.
|
|
func (sc *SettingsCreate) SetApitoken(s string) *SettingsCreate {
|
|
sc.mutation.SetApitoken(s)
|
|
return sc
|
|
}
|
|
|
|
// SetStatspagemode sets the "statspagemode" field.
|
|
func (sc *SettingsCreate) SetStatspagemode(s string) *SettingsCreate {
|
|
sc.mutation.SetStatspagemode(s)
|
|
return sc
|
|
}
|
|
|
|
// SetLoggerchannel sets the "loggerchannel" field.
|
|
func (sc *SettingsCreate) SetLoggerchannel(s string) *SettingsCreate {
|
|
sc.mutation.SetLoggerchannel(s)
|
|
return sc
|
|
}
|
|
|
|
// SetSpamchannel sets the "spamchannel" field.
|
|
func (sc *SettingsCreate) SetSpamchannel(s string) *SettingsCreate {
|
|
sc.mutation.SetSpamchannel(s)
|
|
return sc
|
|
}
|
|
|
|
// SetGreeterchannel sets the "greeterchannel" field.
|
|
func (sc *SettingsCreate) SetGreeterchannel(s string) *SettingsCreate {
|
|
sc.mutation.SetGreeterchannel(s)
|
|
return sc
|
|
}
|
|
|
|
// SetGreetermode sets the "greetermode" field.
|
|
func (sc *SettingsCreate) SetGreetermode(s string) *SettingsCreate {
|
|
sc.mutation.SetGreetermode(s)
|
|
return sc
|
|
}
|
|
|
|
// SetAnnouncechannel sets the "announcechannel" field.
|
|
func (sc *SettingsCreate) SetAnnouncechannel(s string) *SettingsCreate {
|
|
sc.mutation.SetAnnouncechannel(s)
|
|
return sc
|
|
}
|
|
|
|
// SetLogger sets the "logger" field.
|
|
func (sc *SettingsCreate) SetLogger(b bool) *SettingsCreate {
|
|
sc.mutation.SetLogger(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableLogger sets the "logger" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableLogger(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetLogger(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetSpamprotection sets the "spamprotection" field.
|
|
func (sc *SettingsCreate) SetSpamprotection(b bool) *SettingsCreate {
|
|
sc.mutation.SetSpamprotection(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableSpamprotection sets the "spamprotection" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableSpamprotection(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetSpamprotection(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetLinkprotection sets the "linkprotection" field.
|
|
func (sc *SettingsCreate) SetLinkprotection(b bool) *SettingsCreate {
|
|
sc.mutation.SetLinkprotection(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableLinkprotection sets the "linkprotection" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableLinkprotection(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetLinkprotection(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetWordfilter sets the "wordfilter" field.
|
|
func (sc *SettingsCreate) SetWordfilter(b bool) *SettingsCreate {
|
|
sc.mutation.SetWordfilter(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableWordfilter sets the "wordfilter" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableWordfilter(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetWordfilter(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetGreetings sets the "greetings" field.
|
|
func (sc *SettingsCreate) SetGreetings(b bool) *SettingsCreate {
|
|
sc.mutation.SetGreetings(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableGreetings sets the "greetings" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableGreetings(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetGreetings(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetApitoggle sets the "apitoggle" field.
|
|
func (sc *SettingsCreate) SetApitoggle(b bool) *SettingsCreate {
|
|
sc.mutation.SetApitoggle(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableApitoggle sets the "apitoggle" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableApitoggle(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetApitoggle(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetModeration sets the "moderation" field.
|
|
func (sc *SettingsCreate) SetModeration(b bool) *SettingsCreate {
|
|
sc.mutation.SetModeration(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableModeration sets the "moderation" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableModeration(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetModeration(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetAutomatedmoderation sets the "automatedmoderation" field.
|
|
func (sc *SettingsCreate) SetAutomatedmoderation(b bool) *SettingsCreate {
|
|
sc.mutation.SetAutomatedmoderation(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableAutomatedmoderation sets the "automatedmoderation" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableAutomatedmoderation(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetAutomatedmoderation(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetTwitchannounce sets the "twitchannounce" field.
|
|
func (sc *SettingsCreate) SetTwitchannounce(b bool) *SettingsCreate {
|
|
sc.mutation.SetTwitchannounce(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableTwitchannounce sets the "twitchannounce" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableTwitchannounce(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetTwitchannounce(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetTwitterannounce sets the "twitterannounce" field.
|
|
func (sc *SettingsCreate) SetTwitterannounce(b bool) *SettingsCreate {
|
|
sc.mutation.SetTwitterannounce(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableTwitterannounce sets the "twitterannounce" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableTwitterannounce(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetTwitterannounce(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetMusic sets the "music" field.
|
|
func (sc *SettingsCreate) SetMusic(b bool) *SettingsCreate {
|
|
sc.mutation.SetMusic(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableMusic sets the "music" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableMusic(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetMusic(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetStatspage sets the "statspage" field.
|
|
func (sc *SettingsCreate) SetStatspage(b bool) *SettingsCreate {
|
|
sc.mutation.SetStatspage(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableStatspage sets the "statspage" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableStatspage(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetStatspage(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetStatsprivate sets the "statsprivate" field.
|
|
func (sc *SettingsCreate) SetStatsprivate(b bool) *SettingsCreate {
|
|
sc.mutation.SetStatsprivate(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableStatsprivate sets the "statsprivate" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableStatsprivate(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetStatsprivate(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetStats sets the "stats" field.
|
|
func (sc *SettingsCreate) SetStats(b bool) *SettingsCreate {
|
|
sc.mutation.SetStats(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableStats sets the "stats" field if the given value is not nil.
|
|
func (sc *SettingsCreate) SetNillableStats(b *bool) *SettingsCreate {
|
|
if b != nil {
|
|
sc.SetStats(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (sc *SettingsCreate) SetID(i int) *SettingsCreate {
|
|
sc.mutation.SetID(i)
|
|
return sc
|
|
}
|
|
|
|
// Mutation returns the SettingsMutation object of the builder.
|
|
func (sc *SettingsCreate) Mutation() *SettingsMutation {
|
|
return sc.mutation
|
|
}
|
|
|
|
// Save creates the Settings in the database.
|
|
func (sc *SettingsCreate) Save(ctx context.Context) (*Settings, error) {
|
|
var (
|
|
err error
|
|
node *Settings
|
|
)
|
|
sc.defaults()
|
|
if len(sc.hooks) == 0 {
|
|
if err = sc.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
node, err = sc.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)
|
|
}
|
|
if err = sc.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
sc.mutation = mutation
|
|
if node, err = sc.sqlSave(ctx); err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &node.ID
|
|
mutation.done = true
|
|
return node, err
|
|
})
|
|
for i := len(sc.hooks) - 1; i >= 0; i-- {
|
|
if sc.hooks[i] == nil {
|
|
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
|
}
|
|
mut = sc.hooks[i](mut)
|
|
}
|
|
v, err := mut.Mutate(ctx, sc.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 calls Save and panics if Save returns an error.
|
|
func (sc *SettingsCreate) SaveX(ctx context.Context) *Settings {
|
|
v, err := sc.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (sc *SettingsCreate) Exec(ctx context.Context) error {
|
|
_, err := sc.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (sc *SettingsCreate) ExecX(ctx context.Context) {
|
|
if err := sc.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (sc *SettingsCreate) defaults() {
|
|
if _, ok := sc.mutation.Logger(); !ok {
|
|
v := settings.DefaultLogger
|
|
sc.mutation.SetLogger(v)
|
|
}
|
|
if _, ok := sc.mutation.Spamprotection(); !ok {
|
|
v := settings.DefaultSpamprotection
|
|
sc.mutation.SetSpamprotection(v)
|
|
}
|
|
if _, ok := sc.mutation.Linkprotection(); !ok {
|
|
v := settings.DefaultLinkprotection
|
|
sc.mutation.SetLinkprotection(v)
|
|
}
|
|
if _, ok := sc.mutation.Wordfilter(); !ok {
|
|
v := settings.DefaultWordfilter
|
|
sc.mutation.SetWordfilter(v)
|
|
}
|
|
if _, ok := sc.mutation.Greetings(); !ok {
|
|
v := settings.DefaultGreetings
|
|
sc.mutation.SetGreetings(v)
|
|
}
|
|
if _, ok := sc.mutation.Apitoggle(); !ok {
|
|
v := settings.DefaultApitoggle
|
|
sc.mutation.SetApitoggle(v)
|
|
}
|
|
if _, ok := sc.mutation.Moderation(); !ok {
|
|
v := settings.DefaultModeration
|
|
sc.mutation.SetModeration(v)
|
|
}
|
|
if _, ok := sc.mutation.Automatedmoderation(); !ok {
|
|
v := settings.DefaultAutomatedmoderation
|
|
sc.mutation.SetAutomatedmoderation(v)
|
|
}
|
|
if _, ok := sc.mutation.Twitchannounce(); !ok {
|
|
v := settings.DefaultTwitchannounce
|
|
sc.mutation.SetTwitchannounce(v)
|
|
}
|
|
if _, ok := sc.mutation.Twitterannounce(); !ok {
|
|
v := settings.DefaultTwitterannounce
|
|
sc.mutation.SetTwitterannounce(v)
|
|
}
|
|
if _, ok := sc.mutation.Music(); !ok {
|
|
v := settings.DefaultMusic
|
|
sc.mutation.SetMusic(v)
|
|
}
|
|
if _, ok := sc.mutation.Statspage(); !ok {
|
|
v := settings.DefaultStatspage
|
|
sc.mutation.SetStatspage(v)
|
|
}
|
|
if _, ok := sc.mutation.Statsprivate(); !ok {
|
|
v := settings.DefaultStatsprivate
|
|
sc.mutation.SetStatsprivate(v)
|
|
}
|
|
if _, ok := sc.mutation.Stats(); !ok {
|
|
v := settings.DefaultStats
|
|
sc.mutation.SetStats(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (sc *SettingsCreate) check() error {
|
|
if _, ok := sc.mutation.Serverid(); !ok {
|
|
return &ValidationError{Name: "serverid", err: errors.New(`ent: missing required field "Settings.serverid"`)}
|
|
}
|
|
if _, ok := sc.mutation.Servername(); !ok {
|
|
return &ValidationError{Name: "servername", err: errors.New(`ent: missing required field "Settings.servername"`)}
|
|
}
|
|
if _, ok := sc.mutation.Ownerid(); !ok {
|
|
return &ValidationError{Name: "ownerid", err: errors.New(`ent: missing required field "Settings.ownerid"`)}
|
|
}
|
|
if _, ok := sc.mutation.Permtoken(); !ok {
|
|
return &ValidationError{Name: "permtoken", err: errors.New(`ent: missing required field "Settings.permtoken"`)}
|
|
}
|
|
if _, ok := sc.mutation.Apitoken(); !ok {
|
|
return &ValidationError{Name: "apitoken", err: errors.New(`ent: missing required field "Settings.apitoken"`)}
|
|
}
|
|
if _, ok := sc.mutation.Statspagemode(); !ok {
|
|
return &ValidationError{Name: "statspagemode", err: errors.New(`ent: missing required field "Settings.statspagemode"`)}
|
|
}
|
|
if _, ok := sc.mutation.Loggerchannel(); !ok {
|
|
return &ValidationError{Name: "loggerchannel", err: errors.New(`ent: missing required field "Settings.loggerchannel"`)}
|
|
}
|
|
if _, ok := sc.mutation.Spamchannel(); !ok {
|
|
return &ValidationError{Name: "spamchannel", err: errors.New(`ent: missing required field "Settings.spamchannel"`)}
|
|
}
|
|
if _, ok := sc.mutation.Greeterchannel(); !ok {
|
|
return &ValidationError{Name: "greeterchannel", err: errors.New(`ent: missing required field "Settings.greeterchannel"`)}
|
|
}
|
|
if _, ok := sc.mutation.Greetermode(); !ok {
|
|
return &ValidationError{Name: "greetermode", err: errors.New(`ent: missing required field "Settings.greetermode"`)}
|
|
}
|
|
if _, ok := sc.mutation.Announcechannel(); !ok {
|
|
return &ValidationError{Name: "announcechannel", err: errors.New(`ent: missing required field "Settings.announcechannel"`)}
|
|
}
|
|
if _, ok := sc.mutation.Logger(); !ok {
|
|
return &ValidationError{Name: "logger", err: errors.New(`ent: missing required field "Settings.logger"`)}
|
|
}
|
|
if _, ok := sc.mutation.Spamprotection(); !ok {
|
|
return &ValidationError{Name: "spamprotection", err: errors.New(`ent: missing required field "Settings.spamprotection"`)}
|
|
}
|
|
if _, ok := sc.mutation.Linkprotection(); !ok {
|
|
return &ValidationError{Name: "linkprotection", err: errors.New(`ent: missing required field "Settings.linkprotection"`)}
|
|
}
|
|
if _, ok := sc.mutation.Wordfilter(); !ok {
|
|
return &ValidationError{Name: "wordfilter", err: errors.New(`ent: missing required field "Settings.wordfilter"`)}
|
|
}
|
|
if _, ok := sc.mutation.Greetings(); !ok {
|
|
return &ValidationError{Name: "greetings", err: errors.New(`ent: missing required field "Settings.greetings"`)}
|
|
}
|
|
if _, ok := sc.mutation.Apitoggle(); !ok {
|
|
return &ValidationError{Name: "apitoggle", err: errors.New(`ent: missing required field "Settings.apitoggle"`)}
|
|
}
|
|
if _, ok := sc.mutation.Moderation(); !ok {
|
|
return &ValidationError{Name: "moderation", err: errors.New(`ent: missing required field "Settings.moderation"`)}
|
|
}
|
|
if _, ok := sc.mutation.Automatedmoderation(); !ok {
|
|
return &ValidationError{Name: "automatedmoderation", err: errors.New(`ent: missing required field "Settings.automatedmoderation"`)}
|
|
}
|
|
if _, ok := sc.mutation.Twitchannounce(); !ok {
|
|
return &ValidationError{Name: "twitchannounce", err: errors.New(`ent: missing required field "Settings.twitchannounce"`)}
|
|
}
|
|
if _, ok := sc.mutation.Twitterannounce(); !ok {
|
|
return &ValidationError{Name: "twitterannounce", err: errors.New(`ent: missing required field "Settings.twitterannounce"`)}
|
|
}
|
|
if _, ok := sc.mutation.Music(); !ok {
|
|
return &ValidationError{Name: "music", err: errors.New(`ent: missing required field "Settings.music"`)}
|
|
}
|
|
if _, ok := sc.mutation.Statspage(); !ok {
|
|
return &ValidationError{Name: "statspage", err: errors.New(`ent: missing required field "Settings.statspage"`)}
|
|
}
|
|
if _, ok := sc.mutation.Statsprivate(); !ok {
|
|
return &ValidationError{Name: "statsprivate", err: errors.New(`ent: missing required field "Settings.statsprivate"`)}
|
|
}
|
|
if _, ok := sc.mutation.Stats(); !ok {
|
|
return &ValidationError{Name: "stats", err: errors.New(`ent: missing required field "Settings.stats"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (sc *SettingsCreate) sqlSave(ctx context.Context) (*Settings, error) {
|
|
_node, _spec := sc.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
if _spec.ID.Value != _node.ID {
|
|
id := _spec.ID.Value.(int64)
|
|
_node.ID = int(id)
|
|
}
|
|
return _node, nil
|
|
}
|
|
|
|
func (sc *SettingsCreate) createSpec() (*Settings, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &Settings{config: sc.config}
|
|
_spec = &sqlgraph.CreateSpec{
|
|
Table: settings.Table,
|
|
ID: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: settings.FieldID,
|
|
},
|
|
}
|
|
)
|
|
if id, ok := sc.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = id
|
|
}
|
|
if value, ok := sc.mutation.Serverid(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldServerid,
|
|
})
|
|
_node.Serverid = value
|
|
}
|
|
if value, ok := sc.mutation.Servername(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldServername,
|
|
})
|
|
_node.Servername = value
|
|
}
|
|
if value, ok := sc.mutation.Ownerid(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldOwnerid,
|
|
})
|
|
_node.Ownerid = value
|
|
}
|
|
if value, ok := sc.mutation.Permtoken(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldPermtoken,
|
|
})
|
|
_node.Permtoken = value
|
|
}
|
|
if value, ok := sc.mutation.Apitoken(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldApitoken,
|
|
})
|
|
_node.Apitoken = value
|
|
}
|
|
if value, ok := sc.mutation.Statspagemode(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldStatspagemode,
|
|
})
|
|
_node.Statspagemode = value
|
|
}
|
|
if value, ok := sc.mutation.Loggerchannel(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldLoggerchannel,
|
|
})
|
|
_node.Loggerchannel = value
|
|
}
|
|
if value, ok := sc.mutation.Spamchannel(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldSpamchannel,
|
|
})
|
|
_node.Spamchannel = value
|
|
}
|
|
if value, ok := sc.mutation.Greeterchannel(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldGreeterchannel,
|
|
})
|
|
_node.Greeterchannel = value
|
|
}
|
|
if value, ok := sc.mutation.Greetermode(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldGreetermode,
|
|
})
|
|
_node.Greetermode = value
|
|
}
|
|
if value, ok := sc.mutation.Announcechannel(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: settings.FieldAnnouncechannel,
|
|
})
|
|
_node.Announcechannel = value
|
|
}
|
|
if value, ok := sc.mutation.Logger(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldLogger,
|
|
})
|
|
_node.Logger = value
|
|
}
|
|
if value, ok := sc.mutation.Spamprotection(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldSpamprotection,
|
|
})
|
|
_node.Spamprotection = value
|
|
}
|
|
if value, ok := sc.mutation.Linkprotection(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldLinkprotection,
|
|
})
|
|
_node.Linkprotection = value
|
|
}
|
|
if value, ok := sc.mutation.Wordfilter(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldWordfilter,
|
|
})
|
|
_node.Wordfilter = value
|
|
}
|
|
if value, ok := sc.mutation.Greetings(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldGreetings,
|
|
})
|
|
_node.Greetings = value
|
|
}
|
|
if value, ok := sc.mutation.Apitoggle(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldApitoggle,
|
|
})
|
|
_node.Apitoggle = value
|
|
}
|
|
if value, ok := sc.mutation.Moderation(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldModeration,
|
|
})
|
|
_node.Moderation = value
|
|
}
|
|
if value, ok := sc.mutation.Automatedmoderation(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldAutomatedmoderation,
|
|
})
|
|
_node.Automatedmoderation = value
|
|
}
|
|
if value, ok := sc.mutation.Twitchannounce(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldTwitchannounce,
|
|
})
|
|
_node.Twitchannounce = value
|
|
}
|
|
if value, ok := sc.mutation.Twitterannounce(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldTwitterannounce,
|
|
})
|
|
_node.Twitterannounce = value
|
|
}
|
|
if value, ok := sc.mutation.Music(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldMusic,
|
|
})
|
|
_node.Music = value
|
|
}
|
|
if value, ok := sc.mutation.Statspage(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldStatspage,
|
|
})
|
|
_node.Statspage = value
|
|
}
|
|
if value, ok := sc.mutation.Statsprivate(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldStatsprivate,
|
|
})
|
|
_node.Statsprivate = value
|
|
}
|
|
if value, ok := sc.mutation.Stats(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: settings.FieldStats,
|
|
})
|
|
_node.Stats = value
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// SettingsCreateBulk is the builder for creating many Settings entities in bulk.
|
|
type SettingsCreateBulk struct {
|
|
config
|
|
builders []*SettingsCreate
|
|
}
|
|
|
|
// Save creates the Settings entities in the database.
|
|
func (scb *SettingsCreateBulk) Save(ctx context.Context) ([]*Settings, error) {
|
|
specs := make([]*sqlgraph.CreateSpec, len(scb.builders))
|
|
nodes := make([]*Settings, len(scb.builders))
|
|
mutators := make([]Mutator, len(scb.builders))
|
|
for i := range scb.builders {
|
|
func(i int, root context.Context) {
|
|
builder := scb.builders[i]
|
|
builder.defaults()
|
|
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)
|
|
}
|
|
if err := builder.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
builder.mutation = mutation
|
|
nodes[i], specs[i] = builder.createSpec()
|
|
var err error
|
|
if i < len(mutators)-1 {
|
|
_, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, scb.driver, spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
}
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &nodes[i].ID
|
|
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
|
|
id := specs[i].ID.Value.(int64)
|
|
nodes[i].ID = int(id)
|
|
}
|
|
mutation.done = true
|
|
return nodes[i], nil
|
|
})
|
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
|
mut = builder.hooks[i](mut)
|
|
}
|
|
mutators[i] = mut
|
|
}(i, ctx)
|
|
}
|
|
if len(mutators) > 0 {
|
|
if _, err := mutators[0].Mutate(ctx, scb.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (scb *SettingsCreateBulk) SaveX(ctx context.Context) []*Settings {
|
|
v, err := scb.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (scb *SettingsCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := scb.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (scb *SettingsCreateBulk) ExecX(ctx context.Context) {
|
|
if err := scb.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|