func (m *GroupMutation) UsersCleared() bool {
	return m.clearedusers
}
UsersCleared reports if the "users" edge to the User entity was cleared.
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
}
func (m *AttachmentMutation) Type() string {
	return m.typ
}
func (m *AttachmentMutation) Fields() []string {
	fields := make([]string, 0, 0)
	return fields
}
func (m *AttachmentMutation) Field(name string) (ent.Value, bool) {
	return nil, false
}
func (m *AttachmentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	return nil, fmt.Errorf("unknown Attachment field %s", name)
}
func (m *AttachmentMutation) SetField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown Attachment field %s", name)
}
func (m *AttachmentMutation) AddedFields() []string {
	return nil
}
func (m *AttachmentMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}
func (m *AttachmentMutation) AddField(name string, value ent.Value) error {
	return fmt.Errorf("unknown Attachment numeric field %s", name)
}
func (m *AttachmentMutation) ClearedFields() []string {
	return nil
}
func (m *AttachmentMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}
func (m *AttachmentMutation) ClearField(name string) error {
	return fmt.Errorf("unknown Attachment nullable field %s", name)
}
func (m *AttachmentMutation) ResetField(name string) error {
	return fmt.Errorf("unknown Attachment field %s", name)
}
func (m *AttachmentMutation) AddedEdges() []string {
	edges := make([]string, 0, 2)
	if m.user != nil {
		edges = append(edges, attachment.EdgeUser)
	}
	if m.recipients != nil {
		edges = append(edges, attachment.EdgeRecipients)
	}
	return edges
}
func (m *AttachmentMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case attachment.EdgeUser:
		if id := m.user; id != nil {
			return []ent.Value{*id}
		}
	case attachment.EdgeRecipients:
		ids := make([]ent.Value, 0, len(m.recipients))
		for id := range m.recipients {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}
func (m *AttachmentMutation) RemovedEdges() []string {
	edges := make([]string, 0, 2)
	if m.removedrecipients != nil {
		edges = append(edges, attachment.EdgeRecipients)
	}
	return edges
}
func (m *AttachmentMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case attachment.EdgeRecipients:
		ids := make([]ent.Value, 0, len(m.removedrecipients))
		for id := range m.removedrecipients {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}
func (m *AttachmentMutation) ClearedEdges() []string {
	edges := make([]string, 0, 2)
	if m.cleareduser {
		edges = append(edges, attachment.EdgeUser)
	}
	if m.clearedrecipients {
		edges = append(edges, attachment.EdgeRecipients)
	}
	return edges
}
func (m *AttachmentMutation) EdgeCleared(name string) bool {
	switch name {
	case attachment.EdgeUser:
		return m.cleareduser
	case attachment.EdgeRecipients:
		return m.clearedrecipients
	}
	return false
}
func (m *AttachmentMutation) ClearEdge(name string) error {
	switch name {
	case attachment.EdgeUser:
		m.ClearUser()
		return nil
	}
	return fmt.Errorf("unknown Attachment unique edge %s", name)
}
func (m *AttachmentMutation) ResetEdge(name string) error {
	switch name {
	case attachment.EdgeUser:
		m.ResetUser()
		return nil
	case attachment.EdgeRecipients:
		m.ResetRecipients()
		return nil
	}
	return fmt.Errorf("unknown Attachment edge %s", name)
}
type GroupMutation struct {
	config
	op            Op
	typ           string
	id            *int
	name          *string
	clearedFields map[string]struct{}
	users         map[int]struct{}
	removedusers  map[int]struct{}
	clearedusers  bool
	done          bool
	oldValue      func(context.Context) (*Group, error)
	predicates    []predicate.Group
}
var _ ent.Mutation = (*GroupMutation)(nil)
type groupOption func(*GroupMutation)
func newGroupMutation(c config, op Op, opts ...groupOption) *GroupMutation {
	m := &GroupMutation{
		config:        c,
		op:            op,
		typ:           TypeGroup,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}
func withGroupID(id int) groupOption {
	return func(m *GroupMutation) {
		var (
			err   error
			once  sync.Once
			value *Group
		)
		m.oldValue = func(ctx context.Context) (*Group, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Group.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}
func withGroup(node *Group) groupOption {
	return func(m *GroupMutation) {
		m.oldValue = func(context.Context) (*Group, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}
func (m GroupMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}
func (m GroupMutation) 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 *GroupMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}
func (m *GroupMutation) SetName(s string) {
	m.name = &s
}
func (m *GroupMutation) Name() (r string, exists bool) {
	v := m.name
	if v == nil {
		return
	}
	return *v, true
}
func (m *GroupMutation) OldName(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldName is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldName requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldName: %w", err)
	}
	return oldValue.Name, nil
}
func (m *GroupMutation) ResetName() {
	m.name = nil
}
func (m *GroupMutation) AddUserIDs(ids ...int) {
	if m.users == nil {
		m.users = make(map[int]struct{})
	}
	for i := range ids {
		m.users[ids[i]] = struct{}{}
	}
}
func (m *GroupMutation) ClearUsers() {
	m.clearedusers = true
}