func (m *AttachmentMutation) Type() string {
	return m.typ
}
Type returns the node type of this mutation (Attachment).
package ent
import (
	"context"
	"fmt"
	"sync"
	"time"
	"entgo.io/contrib/entproto/internal/todo/ent/attachment"
	"entgo.io/contrib/entproto/internal/todo/ent/group"
	"entgo.io/contrib/entproto/internal/todo/ent/nilexample"
	"entgo.io/contrib/entproto/internal/todo/ent/predicate"
	"entgo.io/contrib/entproto/internal/todo/ent/schema"
	"entgo.io/contrib/entproto/internal/todo/ent/todo"
	"entgo.io/contrib/entproto/internal/todo/ent/user"
	"github.com/google/uuid"
	"entgo.io/ent"
)
const (
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne
	TypeAttachment = "Attachment"
	TypeGroup      = "Group"
	TypeNilExample = "NilExample"
	TypeTodo       = "Todo"
	TypeUser       = "User"
)
type AttachmentMutation struct {
	config
	op                Op
	typ               string
	id                *uuid.UUID
	clearedFields     map[string]struct{}
	user              *int
	cleareduser       bool
	recipients        map[int]struct{}
	removedrecipients map[int]struct{}
	clearedrecipients bool
	done              bool
	oldValue          func(context.Context) (*Attachment, error)
	predicates        []predicate.Attachment
}
var _ ent.Mutation = (*AttachmentMutation)(nil)
type attachmentOption func(*AttachmentMutation)
func newAttachmentMutation(c config, op Op, opts ...attachmentOption) *AttachmentMutation {
	m := &AttachmentMutation{
		config:        c,
		op:            op,
		typ:           TypeAttachment,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}
func withAttachmentID(id uuid.UUID) attachmentOption {
	return func(m *AttachmentMutation) {
		var (
			err   error
			once  sync.Once
			value *Attachment
		)
		m.oldValue = func(ctx context.Context) (*Attachment, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Attachment.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}
func withAttachment(node *Attachment) attachmentOption {
	return func(m *AttachmentMutation) {
		m.oldValue = func(context.Context) (*Attachment, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}
func (m AttachmentMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}
func (m AttachmentMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}
func (m *AttachmentMutation) SetID(id uuid.UUID) {
	m.id = &id
}
func (m *AttachmentMutation) ID() (id uuid.UUID, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}
func (m *AttachmentMutation) SetUserID(id int) {
	m.user = &id
}
func (m *AttachmentMutation) ClearUser() {
	m.cleareduser = true
}
func (m *AttachmentMutation) UserCleared() bool {
	return m.cleareduser
}
func (m *AttachmentMutation) UserID() (id int, exists bool) {
	if m.user != nil {
		return *m.user, true
	}
	return
}
func (m *AttachmentMutation) UserIDs() (ids []int) {
	if id := m.user; id != nil {
		ids = append(ids, *id)
	}
	return
}
func (m *AttachmentMutation) ResetUser() {
	m.user = nil
	m.cleareduser = false
}
func (m *AttachmentMutation) AddRecipientIDs(ids ...int) {
	if m.recipients == nil {
		m.recipients = make(map[int]struct{})
	}
	for i := range ids {
		m.recipients[ids[i]] = struct{}{}
	}
}
func (m *AttachmentMutation) ClearRecipients() {
	m.clearedrecipients = true
}
func (m *AttachmentMutation) RecipientsCleared() bool {
	return m.clearedrecipients
}
func (m *AttachmentMutation) RemoveRecipientIDs(ids ...int) {
	if m.removedrecipients == nil {
		m.removedrecipients = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.recipients, ids[i])
		m.removedrecipients[ids[i]] = struct{}{}
	}
}
func (m *AttachmentMutation) RemovedRecipientsIDs() (ids []int) {
	for id := range m.removedrecipients {
		ids = append(ids, id)
	}
	return
}
func (m *AttachmentMutation) RecipientsIDs() (ids []int) {
	for id := range m.recipients {
		ids = append(ids, id)
	}
	return
}
func (m *AttachmentMutation) ResetRecipients() {
	m.recipients = nil
	m.clearedrecipients = false
	m.removedrecipients = nil
}
func (m *AttachmentMutation) Where(ps ...predicate.Attachment) {
	m.predicates = append(m.predicates, ps...)
}
func (m *AttachmentMutation) Op() Op {
	return m.op
}