func (auo *AttachmentUpdateOne) RemoveRecipientIDs(ids ...int) *AttachmentUpdateOne {
	auo.mutation.RemoveRecipientIDs(ids...)
	return auo
}
RemoveRecipientIDs removes the "recipients" edge to User entities by IDs.
package ent
import (
	"context"
	"fmt"
	"entgo.io/contrib/entproto/internal/todo/ent/attachment"
	"entgo.io/contrib/entproto/internal/todo/ent/predicate"
	"entgo.io/contrib/entproto/internal/todo/ent/user"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)
type AttachmentUpdate struct {
	config
	hooks    []Hook
	mutation *AttachmentMutation
}
func (au *AttachmentUpdate) Where(ps ...predicate.Attachment) *AttachmentUpdate {
	au.mutation.Where(ps...)
	return au
}
func (au *AttachmentUpdate) SetUserID(id int) *AttachmentUpdate {
	au.mutation.SetUserID(id)
	return au
}
func (au *AttachmentUpdate) SetNillableUserID(id *int) *AttachmentUpdate {
	if id != nil {
		au = au.SetUserID(*id)
	}
	return au
}
func (au *AttachmentUpdate) SetUser(u *User) *AttachmentUpdate {
	return au.SetUserID(u.ID)
}
func (au *AttachmentUpdate) AddRecipientIDs(ids ...int) *AttachmentUpdate {
	au.mutation.AddRecipientIDs(ids...)
	return au
}
func (au *AttachmentUpdate) AddRecipients(u ...*User) *AttachmentUpdate {
	ids := make([]int, len(u))
	for i := range u {
		ids[i] = u[i].ID
	}
	return au.AddRecipientIDs(ids...)
}
func (au *AttachmentUpdate) Mutation() *AttachmentMutation {
	return au.mutation
}
func (au *AttachmentUpdate) ClearUser() *AttachmentUpdate {
	au.mutation.ClearUser()
	return au
}
func (au *AttachmentUpdate) ClearRecipients() *AttachmentUpdate {
	au.mutation.ClearRecipients()
	return au
}
func (au *AttachmentUpdate) RemoveRecipientIDs(ids ...int) *AttachmentUpdate {
	au.mutation.RemoveRecipientIDs(ids...)
	return au
}
func (au *AttachmentUpdate) RemoveRecipients(u ...*User) *AttachmentUpdate {
	ids := make([]int, len(u))
	for i := range u {
		ids[i] = u[i].ID
	}
	return au.RemoveRecipientIDs(ids...)
}
func (au *AttachmentUpdate) Save(ctx context.Context) (int, error) {
	var (
		err      error
		affected int
	)
	if len(au.hooks) == 0 {
		affected, err = au.sqlSave(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*AttachmentMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			au.mutation = mutation
			affected, err = au.sqlSave(ctx)
			mutation.done = true
			return affected, err
		})
		for i := len(au.hooks) - 1; i >= 0; i-- {
			if au.hooks[i] == nil {
				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
			}
			mut = au.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, au.mutation); err != nil {
			return 0, err
		}
	}
	return affected, err
}
func (au *AttachmentUpdate) SaveX(ctx context.Context) int {
	affected, err := au.Save(ctx)
	if err != nil {
		panic(err)
	}
	return affected
}
func (au *AttachmentUpdate) Exec(ctx context.Context) error {
	_, err := au.Save(ctx)
	return err
}
func (au *AttachmentUpdate) ExecX(ctx context.Context) {
	if err := au.Exec(ctx); err != nil {
		panic(err)
	}
}
func (au *AttachmentUpdate) sqlSave(ctx context.Context) (n int, err error) {
	_spec := &sqlgraph.UpdateSpec{
		Node: &sqlgraph.NodeSpec{
			Table:   attachment.Table,
			Columns: attachment.Columns,
			ID: &sqlgraph.FieldSpec{
				Type:   field.TypeUUID,
				Column: attachment.FieldID,
			},
		},
	}
	if ps := au.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if au.mutation.UserCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   attachment.UserTable,
			Columns: []string{attachment.UserColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt,
					Column: user.FieldID,
				},
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := au.mutation.UserIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   attachment.UserTable,
			Columns: []string{attachment.UserColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt,
					Column: user.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if au.mutation.RecipientsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: false,
			Table:   attachment.RecipientsTable,
			Columns: attachment.RecipientsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt,
					Column: user.FieldID,
				},
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := au.mutation.RemovedRecipientsIDs(); len(nodes) > 0 && !au.mutation.RecipientsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: false,
			Table:   attachment.RecipientsTable,
			Columns: attachment.RecipientsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt,
					Column: user.FieldID,
				},
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := au.mutation.RecipientsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: false,
			Table:   attachment.RecipientsTable,
			Columns: attachment.RecipientsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: &sqlgraph.FieldSpec{
					Type:   field.TypeInt,
					Column: user.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, au.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{attachment.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{err.Error(), err}
		}
		return 0, err
	}
	return n, nil
}
type AttachmentUpdateOne struct {
	config
	fields   []string
	hooks    []Hook
	mutation *AttachmentMutation
}
func (auo *AttachmentUpdateOne) SetUserID(id int) *AttachmentUpdateOne {
	auo.mutation.SetUserID(id)
	return auo
}
func (auo *AttachmentUpdateOne) SetNillableUserID(id *int) *AttachmentUpdateOne {
	if id != nil {
		auo = auo.SetUserID(*id)
	}
	return auo
}
func (auo *AttachmentUpdateOne) SetUser(u *User) *AttachmentUpdateOne {
	return auo.SetUserID(u.ID)
}
func (auo *AttachmentUpdateOne) AddRecipientIDs(ids ...int) *AttachmentUpdateOne {
	auo.mutation.AddRecipientIDs(ids...)
	return auo
}
func (auo *AttachmentUpdateOne) AddRecipients(u ...*User) *AttachmentUpdateOne {
	ids := make([]int, len(u))
	for i := range u {
		ids[i] = u[i].ID
	}
	return auo.AddRecipientIDs(ids...)
}
func (auo *AttachmentUpdateOne) Mutation() *AttachmentMutation {
	return auo.mutation
}
func (auo *AttachmentUpdateOne) ClearUser() *AttachmentUpdateOne {
	auo.mutation.ClearUser()
	return auo
}
func (auo *AttachmentUpdateOne) ClearRecipients() *AttachmentUpdateOne {
	auo.mutation.ClearRecipients()
	return auo
}