func (m *BlogPostMutation) AuthorCleared() bool {
	return m.clearedauthor
}
AuthorCleared reports if the "author" edge to the User entity was cleared.
package ent
import (
	"context"
	"fmt"
	"sync"
	"time"
	"entgo.io/contrib/entproto/internal/entprototest/ent/blogpost"
	"entgo.io/contrib/entproto/internal/entprototest/ent/category"
	"entgo.io/contrib/entproto/internal/entprototest/ent/dependsonskipped"
	"entgo.io/contrib/entproto/internal/entprototest/ent/duplicatenumbermessage"
	"entgo.io/contrib/entproto/internal/entprototest/ent/image"
	"entgo.io/contrib/entproto/internal/entprototest/ent/invalidfieldmessage"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithenum"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithfieldone"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithoptionals"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithpackagename"
	"entgo.io/contrib/entproto/internal/entprototest/ent/portal"
	"entgo.io/contrib/entproto/internal/entprototest/ent/predicate"
	"entgo.io/contrib/entproto/internal/entprototest/ent/schema"
	"entgo.io/contrib/entproto/internal/entprototest/ent/user"
	"entgo.io/contrib/entproto/internal/entprototest/ent/validmessage"
	"github.com/google/uuid"
	"entgo.io/ent"
)
const (
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne
	TypeBlogPost               = "BlogPost"
	TypeCategory               = "Category"
	TypeDependsOnSkipped       = "DependsOnSkipped"
	TypeDuplicateNumberMessage = "DuplicateNumberMessage"
	TypeExplicitSkippedMessage = "ExplicitSkippedMessage"
	TypeImage                  = "Image"
	TypeImplicitSkippedMessage = "ImplicitSkippedMessage"
	TypeInvalidFieldMessage    = "InvalidFieldMessage"
	TypeMessageWithEnum        = "MessageWithEnum"
	TypeMessageWithFieldOne    = "MessageWithFieldOne"
	TypeMessageWithID          = "MessageWithID"
	TypeMessageWithOptionals   = "MessageWithOptionals"
	TypeMessageWithPackageName = "MessageWithPackageName"
	TypePortal                 = "Portal"
	TypeUser                   = "User"
	TypeValidMessage           = "ValidMessage"
)
type BlogPostMutation struct {
	config
	op                Op
	typ               string
	id                *int
	title             *string
	body              *string
	external_id       *int
	addexternal_id    *int
	clearedFields     map[string]struct{}
	author            *int
	clearedauthor     bool
	categories        map[int]struct{}
	removedcategories map[int]struct{}
	clearedcategories bool
	done              bool
	oldValue          func(context.Context) (*BlogPost, error)
	predicates        []predicate.BlogPost
}
var _ ent.Mutation = (*BlogPostMutation)(nil)
type blogpostOption func(*BlogPostMutation)
func newBlogPostMutation(c config, op Op, opts ...blogpostOption) *BlogPostMutation {
	m := &BlogPostMutation{
		config:        c,
		op:            op,
		typ:           TypeBlogPost,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}
func withBlogPostID(id int) blogpostOption {
	return func(m *BlogPostMutation) {
		var (
			err   error
			once  sync.Once
			value *BlogPost
		)
		m.oldValue = func(ctx context.Context) (*BlogPost, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().BlogPost.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}
func withBlogPost(node *BlogPost) blogpostOption {
	return func(m *BlogPostMutation) {
		m.oldValue = func(context.Context) (*BlogPost, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}
func (m BlogPostMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}
func (m BlogPostMutation) 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 *BlogPostMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}
func (m *BlogPostMutation) SetTitle(s string) {
	m.title = &s
}
func (m *BlogPostMutation) Title() (r string, exists bool) {
	v := m.title
	if v == nil {
		return
	}
	return *v, true
}
func (m *BlogPostMutation) OldTitle(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldTitle is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldTitle requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldTitle: %w", err)
	}
	return oldValue.Title, nil
}
func (m *BlogPostMutation) ResetTitle() {
	m.title = nil
}
func (m *BlogPostMutation) SetBody(s string) {
	m.body = &s
}
func (m *BlogPostMutation) Body() (r string, exists bool) {
	v := m.body
	if v == nil {
		return
	}
	return *v, true
}
func (m *BlogPostMutation) OldBody(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldBody is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldBody requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldBody: %w", err)
	}
	return oldValue.Body, nil
}
func (m *BlogPostMutation) ResetBody() {
	m.body = nil
}
func (m *BlogPostMutation) SetExternalID(i int) {
	m.external_id = &i
	m.addexternal_id = nil
}
func (m *BlogPostMutation) ExternalID() (r int, exists bool) {
	v := m.external_id
	if v == nil {
		return
	}
	return *v, true
}
func (m *BlogPostMutation) OldExternalID(ctx context.Context) (v int, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldExternalID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldExternalID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldExternalID: %w", err)
	}
	return oldValue.ExternalID, nil
}
func (m *BlogPostMutation) AddExternalID(i int) {
	if m.addexternal_id != nil {
		*m.addexternal_id += i
	} else {
		m.addexternal_id = &i
	}
}
func (m *BlogPostMutation) AddedExternalID() (r int, exists bool) {
	v := m.addexternal_id
	if v == nil {
		return
	}
	return *v, true
}
func (m *BlogPostMutation) ResetExternalID() {
	m.external_id = nil
	m.addexternal_id = nil
}
func (m *BlogPostMutation) SetAuthorID(id int) {
	m.author = &id
}
func (m *BlogPostMutation) ClearAuthor() {
	m.clearedauthor = true
}