func (m *FileMutation) ClearEdge(name string) error {
	return fmt.Errorf("unknown File unique edge %s", name)
}
ClearEdge clears the value of the edge with the given name. It returns an error
if that edge is not defined in the schema.
package ent
import (
	"context"
	"fmt"
	"sync"
	"entgo.io/contrib/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment"
	"entgo.io/contrib/entproto/cmd/protoc-gen-ent/internal/todo/ent/file"
	"entgo.io/contrib/entproto/cmd/protoc-gen-ent/internal/todo/ent/predicate"
	"entgo.io/contrib/entproto/cmd/protoc-gen-ent/internal/todo/ent/task"
	"entgo.io/contrib/entproto/cmd/protoc-gen-ent/internal/todo/ent/user"
	"entgo.io/ent"
)
const (
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne
	TypeAttachment = "Attachment"
	TypeFile       = "File"
	TypeTask       = "Task"
	TypeUser       = "User"
)
type AttachmentMutation struct {
	config
	op            Op
	typ           string
	id            *string
	contents      *string
	clearedFields map[string]struct{}
	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 string) 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 string) {
	m.id = &id
}
func (m *AttachmentMutation) ID() (id string, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}
func (m *AttachmentMutation) SetContents(s string) {
	m.contents = &s
}
func (m *AttachmentMutation) Contents() (r string, exists bool) {
	v := m.contents
	if v == nil {
		return
	}
	return *v, true
}
func (m *AttachmentMutation) OldContents(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldContents is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldContents requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldContents: %w", err)
	}
	return oldValue.Contents, nil
}
func (m *AttachmentMutation) ResetContents() {
	m.contents = 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, 1)
	if m.contents != nil {
		fields = append(fields, attachment.FieldContents)
	}
	return fields
}
func (m *AttachmentMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case attachment.FieldContents:
		return m.Contents()
	}
	return nil, false
}
func (m *AttachmentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case attachment.FieldContents:
		return m.OldContents(ctx)
	}
	return nil, fmt.Errorf("unknown Attachment field %s", name)
}
func (m *AttachmentMutation) SetField(name string, value ent.Value) error {
	switch name {
	case attachment.FieldContents:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetContents(v)
		return nil
	}
	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 {
	switch name {
	}
	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 {
	switch name {
	case attachment.FieldContents:
		m.ResetContents()
		return nil
	}
	return fmt.Errorf("unknown Attachment field %s", name)
}
func (m *AttachmentMutation) AddedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}
func (m *AttachmentMutation) AddedIDs(name string) []ent.Value {
	return nil
}
func (m *AttachmentMutation) RemovedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}
func (m *AttachmentMutation) RemovedIDs(name string) []ent.Value {
	return nil
}
func (m *AttachmentMutation) ClearedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}
func (m *AttachmentMutation) EdgeCleared(name string) bool {
	return false
}
func (m *AttachmentMutation) ClearEdge(name string) error {
	return fmt.Errorf("unknown Attachment unique edge %s", name)
}
func (m *AttachmentMutation) ResetEdge(name string) error {
	return fmt.Errorf("unknown Attachment edge %s", name)
}
type FileMutation struct {
	config
	op            Op
	typ           string
	id            *string
	contents      *string
	clearedFields map[string]struct{}
	done          bool
	oldValue      func(context.Context) (*File, error)
	predicates    []predicate.File
}
var _ ent.Mutation = (*FileMutation)(nil)
type fileOption func(*FileMutation)
func newFileMutation(c config, op Op, opts ...fileOption) *FileMutation {
	m := &FileMutation{
		config:        c,
		op:            op,
		typ:           TypeFile,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}
func withFileID(id string) fileOption {
	return func(m *FileMutation) {
		var (
			err   error
			once  sync.Once
			value *File
		)
		m.oldValue = func(ctx context.Context) (*File, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().File.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}
func withFile(node *File) fileOption {
	return func(m *FileMutation) {
		m.oldValue = func(context.Context) (*File, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}
func (m FileMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}
func (m FileMutation) 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 *FileMutation) SetID(id string) {
	m.id = &id
}
func (m *FileMutation) ID() (id string, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}
func (m *FileMutation) SetContents(s string) {
	m.contents = &s
}
func (m *FileMutation) Contents() (r string, exists bool) {
	v := m.contents
	if v == nil {
		return
	}
	return *v, true
}
func (m *FileMutation) OldContents(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldContents is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldContents requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldContents: %w", err)
	}
	return oldValue.Contents, nil
}
func (m *FileMutation) ResetContents() {
	m.contents = nil
}
func (m *FileMutation) Where(ps ...predicate.File) {
	m.predicates = append(m.predicates, ps...)
}
func (m *FileMutation) Op() Op {
	return m.op
}
func (m *FileMutation) Type() string {
	return m.typ
}
func (m *FileMutation) Fields() []string {
	fields := make([]string, 0, 1)
	if m.contents != nil {
		fields = append(fields, file.FieldContents)
	}
	return fields
}
func (m *FileMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case file.FieldContents:
		return m.Contents()
	}
	return nil, false
}
func (m *FileMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case file.FieldContents:
		return m.OldContents(ctx)
	}
	return nil, fmt.Errorf("unknown File field %s", name)
}
func (m *FileMutation) SetField(name string, value ent.Value) error {
	switch name {
	case file.FieldContents:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetContents(v)
		return nil
	}
	return fmt.Errorf("unknown File field %s", name)
}
func (m *FileMutation) AddedFields() []string {
	return nil
}
func (m *FileMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}
func (m *FileMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown File numeric field %s", name)
}
func (m *FileMutation) ClearedFields() []string {
	return nil
}
func (m *FileMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}
func (m *FileMutation) ClearField(name string) error {
	return fmt.Errorf("unknown File nullable field %s", name)
}
func (m *FileMutation) ResetField(name string) error {
	switch name {
	case file.FieldContents:
		m.ResetContents()
		return nil
	}
	return fmt.Errorf("unknown File field %s", name)
}
func (m *FileMutation) AddedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}
func (m *FileMutation) AddedIDs(name string) []ent.Value {
	return nil
}
func (m *FileMutation) RemovedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}
func (m *FileMutation) RemovedIDs(name string) []ent.Value {
	return nil
}
func (m *FileMutation) ClearedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}
func (m *FileMutation) EdgeCleared(name string) bool {
	return false
}