// Code generated by entc, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"time"

	"code.icod.de/postfix/manager/ent/account"
	"code.icod.de/postfix/manager/ent/alias"
	"code.icod.de/postfix/manager/ent/domain"
	"code.icod.de/postfix/manager/ent/logentry"
	"code.icod.de/postfix/manager/ent/mailbox"
	"code.icod.de/postfix/manager/ent/predicate"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)

// DomainUpdate is the builder for updating Domain entities.
type DomainUpdate struct {
	config
	hooks    []Hook
	mutation *DomainMutation
}

// Where appends a list predicates to the DomainUpdate builder.
func (du *DomainUpdate) Where(ps ...predicate.Domain) *DomainUpdate {
	du.mutation.Where(ps...)
	return du
}

// SetModified sets the "modified" field.
func (du *DomainUpdate) SetModified(t time.Time) *DomainUpdate {
	du.mutation.SetModified(t)
	return du
}

// ClearModified clears the value of the "modified" field.
func (du *DomainUpdate) ClearModified() *DomainUpdate {
	du.mutation.ClearModified()
	return du
}

// SetDomain sets the "domain" field.
func (du *DomainUpdate) SetDomain(s string) *DomainUpdate {
	du.mutation.SetDomain(s)
	return du
}

// SetDescription sets the "description" field.
func (du *DomainUpdate) SetDescription(s string) *DomainUpdate {
	du.mutation.SetDescription(s)
	return du
}

// SetNillableDescription sets the "description" field if the given value is not nil.
func (du *DomainUpdate) SetNillableDescription(s *string) *DomainUpdate {
	if s != nil {
		du.SetDescription(*s)
	}
	return du
}

// ClearDescription clears the value of the "description" field.
func (du *DomainUpdate) ClearDescription() *DomainUpdate {
	du.mutation.ClearDescription()
	return du
}

// SetMaxAliases sets the "max_aliases" field.
func (du *DomainUpdate) SetMaxAliases(i int64) *DomainUpdate {
	du.mutation.ResetMaxAliases()
	du.mutation.SetMaxAliases(i)
	return du
}

// AddMaxAliases adds i to the "max_aliases" field.
func (du *DomainUpdate) AddMaxAliases(i int64) *DomainUpdate {
	du.mutation.AddMaxAliases(i)
	return du
}

// SetMaxMailboxes sets the "max_mailboxes" field.
func (du *DomainUpdate) SetMaxMailboxes(i int64) *DomainUpdate {
	du.mutation.ResetMaxMailboxes()
	du.mutation.SetMaxMailboxes(i)
	return du
}

// AddMaxMailboxes adds i to the "max_mailboxes" field.
func (du *DomainUpdate) AddMaxMailboxes(i int64) *DomainUpdate {
	du.mutation.AddMaxMailboxes(i)
	return du
}

// SetMaxQuota sets the "max_quota" field.
func (du *DomainUpdate) SetMaxQuota(i int64) *DomainUpdate {
	du.mutation.ResetMaxQuota()
	du.mutation.SetMaxQuota(i)
	return du
}

// AddMaxQuota adds i to the "max_quota" field.
func (du *DomainUpdate) AddMaxQuota(i int64) *DomainUpdate {
	du.mutation.AddMaxQuota(i)
	return du
}

// SetQuota sets the "quota" field.
func (du *DomainUpdate) SetQuota(i int64) *DomainUpdate {
	du.mutation.ResetQuota()
	du.mutation.SetQuota(i)
	return du
}

// AddQuota adds i to the "quota" field.
func (du *DomainUpdate) AddQuota(i int64) *DomainUpdate {
	du.mutation.AddQuota(i)
	return du
}

// SetTransport sets the "transport" field.
func (du *DomainUpdate) SetTransport(s string) *DomainUpdate {
	du.mutation.SetTransport(s)
	return du
}

// SetBackupMx sets the "backup_mx" field.
func (du *DomainUpdate) SetBackupMx(b bool) *DomainUpdate {
	du.mutation.SetBackupMx(b)
	return du
}

// SetActive sets the "active" field.
func (du *DomainUpdate) SetActive(b bool) *DomainUpdate {
	du.mutation.SetActive(b)
	return du
}

// AddMailboxIDs adds the "mailboxes" edge to the Mailbox entity by IDs.
func (du *DomainUpdate) AddMailboxIDs(ids ...int64) *DomainUpdate {
	du.mutation.AddMailboxIDs(ids...)
	return du
}

// AddMailboxes adds the "mailboxes" edges to the Mailbox entity.
func (du *DomainUpdate) AddMailboxes(m ...*Mailbox) *DomainUpdate {
	ids := make([]int64, len(m))
	for i := range m {
		ids[i] = m[i].ID
	}
	return du.AddMailboxIDs(ids...)
}

// AddAliasIDs adds the "aliases" edge to the Alias entity by IDs.
func (du *DomainUpdate) AddAliasIDs(ids ...int64) *DomainUpdate {
	du.mutation.AddAliasIDs(ids...)
	return du
}

// AddAliases adds the "aliases" edges to the Alias entity.
func (du *DomainUpdate) AddAliases(a ...*Alias) *DomainUpdate {
	ids := make([]int64, len(a))
	for i := range a {
		ids[i] = a[i].ID
	}
	return du.AddAliasIDs(ids...)
}

// AddLogIDs adds the "logs" edge to the Logentry entity by IDs.
func (du *DomainUpdate) AddLogIDs(ids ...int64) *DomainUpdate {
	du.mutation.AddLogIDs(ids...)
	return du
}

// AddLogs adds the "logs" edges to the Logentry entity.
func (du *DomainUpdate) AddLogs(l ...*Logentry) *DomainUpdate {
	ids := make([]int64, len(l))
	for i := range l {
		ids[i] = l[i].ID
	}
	return du.AddLogIDs(ids...)
}

// AddAccountIDs adds the "accounts" edge to the Account entity by IDs.
func (du *DomainUpdate) AddAccountIDs(ids ...int64) *DomainUpdate {
	du.mutation.AddAccountIDs(ids...)
	return du
}

// AddAccounts adds the "accounts" edges to the Account entity.
func (du *DomainUpdate) AddAccounts(a ...*Account) *DomainUpdate {
	ids := make([]int64, len(a))
	for i := range a {
		ids[i] = a[i].ID
	}
	return du.AddAccountIDs(ids...)
}

// Mutation returns the DomainMutation object of the builder.
func (du *DomainUpdate) Mutation() *DomainMutation {
	return du.mutation
}

// ClearMailboxes clears all "mailboxes" edges to the Mailbox entity.
func (du *DomainUpdate) ClearMailboxes() *DomainUpdate {
	du.mutation.ClearMailboxes()
	return du
}

// RemoveMailboxIDs removes the "mailboxes" edge to Mailbox entities by IDs.
func (du *DomainUpdate) RemoveMailboxIDs(ids ...int64) *DomainUpdate {
	du.mutation.RemoveMailboxIDs(ids...)
	return du
}

// RemoveMailboxes removes "mailboxes" edges to Mailbox entities.
func (du *DomainUpdate) RemoveMailboxes(m ...*Mailbox) *DomainUpdate {
	ids := make([]int64, len(m))
	for i := range m {
		ids[i] = m[i].ID
	}
	return du.RemoveMailboxIDs(ids...)
}

// ClearAliases clears all "aliases" edges to the Alias entity.
func (du *DomainUpdate) ClearAliases() *DomainUpdate {
	du.mutation.ClearAliases()
	return du
}

// RemoveAliasIDs removes the "aliases" edge to Alias entities by IDs.
func (du *DomainUpdate) RemoveAliasIDs(ids ...int64) *DomainUpdate {
	du.mutation.RemoveAliasIDs(ids...)
	return du
}

// RemoveAliases removes "aliases" edges to Alias entities.
func (du *DomainUpdate) RemoveAliases(a ...*Alias) *DomainUpdate {
	ids := make([]int64, len(a))
	for i := range a {
		ids[i] = a[i].ID
	}
	return du.RemoveAliasIDs(ids...)
}

// ClearLogs clears all "logs" edges to the Logentry entity.
func (du *DomainUpdate) ClearLogs() *DomainUpdate {
	du.mutation.ClearLogs()
	return du
}

// RemoveLogIDs removes the "logs" edge to Logentry entities by IDs.
func (du *DomainUpdate) RemoveLogIDs(ids ...int64) *DomainUpdate {
	du.mutation.RemoveLogIDs(ids...)
	return du
}

// RemoveLogs removes "logs" edges to Logentry entities.
func (du *DomainUpdate) RemoveLogs(l ...*Logentry) *DomainUpdate {
	ids := make([]int64, len(l))
	for i := range l {
		ids[i] = l[i].ID
	}
	return du.RemoveLogIDs(ids...)
}

// ClearAccounts clears all "accounts" edges to the Account entity.
func (du *DomainUpdate) ClearAccounts() *DomainUpdate {
	du.mutation.ClearAccounts()
	return du
}

// RemoveAccountIDs removes the "accounts" edge to Account entities by IDs.
func (du *DomainUpdate) RemoveAccountIDs(ids ...int64) *DomainUpdate {
	du.mutation.RemoveAccountIDs(ids...)
	return du
}

// RemoveAccounts removes "accounts" edges to Account entities.
func (du *DomainUpdate) RemoveAccounts(a ...*Account) *DomainUpdate {
	ids := make([]int64, len(a))
	for i := range a {
		ids[i] = a[i].ID
	}
	return du.RemoveAccountIDs(ids...)
}

// Save executes the query and returns the number of nodes affected by the update operation.
func (du *DomainUpdate) Save(ctx context.Context) (int, error) {
	var (
		err      error
		affected int
	)
	du.defaults()
	if len(du.hooks) == 0 {
		affected, err = du.sqlSave(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*DomainMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			du.mutation = mutation
			affected, err = du.sqlSave(ctx)
			mutation.done = true
			return affected, err
		})
		for i := len(du.hooks) - 1; i >= 0; i-- {
			if du.hooks[i] == nil {
				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
			}
			mut = du.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, du.mutation); err != nil {
			return 0, err
		}
	}
	return affected, err
}

// SaveX is like Save, but panics if an error occurs.
func (du *DomainUpdate) SaveX(ctx context.Context) int {
	affected, err := du.Save(ctx)
	if err != nil {
		panic(err)
	}
	return affected
}

// Exec executes the query.
func (du *DomainUpdate) Exec(ctx context.Context) error {
	_, err := du.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (du *DomainUpdate) ExecX(ctx context.Context) {
	if err := du.Exec(ctx); err != nil {
		panic(err)
	}
}

// defaults sets the default values of the builder before save.
func (du *DomainUpdate) defaults() {
	if _, ok := du.mutation.Modified(); !ok && !du.mutation.ModifiedCleared() {
		v := domain.UpdateDefaultModified()
		du.mutation.SetModified(v)
	}
}

func (du *DomainUpdate) sqlSave(ctx context.Context) (n int, err error) {
	_spec := &sqlgraph.UpdateSpec{
		Node: &sqlgraph.NodeSpec{
			Table:   domain.Table,
			Columns: domain.Columns,
			ID: &sqlgraph.FieldSpec{
				Type:   field.TypeInt64,
				Column: domain.FieldID,
			},
		},
	}
	if ps := du.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := du.mutation.Modified(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeTime,
			Value:  value,
			Column: domain.FieldModified,
		})
	}
	if du.mutation.ModifiedCleared() {
		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
			Type:   field.TypeTime,
			Column: domain.FieldModified,
		})
	}
	if value, ok := du.mutation.Domain(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeString,
			Value:  value,
			Column: domain.FieldDomain,
		})
	}
	if value, ok := du.mutation.Description(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeString,
			Value:  value,
			Column: domain.FieldDescription,
		})
	}
	if du.mutation.DescriptionCleared() {
		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
			Type:   field.TypeString,
			Column: domain.FieldDescription,
		})
	}
	if value, ok := du.mutation.MaxAliases(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldMaxAliases,
		})
	}
	if value, ok := du.mutation.AddedMaxAliases(); ok {
		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldMaxAliases,
		})
	}
	if value, ok := du.mutation.MaxMailboxes(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldMaxMailboxes,
		})
	}
	if value, ok := du.mutation.AddedMaxMailboxes(); ok {
		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldMaxMailboxes,
		})
	}
	if value, ok := du.mutation.MaxQuota(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldMaxQuota,
		})
	}
	if value, ok := du.mutation.AddedMaxQuota(); ok {
		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldMaxQuota,
		})
	}
	if value, ok := du.mutation.Quota(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldQuota,
		})
	}
	if value, ok := du.mutation.AddedQuota(); ok {
		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldQuota,
		})
	}
	if value, ok := du.mutation.Transport(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeString,
			Value:  value,
			Column: domain.FieldTransport,
		})
	}
	if value, ok := du.mutation.BackupMx(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeBool,
			Value:  value,
			Column: domain.FieldBackupMx,
		})
	}
	if value, ok := du.mutation.Active(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeBool,
			Value:  value,
			Column: domain.FieldActive,
		})
	}
	if du.mutation.MailboxesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.MailboxesTable,
			Columns: []string{domain.MailboxesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: mailbox.FieldID,
				},
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := du.mutation.RemovedMailboxesIDs(); len(nodes) > 0 && !du.mutation.MailboxesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.MailboxesTable,
			Columns: []string{domain.MailboxesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: mailbox.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := du.mutation.MailboxesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.MailboxesTable,
			Columns: []string{domain.MailboxesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: mailbox.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if du.mutation.AliasesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.AliasesTable,
			Columns: []string{domain.AliasesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: alias.FieldID,
				},
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := du.mutation.RemovedAliasesIDs(); len(nodes) > 0 && !du.mutation.AliasesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.AliasesTable,
			Columns: []string{domain.AliasesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: alias.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := du.mutation.AliasesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.AliasesTable,
			Columns: []string{domain.AliasesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: alias.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if du.mutation.LogsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.LogsTable,
			Columns: []string{domain.LogsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: logentry.FieldID,
				},
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := du.mutation.RemovedLogsIDs(); len(nodes) > 0 && !du.mutation.LogsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.LogsTable,
			Columns: []string{domain.LogsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: logentry.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := du.mutation.LogsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.LogsTable,
			Columns: []string{domain.LogsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: logentry.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if du.mutation.AccountsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   domain.AccountsTable,
			Columns: domain.AccountsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: account.FieldID,
				},
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := du.mutation.RemovedAccountsIDs(); len(nodes) > 0 && !du.mutation.AccountsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   domain.AccountsTable,
			Columns: domain.AccountsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: account.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := du.mutation.AccountsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   domain.AccountsTable,
			Columns: domain.AccountsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: account.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if n, err = sqlgraph.UpdateNodes(ctx, du.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{domain.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{err.Error(), err}
		}
		return 0, err
	}
	return n, nil
}

// DomainUpdateOne is the builder for updating a single Domain entity.
type DomainUpdateOne struct {
	config
	fields   []string
	hooks    []Hook
	mutation *DomainMutation
}

// SetModified sets the "modified" field.
func (duo *DomainUpdateOne) SetModified(t time.Time) *DomainUpdateOne {
	duo.mutation.SetModified(t)
	return duo
}

// ClearModified clears the value of the "modified" field.
func (duo *DomainUpdateOne) ClearModified() *DomainUpdateOne {
	duo.mutation.ClearModified()
	return duo
}

// SetDomain sets the "domain" field.
func (duo *DomainUpdateOne) SetDomain(s string) *DomainUpdateOne {
	duo.mutation.SetDomain(s)
	return duo
}

// SetDescription sets the "description" field.
func (duo *DomainUpdateOne) SetDescription(s string) *DomainUpdateOne {
	duo.mutation.SetDescription(s)
	return duo
}

// SetNillableDescription sets the "description" field if the given value is not nil.
func (duo *DomainUpdateOne) SetNillableDescription(s *string) *DomainUpdateOne {
	if s != nil {
		duo.SetDescription(*s)
	}
	return duo
}

// ClearDescription clears the value of the "description" field.
func (duo *DomainUpdateOne) ClearDescription() *DomainUpdateOne {
	duo.mutation.ClearDescription()
	return duo
}

// SetMaxAliases sets the "max_aliases" field.
func (duo *DomainUpdateOne) SetMaxAliases(i int64) *DomainUpdateOne {
	duo.mutation.ResetMaxAliases()
	duo.mutation.SetMaxAliases(i)
	return duo
}

// AddMaxAliases adds i to the "max_aliases" field.
func (duo *DomainUpdateOne) AddMaxAliases(i int64) *DomainUpdateOne {
	duo.mutation.AddMaxAliases(i)
	return duo
}

// SetMaxMailboxes sets the "max_mailboxes" field.
func (duo *DomainUpdateOne) SetMaxMailboxes(i int64) *DomainUpdateOne {
	duo.mutation.ResetMaxMailboxes()
	duo.mutation.SetMaxMailboxes(i)
	return duo
}

// AddMaxMailboxes adds i to the "max_mailboxes" field.
func (duo *DomainUpdateOne) AddMaxMailboxes(i int64) *DomainUpdateOne {
	duo.mutation.AddMaxMailboxes(i)
	return duo
}

// SetMaxQuota sets the "max_quota" field.
func (duo *DomainUpdateOne) SetMaxQuota(i int64) *DomainUpdateOne {
	duo.mutation.ResetMaxQuota()
	duo.mutation.SetMaxQuota(i)
	return duo
}

// AddMaxQuota adds i to the "max_quota" field.
func (duo *DomainUpdateOne) AddMaxQuota(i int64) *DomainUpdateOne {
	duo.mutation.AddMaxQuota(i)
	return duo
}

// SetQuota sets the "quota" field.
func (duo *DomainUpdateOne) SetQuota(i int64) *DomainUpdateOne {
	duo.mutation.ResetQuota()
	duo.mutation.SetQuota(i)
	return duo
}

// AddQuota adds i to the "quota" field.
func (duo *DomainUpdateOne) AddQuota(i int64) *DomainUpdateOne {
	duo.mutation.AddQuota(i)
	return duo
}

// SetTransport sets the "transport" field.
func (duo *DomainUpdateOne) SetTransport(s string) *DomainUpdateOne {
	duo.mutation.SetTransport(s)
	return duo
}

// SetBackupMx sets the "backup_mx" field.
func (duo *DomainUpdateOne) SetBackupMx(b bool) *DomainUpdateOne {
	duo.mutation.SetBackupMx(b)
	return duo
}

// SetActive sets the "active" field.
func (duo *DomainUpdateOne) SetActive(b bool) *DomainUpdateOne {
	duo.mutation.SetActive(b)
	return duo
}

// AddMailboxIDs adds the "mailboxes" edge to the Mailbox entity by IDs.
func (duo *DomainUpdateOne) AddMailboxIDs(ids ...int64) *DomainUpdateOne {
	duo.mutation.AddMailboxIDs(ids...)
	return duo
}

// AddMailboxes adds the "mailboxes" edges to the Mailbox entity.
func (duo *DomainUpdateOne) AddMailboxes(m ...*Mailbox) *DomainUpdateOne {
	ids := make([]int64, len(m))
	for i := range m {
		ids[i] = m[i].ID
	}
	return duo.AddMailboxIDs(ids...)
}

// AddAliasIDs adds the "aliases" edge to the Alias entity by IDs.
func (duo *DomainUpdateOne) AddAliasIDs(ids ...int64) *DomainUpdateOne {
	duo.mutation.AddAliasIDs(ids...)
	return duo
}

// AddAliases adds the "aliases" edges to the Alias entity.
func (duo *DomainUpdateOne) AddAliases(a ...*Alias) *DomainUpdateOne {
	ids := make([]int64, len(a))
	for i := range a {
		ids[i] = a[i].ID
	}
	return duo.AddAliasIDs(ids...)
}

// AddLogIDs adds the "logs" edge to the Logentry entity by IDs.
func (duo *DomainUpdateOne) AddLogIDs(ids ...int64) *DomainUpdateOne {
	duo.mutation.AddLogIDs(ids...)
	return duo
}

// AddLogs adds the "logs" edges to the Logentry entity.
func (duo *DomainUpdateOne) AddLogs(l ...*Logentry) *DomainUpdateOne {
	ids := make([]int64, len(l))
	for i := range l {
		ids[i] = l[i].ID
	}
	return duo.AddLogIDs(ids...)
}

// AddAccountIDs adds the "accounts" edge to the Account entity by IDs.
func (duo *DomainUpdateOne) AddAccountIDs(ids ...int64) *DomainUpdateOne {
	duo.mutation.AddAccountIDs(ids...)
	return duo
}

// AddAccounts adds the "accounts" edges to the Account entity.
func (duo *DomainUpdateOne) AddAccounts(a ...*Account) *DomainUpdateOne {
	ids := make([]int64, len(a))
	for i := range a {
		ids[i] = a[i].ID
	}
	return duo.AddAccountIDs(ids...)
}

// Mutation returns the DomainMutation object of the builder.
func (duo *DomainUpdateOne) Mutation() *DomainMutation {
	return duo.mutation
}

// ClearMailboxes clears all "mailboxes" edges to the Mailbox entity.
func (duo *DomainUpdateOne) ClearMailboxes() *DomainUpdateOne {
	duo.mutation.ClearMailboxes()
	return duo
}

// RemoveMailboxIDs removes the "mailboxes" edge to Mailbox entities by IDs.
func (duo *DomainUpdateOne) RemoveMailboxIDs(ids ...int64) *DomainUpdateOne {
	duo.mutation.RemoveMailboxIDs(ids...)
	return duo
}

// RemoveMailboxes removes "mailboxes" edges to Mailbox entities.
func (duo *DomainUpdateOne) RemoveMailboxes(m ...*Mailbox) *DomainUpdateOne {
	ids := make([]int64, len(m))
	for i := range m {
		ids[i] = m[i].ID
	}
	return duo.RemoveMailboxIDs(ids...)
}

// ClearAliases clears all "aliases" edges to the Alias entity.
func (duo *DomainUpdateOne) ClearAliases() *DomainUpdateOne {
	duo.mutation.ClearAliases()
	return duo
}

// RemoveAliasIDs removes the "aliases" edge to Alias entities by IDs.
func (duo *DomainUpdateOne) RemoveAliasIDs(ids ...int64) *DomainUpdateOne {
	duo.mutation.RemoveAliasIDs(ids...)
	return duo
}

// RemoveAliases removes "aliases" edges to Alias entities.
func (duo *DomainUpdateOne) RemoveAliases(a ...*Alias) *DomainUpdateOne {
	ids := make([]int64, len(a))
	for i := range a {
		ids[i] = a[i].ID
	}
	return duo.RemoveAliasIDs(ids...)
}

// ClearLogs clears all "logs" edges to the Logentry entity.
func (duo *DomainUpdateOne) ClearLogs() *DomainUpdateOne {
	duo.mutation.ClearLogs()
	return duo
}

// RemoveLogIDs removes the "logs" edge to Logentry entities by IDs.
func (duo *DomainUpdateOne) RemoveLogIDs(ids ...int64) *DomainUpdateOne {
	duo.mutation.RemoveLogIDs(ids...)
	return duo
}

// RemoveLogs removes "logs" edges to Logentry entities.
func (duo *DomainUpdateOne) RemoveLogs(l ...*Logentry) *DomainUpdateOne {
	ids := make([]int64, len(l))
	for i := range l {
		ids[i] = l[i].ID
	}
	return duo.RemoveLogIDs(ids...)
}

// ClearAccounts clears all "accounts" edges to the Account entity.
func (duo *DomainUpdateOne) ClearAccounts() *DomainUpdateOne {
	duo.mutation.ClearAccounts()
	return duo
}

// RemoveAccountIDs removes the "accounts" edge to Account entities by IDs.
func (duo *DomainUpdateOne) RemoveAccountIDs(ids ...int64) *DomainUpdateOne {
	duo.mutation.RemoveAccountIDs(ids...)
	return duo
}

// RemoveAccounts removes "accounts" edges to Account entities.
func (duo *DomainUpdateOne) RemoveAccounts(a ...*Account) *DomainUpdateOne {
	ids := make([]int64, len(a))
	for i := range a {
		ids[i] = a[i].ID
	}
	return duo.RemoveAccountIDs(ids...)
}

// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (duo *DomainUpdateOne) Select(field string, fields ...string) *DomainUpdateOne {
	duo.fields = append([]string{field}, fields...)
	return duo
}

// Save executes the query and returns the updated Domain entity.
func (duo *DomainUpdateOne) Save(ctx context.Context) (*Domain, error) {
	var (
		err  error
		node *Domain
	)
	duo.defaults()
	if len(duo.hooks) == 0 {
		node, err = duo.sqlSave(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*DomainMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			duo.mutation = mutation
			node, err = duo.sqlSave(ctx)
			mutation.done = true
			return node, err
		})
		for i := len(duo.hooks) - 1; i >= 0; i-- {
			if duo.hooks[i] == nil {
				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
			}
			mut = duo.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, duo.mutation); err != nil {
			return nil, err
		}
	}
	return node, err
}

// SaveX is like Save, but panics if an error occurs.
func (duo *DomainUpdateOne) SaveX(ctx context.Context) *Domain {
	node, err := duo.Save(ctx)
	if err != nil {
		panic(err)
	}
	return node
}

// Exec executes the query on the entity.
func (duo *DomainUpdateOne) Exec(ctx context.Context) error {
	_, err := duo.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (duo *DomainUpdateOne) ExecX(ctx context.Context) {
	if err := duo.Exec(ctx); err != nil {
		panic(err)
	}
}

// defaults sets the default values of the builder before save.
func (duo *DomainUpdateOne) defaults() {
	if _, ok := duo.mutation.Modified(); !ok && !duo.mutation.ModifiedCleared() {
		v := domain.UpdateDefaultModified()
		duo.mutation.SetModified(v)
	}
}

func (duo *DomainUpdateOne) sqlSave(ctx context.Context) (_node *Domain, err error) {
	_spec := &sqlgraph.UpdateSpec{
		Node: &sqlgraph.NodeSpec{
			Table:   domain.Table,
			Columns: domain.Columns,
			ID: &sqlgraph.FieldSpec{
				Type:   field.TypeInt64,
				Column: domain.FieldID,
			},
		},
	}
	id, ok := duo.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Domain.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := duo.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, domain.FieldID)
		for _, f := range fields {
			if !domain.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != domain.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := duo.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := duo.mutation.Modified(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeTime,
			Value:  value,
			Column: domain.FieldModified,
		})
	}
	if duo.mutation.ModifiedCleared() {
		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
			Type:   field.TypeTime,
			Column: domain.FieldModified,
		})
	}
	if value, ok := duo.mutation.Domain(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeString,
			Value:  value,
			Column: domain.FieldDomain,
		})
	}
	if value, ok := duo.mutation.Description(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeString,
			Value:  value,
			Column: domain.FieldDescription,
		})
	}
	if duo.mutation.DescriptionCleared() {
		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
			Type:   field.TypeString,
			Column: domain.FieldDescription,
		})
	}
	if value, ok := duo.mutation.MaxAliases(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldMaxAliases,
		})
	}
	if value, ok := duo.mutation.AddedMaxAliases(); ok {
		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldMaxAliases,
		})
	}
	if value, ok := duo.mutation.MaxMailboxes(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldMaxMailboxes,
		})
	}
	if value, ok := duo.mutation.AddedMaxMailboxes(); ok {
		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldMaxMailboxes,
		})
	}
	if value, ok := duo.mutation.MaxQuota(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldMaxQuota,
		})
	}
	if value, ok := duo.mutation.AddedMaxQuota(); ok {
		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldMaxQuota,
		})
	}
	if value, ok := duo.mutation.Quota(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldQuota,
		})
	}
	if value, ok := duo.mutation.AddedQuota(); ok {
		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
			Type:   field.TypeInt64,
			Value:  value,
			Column: domain.FieldQuota,
		})
	}
	if value, ok := duo.mutation.Transport(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeString,
			Value:  value,
			Column: domain.FieldTransport,
		})
	}
	if value, ok := duo.mutation.BackupMx(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeBool,
			Value:  value,
			Column: domain.FieldBackupMx,
		})
	}
	if value, ok := duo.mutation.Active(); ok {
		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
			Type:   field.TypeBool,
			Value:  value,
			Column: domain.FieldActive,
		})
	}
	if duo.mutation.MailboxesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.MailboxesTable,
			Columns: []string{domain.MailboxesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: mailbox.FieldID,
				},
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := duo.mutation.RemovedMailboxesIDs(); len(nodes) > 0 && !duo.mutation.MailboxesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.MailboxesTable,
			Columns: []string{domain.MailboxesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: mailbox.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := duo.mutation.MailboxesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.MailboxesTable,
			Columns: []string{domain.MailboxesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: mailbox.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if duo.mutation.AliasesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.AliasesTable,
			Columns: []string{domain.AliasesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: alias.FieldID,
				},
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := duo.mutation.RemovedAliasesIDs(); len(nodes) > 0 && !duo.mutation.AliasesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.AliasesTable,
			Columns: []string{domain.AliasesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: alias.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := duo.mutation.AliasesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.AliasesTable,
			Columns: []string{domain.AliasesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: alias.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if duo.mutation.LogsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.LogsTable,
			Columns: []string{domain.LogsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: logentry.FieldID,
				},
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := duo.mutation.RemovedLogsIDs(); len(nodes) > 0 && !duo.mutation.LogsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.LogsTable,
			Columns: []string{domain.LogsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: logentry.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := duo.mutation.LogsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   domain.LogsTable,
			Columns: []string{domain.LogsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: logentry.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if duo.mutation.AccountsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   domain.AccountsTable,
			Columns: domain.AccountsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: account.FieldID,
				},
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := duo.mutation.RemovedAccountsIDs(); len(nodes) > 0 && !duo.mutation.AccountsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   domain.AccountsTable,
			Columns: domain.AccountsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: account.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := duo.mutation.AccountsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   domain.AccountsTable,
			Columns: domain.AccountsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt64,
					Column: account.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	_node = &Domain{config: duo.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, duo.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{domain.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{err.Error(), err}
		}
		return nil, err
	}
	return _node, nil
}
