// Code generated by ent, DO NOT EDIT.

package models

import (
	"context"
	"errors"
	"fmt"
	"juwan-backend/app/community/rpc/internal/models/commentlikes"
	"juwan-backend/app/community/rpc/internal/models/comments"
	"juwan-backend/app/community/rpc/internal/models/postlikes"
	"juwan-backend/app/community/rpc/internal/models/posts"
	"juwan-backend/app/community/rpc/internal/models/predicate"
	"juwan-backend/pkg/types"
	"sync"
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect/sql"
)

const (
	// Operation types.
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne

	// Node types.
	TypeCommentLikes = "CommentLikes"
	TypeComments     = "Comments"
	TypePostLikes    = "PostLikes"
	TypePosts        = "Posts"
)

// CommentLikesMutation represents an operation that mutates the CommentLikes nodes in the graph.
type CommentLikesMutation struct {
	config
	op            Op
	typ           string
	id            *int64
	comment_id    *int64
	addcomment_id *int64
	user_id       *int64
	adduser_id    *int64
	created_at    *time.Time
	clearedFields map[string]struct{}
	done          bool
	oldValue      func(context.Context) (*CommentLikes, error)
	predicates    []predicate.CommentLikes
}

var _ ent.Mutation = (*CommentLikesMutation)(nil)

// commentlikesOption allows management of the mutation configuration using functional options.
type commentlikesOption func(*CommentLikesMutation)

// newCommentLikesMutation creates new mutation for the CommentLikes entity.
func newCommentLikesMutation(c config, op Op, opts ...commentlikesOption) *CommentLikesMutation {
	m := &CommentLikesMutation{
		config:        c,
		op:            op,
		typ:           TypeCommentLikes,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withCommentLikesID sets the ID field of the mutation.
func withCommentLikesID(id int64) commentlikesOption {
	return func(m *CommentLikesMutation) {
		var (
			err   error
			once  sync.Once
			value *CommentLikes
		)
		m.oldValue = func(ctx context.Context) (*CommentLikes, error) {
			once.Do(func() {
				if m.done {
					err = errors.New("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().CommentLikes.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withCommentLikes sets the old CommentLikes of the mutation.
func withCommentLikes(node *CommentLikes) commentlikesOption {
	return func(m *CommentLikesMutation) {
		m.oldValue = func(context.Context) (*CommentLikes, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m CommentLikesMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m CommentLikesMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, errors.New("models: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of CommentLikes entities.
func (m *CommentLikesMutation) SetID(id int64) {
	m.id = &id
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *CommentLikesMutation) ID() (id int64, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *CommentLikesMutation) IDs(ctx context.Context) ([]int64, error) {
	switch {
	case m.op.Is(OpUpdateOne | OpDeleteOne):
		id, exists := m.ID()
		if exists {
			return []int64{id}, nil
		}
		fallthrough
	case m.op.Is(OpUpdate | OpDelete):
		return m.Client().CommentLikes.Query().Where(m.predicates...).IDs(ctx)
	default:
		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
	}
}

// SetCommentID sets the "comment_id" field.
func (m *CommentLikesMutation) SetCommentID(i int64) {
	m.comment_id = &i
	m.addcomment_id = nil
}

// CommentID returns the value of the "comment_id" field in the mutation.
func (m *CommentLikesMutation) CommentID() (r int64, exists bool) {
	v := m.comment_id
	if v == nil {
		return
	}
	return *v, true
}

// OldCommentID returns the old "comment_id" field's value of the CommentLikes entity.
// If the CommentLikes object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CommentLikesMutation) OldCommentID(ctx context.Context) (v int64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCommentID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCommentID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCommentID: %w", err)
	}
	return oldValue.CommentID, nil
}

// AddCommentID adds i to the "comment_id" field.
func (m *CommentLikesMutation) AddCommentID(i int64) {
	if m.addcomment_id != nil {
		*m.addcomment_id += i
	} else {
		m.addcomment_id = &i
	}
}

// AddedCommentID returns the value that was added to the "comment_id" field in this mutation.
func (m *CommentLikesMutation) AddedCommentID() (r int64, exists bool) {
	v := m.addcomment_id
	if v == nil {
		return
	}
	return *v, true
}

// ResetCommentID resets all changes to the "comment_id" field.
func (m *CommentLikesMutation) ResetCommentID() {
	m.comment_id = nil
	m.addcomment_id = nil
}

// SetUserID sets the "user_id" field.
func (m *CommentLikesMutation) SetUserID(i int64) {
	m.user_id = &i
	m.adduser_id = nil
}

// UserID returns the value of the "user_id" field in the mutation.
func (m *CommentLikesMutation) UserID() (r int64, exists bool) {
	v := m.user_id
	if v == nil {
		return
	}
	return *v, true
}

// OldUserID returns the old "user_id" field's value of the CommentLikes entity.
// If the CommentLikes object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CommentLikesMutation) OldUserID(ctx context.Context) (v int64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUserID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUserID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUserID: %w", err)
	}
	return oldValue.UserID, nil
}

// AddUserID adds i to the "user_id" field.
func (m *CommentLikesMutation) AddUserID(i int64) {
	if m.adduser_id != nil {
		*m.adduser_id += i
	} else {
		m.adduser_id = &i
	}
}

// AddedUserID returns the value that was added to the "user_id" field in this mutation.
func (m *CommentLikesMutation) AddedUserID() (r int64, exists bool) {
	v := m.adduser_id
	if v == nil {
		return
	}
	return *v, true
}

// ResetUserID resets all changes to the "user_id" field.
func (m *CommentLikesMutation) ResetUserID() {
	m.user_id = nil
	m.adduser_id = nil
}

// SetCreatedAt sets the "created_at" field.
func (m *CommentLikesMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *CommentLikesMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the CommentLikes entity.
// If the CommentLikes object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CommentLikesMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *CommentLikesMutation) ResetCreatedAt() {
	m.created_at = nil
}

// Where appends a list predicates to the CommentLikesMutation builder.
func (m *CommentLikesMutation) Where(ps ...predicate.CommentLikes) {
	m.predicates = append(m.predicates, ps...)
}

// WhereP appends storage-level predicates to the CommentLikesMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *CommentLikesMutation) WhereP(ps ...func(*sql.Selector)) {
	p := make([]predicate.CommentLikes, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	m.Where(p...)
}

// Op returns the operation name.
func (m *CommentLikesMutation) Op() Op {
	return m.op
}

// SetOp allows setting the mutation operation.
func (m *CommentLikesMutation) SetOp(op Op) {
	m.op = op
}

// Type returns the node type of this mutation (CommentLikes).
func (m *CommentLikesMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *CommentLikesMutation) Fields() []string {
	fields := make([]string, 0, 3)
	if m.comment_id != nil {
		fields = append(fields, commentlikes.FieldCommentID)
	}
	if m.user_id != nil {
		fields = append(fields, commentlikes.FieldUserID)
	}
	if m.created_at != nil {
		fields = append(fields, commentlikes.FieldCreatedAt)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *CommentLikesMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case commentlikes.FieldCommentID:
		return m.CommentID()
	case commentlikes.FieldUserID:
		return m.UserID()
	case commentlikes.FieldCreatedAt:
		return m.CreatedAt()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *CommentLikesMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case commentlikes.FieldCommentID:
		return m.OldCommentID(ctx)
	case commentlikes.FieldUserID:
		return m.OldUserID(ctx)
	case commentlikes.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	}
	return nil, fmt.Errorf("unknown CommentLikes field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *CommentLikesMutation) SetField(name string, value ent.Value) error {
	switch name {
	case commentlikes.FieldCommentID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCommentID(v)
		return nil
	case commentlikes.FieldUserID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUserID(v)
		return nil
	case commentlikes.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	}
	return fmt.Errorf("unknown CommentLikes field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *CommentLikesMutation) AddedFields() []string {
	var fields []string
	if m.addcomment_id != nil {
		fields = append(fields, commentlikes.FieldCommentID)
	}
	if m.adduser_id != nil {
		fields = append(fields, commentlikes.FieldUserID)
	}
	return fields
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *CommentLikesMutation) AddedField(name string) (ent.Value, bool) {
	switch name {
	case commentlikes.FieldCommentID:
		return m.AddedCommentID()
	case commentlikes.FieldUserID:
		return m.AddedUserID()
	}
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *CommentLikesMutation) AddField(name string, value ent.Value) error {
	switch name {
	case commentlikes.FieldCommentID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddCommentID(v)
		return nil
	case commentlikes.FieldUserID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddUserID(v)
		return nil
	}
	return fmt.Errorf("unknown CommentLikes numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *CommentLikesMutation) ClearedFields() []string {
	return nil
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *CommentLikesMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *CommentLikesMutation) ClearField(name string) error {
	return fmt.Errorf("unknown CommentLikes nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *CommentLikesMutation) ResetField(name string) error {
	switch name {
	case commentlikes.FieldCommentID:
		m.ResetCommentID()
		return nil
	case commentlikes.FieldUserID:
		m.ResetUserID()
		return nil
	case commentlikes.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	}
	return fmt.Errorf("unknown CommentLikes field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *CommentLikesMutation) AddedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *CommentLikesMutation) AddedIDs(name string) []ent.Value {
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *CommentLikesMutation) RemovedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *CommentLikesMutation) RemovedIDs(name string) []ent.Value {
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *CommentLikesMutation) ClearedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *CommentLikesMutation) EdgeCleared(name string) bool {
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *CommentLikesMutation) ClearEdge(name string) error {
	return fmt.Errorf("unknown CommentLikes unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *CommentLikesMutation) ResetEdge(name string) error {
	return fmt.Errorf("unknown CommentLikes edge %s", name)
}

// CommentsMutation represents an operation that mutates the Comments nodes in the graph.
type CommentsMutation struct {
	config
	op            Op
	typ           string
	id            *int64
	post_id       *int64
	addpost_id    *int64
	author_id     *int64
	addauthor_id  *int64
	content       *string
	like_count    *int
	addlike_count *int
	created_at    *time.Time
	deleted_at    *time.Time
	clearedFields map[string]struct{}
	done          bool
	oldValue      func(context.Context) (*Comments, error)
	predicates    []predicate.Comments
}

var _ ent.Mutation = (*CommentsMutation)(nil)

// commentsOption allows management of the mutation configuration using functional options.
type commentsOption func(*CommentsMutation)

// newCommentsMutation creates new mutation for the Comments entity.
func newCommentsMutation(c config, op Op, opts ...commentsOption) *CommentsMutation {
	m := &CommentsMutation{
		config:        c,
		op:            op,
		typ:           TypeComments,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withCommentsID sets the ID field of the mutation.
func withCommentsID(id int64) commentsOption {
	return func(m *CommentsMutation) {
		var (
			err   error
			once  sync.Once
			value *Comments
		)
		m.oldValue = func(ctx context.Context) (*Comments, error) {
			once.Do(func() {
				if m.done {
					err = errors.New("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Comments.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withComments sets the old Comments of the mutation.
func withComments(node *Comments) commentsOption {
	return func(m *CommentsMutation) {
		m.oldValue = func(context.Context) (*Comments, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m CommentsMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m CommentsMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, errors.New("models: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Comments entities.
func (m *CommentsMutation) SetID(id int64) {
	m.id = &id
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *CommentsMutation) ID() (id int64, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *CommentsMutation) IDs(ctx context.Context) ([]int64, error) {
	switch {
	case m.op.Is(OpUpdateOne | OpDeleteOne):
		id, exists := m.ID()
		if exists {
			return []int64{id}, nil
		}
		fallthrough
	case m.op.Is(OpUpdate | OpDelete):
		return m.Client().Comments.Query().Where(m.predicates...).IDs(ctx)
	default:
		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
	}
}

// SetPostID sets the "post_id" field.
func (m *CommentsMutation) SetPostID(i int64) {
	m.post_id = &i
	m.addpost_id = nil
}

// PostID returns the value of the "post_id" field in the mutation.
func (m *CommentsMutation) PostID() (r int64, exists bool) {
	v := m.post_id
	if v == nil {
		return
	}
	return *v, true
}

// OldPostID returns the old "post_id" field's value of the Comments entity.
// If the Comments object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CommentsMutation) OldPostID(ctx context.Context) (v int64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldPostID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldPostID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldPostID: %w", err)
	}
	return oldValue.PostID, nil
}

// AddPostID adds i to the "post_id" field.
func (m *CommentsMutation) AddPostID(i int64) {
	if m.addpost_id != nil {
		*m.addpost_id += i
	} else {
		m.addpost_id = &i
	}
}

// AddedPostID returns the value that was added to the "post_id" field in this mutation.
func (m *CommentsMutation) AddedPostID() (r int64, exists bool) {
	v := m.addpost_id
	if v == nil {
		return
	}
	return *v, true
}

// ResetPostID resets all changes to the "post_id" field.
func (m *CommentsMutation) ResetPostID() {
	m.post_id = nil
	m.addpost_id = nil
}

// SetAuthorID sets the "author_id" field.
func (m *CommentsMutation) SetAuthorID(i int64) {
	m.author_id = &i
	m.addauthor_id = nil
}

// AuthorID returns the value of the "author_id" field in the mutation.
func (m *CommentsMutation) AuthorID() (r int64, exists bool) {
	v := m.author_id
	if v == nil {
		return
	}
	return *v, true
}

// OldAuthorID returns the old "author_id" field's value of the Comments entity.
// If the Comments object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CommentsMutation) OldAuthorID(ctx context.Context) (v int64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldAuthorID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldAuthorID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldAuthorID: %w", err)
	}
	return oldValue.AuthorID, nil
}

// AddAuthorID adds i to the "author_id" field.
func (m *CommentsMutation) AddAuthorID(i int64) {
	if m.addauthor_id != nil {
		*m.addauthor_id += i
	} else {
		m.addauthor_id = &i
	}
}

// AddedAuthorID returns the value that was added to the "author_id" field in this mutation.
func (m *CommentsMutation) AddedAuthorID() (r int64, exists bool) {
	v := m.addauthor_id
	if v == nil {
		return
	}
	return *v, true
}

// ResetAuthorID resets all changes to the "author_id" field.
func (m *CommentsMutation) ResetAuthorID() {
	m.author_id = nil
	m.addauthor_id = nil
}

// SetContent sets the "content" field.
func (m *CommentsMutation) SetContent(s string) {
	m.content = &s
}

// Content returns the value of the "content" field in the mutation.
func (m *CommentsMutation) Content() (r string, exists bool) {
	v := m.content
	if v == nil {
		return
	}
	return *v, true
}

// OldContent returns the old "content" field's value of the Comments entity.
// If the Comments object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CommentsMutation) OldContent(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldContent is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldContent requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldContent: %w", err)
	}
	return oldValue.Content, nil
}

// ResetContent resets all changes to the "content" field.
func (m *CommentsMutation) ResetContent() {
	m.content = nil
}

// SetLikeCount sets the "like_count" field.
func (m *CommentsMutation) SetLikeCount(i int) {
	m.like_count = &i
	m.addlike_count = nil
}

// LikeCount returns the value of the "like_count" field in the mutation.
func (m *CommentsMutation) LikeCount() (r int, exists bool) {
	v := m.like_count
	if v == nil {
		return
	}
	return *v, true
}

// OldLikeCount returns the old "like_count" field's value of the Comments entity.
// If the Comments object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CommentsMutation) OldLikeCount(ctx context.Context) (v int, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldLikeCount is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldLikeCount requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldLikeCount: %w", err)
	}
	return oldValue.LikeCount, nil
}

// AddLikeCount adds i to the "like_count" field.
func (m *CommentsMutation) AddLikeCount(i int) {
	if m.addlike_count != nil {
		*m.addlike_count += i
	} else {
		m.addlike_count = &i
	}
}

// AddedLikeCount returns the value that was added to the "like_count" field in this mutation.
func (m *CommentsMutation) AddedLikeCount() (r int, exists bool) {
	v := m.addlike_count
	if v == nil {
		return
	}
	return *v, true
}

// ClearLikeCount clears the value of the "like_count" field.
func (m *CommentsMutation) ClearLikeCount() {
	m.like_count = nil
	m.addlike_count = nil
	m.clearedFields[comments.FieldLikeCount] = struct{}{}
}

// LikeCountCleared returns if the "like_count" field was cleared in this mutation.
func (m *CommentsMutation) LikeCountCleared() bool {
	_, ok := m.clearedFields[comments.FieldLikeCount]
	return ok
}

// ResetLikeCount resets all changes to the "like_count" field.
func (m *CommentsMutation) ResetLikeCount() {
	m.like_count = nil
	m.addlike_count = nil
	delete(m.clearedFields, comments.FieldLikeCount)
}

// SetCreatedAt sets the "created_at" field.
func (m *CommentsMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *CommentsMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the Comments entity.
// If the Comments object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CommentsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *CommentsMutation) ResetCreatedAt() {
	m.created_at = nil
}

// SetDeletedAt sets the "deleted_at" field.
func (m *CommentsMutation) SetDeletedAt(t time.Time) {
	m.deleted_at = &t
}

// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *CommentsMutation) DeletedAt() (r time.Time, exists bool) {
	v := m.deleted_at
	if v == nil {
		return
	}
	return *v, true
}

// OldDeletedAt returns the old "deleted_at" field's value of the Comments entity.
// If the Comments object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CommentsMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldDeletedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
	}
	return oldValue.DeletedAt, nil
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (m *CommentsMutation) ClearDeletedAt() {
	m.deleted_at = nil
	m.clearedFields[comments.FieldDeletedAt] = struct{}{}
}

// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *CommentsMutation) DeletedAtCleared() bool {
	_, ok := m.clearedFields[comments.FieldDeletedAt]
	return ok
}

// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *CommentsMutation) ResetDeletedAt() {
	m.deleted_at = nil
	delete(m.clearedFields, comments.FieldDeletedAt)
}

// Where appends a list predicates to the CommentsMutation builder.
func (m *CommentsMutation) Where(ps ...predicate.Comments) {
	m.predicates = append(m.predicates, ps...)
}

// WhereP appends storage-level predicates to the CommentsMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *CommentsMutation) WhereP(ps ...func(*sql.Selector)) {
	p := make([]predicate.Comments, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	m.Where(p...)
}

// Op returns the operation name.
func (m *CommentsMutation) Op() Op {
	return m.op
}

// SetOp allows setting the mutation operation.
func (m *CommentsMutation) SetOp(op Op) {
	m.op = op
}

// Type returns the node type of this mutation (Comments).
func (m *CommentsMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *CommentsMutation) Fields() []string {
	fields := make([]string, 0, 6)
	if m.post_id != nil {
		fields = append(fields, comments.FieldPostID)
	}
	if m.author_id != nil {
		fields = append(fields, comments.FieldAuthorID)
	}
	if m.content != nil {
		fields = append(fields, comments.FieldContent)
	}
	if m.like_count != nil {
		fields = append(fields, comments.FieldLikeCount)
	}
	if m.created_at != nil {
		fields = append(fields, comments.FieldCreatedAt)
	}
	if m.deleted_at != nil {
		fields = append(fields, comments.FieldDeletedAt)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *CommentsMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case comments.FieldPostID:
		return m.PostID()
	case comments.FieldAuthorID:
		return m.AuthorID()
	case comments.FieldContent:
		return m.Content()
	case comments.FieldLikeCount:
		return m.LikeCount()
	case comments.FieldCreatedAt:
		return m.CreatedAt()
	case comments.FieldDeletedAt:
		return m.DeletedAt()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *CommentsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case comments.FieldPostID:
		return m.OldPostID(ctx)
	case comments.FieldAuthorID:
		return m.OldAuthorID(ctx)
	case comments.FieldContent:
		return m.OldContent(ctx)
	case comments.FieldLikeCount:
		return m.OldLikeCount(ctx)
	case comments.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case comments.FieldDeletedAt:
		return m.OldDeletedAt(ctx)
	}
	return nil, fmt.Errorf("unknown Comments field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *CommentsMutation) SetField(name string, value ent.Value) error {
	switch name {
	case comments.FieldPostID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetPostID(v)
		return nil
	case comments.FieldAuthorID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetAuthorID(v)
		return nil
	case comments.FieldContent:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetContent(v)
		return nil
	case comments.FieldLikeCount:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetLikeCount(v)
		return nil
	case comments.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case comments.FieldDeletedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetDeletedAt(v)
		return nil
	}
	return fmt.Errorf("unknown Comments field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *CommentsMutation) AddedFields() []string {
	var fields []string
	if m.addpost_id != nil {
		fields = append(fields, comments.FieldPostID)
	}
	if m.addauthor_id != nil {
		fields = append(fields, comments.FieldAuthorID)
	}
	if m.addlike_count != nil {
		fields = append(fields, comments.FieldLikeCount)
	}
	return fields
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *CommentsMutation) AddedField(name string) (ent.Value, bool) {
	switch name {
	case comments.FieldPostID:
		return m.AddedPostID()
	case comments.FieldAuthorID:
		return m.AddedAuthorID()
	case comments.FieldLikeCount:
		return m.AddedLikeCount()
	}
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *CommentsMutation) AddField(name string, value ent.Value) error {
	switch name {
	case comments.FieldPostID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddPostID(v)
		return nil
	case comments.FieldAuthorID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddAuthorID(v)
		return nil
	case comments.FieldLikeCount:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddLikeCount(v)
		return nil
	}
	return fmt.Errorf("unknown Comments numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *CommentsMutation) ClearedFields() []string {
	var fields []string
	if m.FieldCleared(comments.FieldLikeCount) {
		fields = append(fields, comments.FieldLikeCount)
	}
	if m.FieldCleared(comments.FieldDeletedAt) {
		fields = append(fields, comments.FieldDeletedAt)
	}
	return fields
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *CommentsMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *CommentsMutation) ClearField(name string) error {
	switch name {
	case comments.FieldLikeCount:
		m.ClearLikeCount()
		return nil
	case comments.FieldDeletedAt:
		m.ClearDeletedAt()
		return nil
	}
	return fmt.Errorf("unknown Comments nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *CommentsMutation) ResetField(name string) error {
	switch name {
	case comments.FieldPostID:
		m.ResetPostID()
		return nil
	case comments.FieldAuthorID:
		m.ResetAuthorID()
		return nil
	case comments.FieldContent:
		m.ResetContent()
		return nil
	case comments.FieldLikeCount:
		m.ResetLikeCount()
		return nil
	case comments.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case comments.FieldDeletedAt:
		m.ResetDeletedAt()
		return nil
	}
	return fmt.Errorf("unknown Comments field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *CommentsMutation) AddedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *CommentsMutation) AddedIDs(name string) []ent.Value {
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *CommentsMutation) RemovedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *CommentsMutation) RemovedIDs(name string) []ent.Value {
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *CommentsMutation) ClearedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *CommentsMutation) EdgeCleared(name string) bool {
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *CommentsMutation) ClearEdge(name string) error {
	return fmt.Errorf("unknown Comments unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *CommentsMutation) ResetEdge(name string) error {
	return fmt.Errorf("unknown Comments edge %s", name)
}

// PostLikesMutation represents an operation that mutates the PostLikes nodes in the graph.
type PostLikesMutation struct {
	config
	op            Op
	typ           string
	id            *int64
	post_id       *int64
	addpost_id    *int64
	user_id       *int64
	adduser_id    *int64
	created_at    *time.Time
	clearedFields map[string]struct{}
	done          bool
	oldValue      func(context.Context) (*PostLikes, error)
	predicates    []predicate.PostLikes
}

var _ ent.Mutation = (*PostLikesMutation)(nil)

// postlikesOption allows management of the mutation configuration using functional options.
type postlikesOption func(*PostLikesMutation)

// newPostLikesMutation creates new mutation for the PostLikes entity.
func newPostLikesMutation(c config, op Op, opts ...postlikesOption) *PostLikesMutation {
	m := &PostLikesMutation{
		config:        c,
		op:            op,
		typ:           TypePostLikes,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withPostLikesID sets the ID field of the mutation.
func withPostLikesID(id int64) postlikesOption {
	return func(m *PostLikesMutation) {
		var (
			err   error
			once  sync.Once
			value *PostLikes
		)
		m.oldValue = func(ctx context.Context) (*PostLikes, error) {
			once.Do(func() {
				if m.done {
					err = errors.New("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().PostLikes.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withPostLikes sets the old PostLikes of the mutation.
func withPostLikes(node *PostLikes) postlikesOption {
	return func(m *PostLikesMutation) {
		m.oldValue = func(context.Context) (*PostLikes, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m PostLikesMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m PostLikesMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, errors.New("models: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of PostLikes entities.
func (m *PostLikesMutation) SetID(id int64) {
	m.id = &id
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *PostLikesMutation) ID() (id int64, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *PostLikesMutation) IDs(ctx context.Context) ([]int64, error) {
	switch {
	case m.op.Is(OpUpdateOne | OpDeleteOne):
		id, exists := m.ID()
		if exists {
			return []int64{id}, nil
		}
		fallthrough
	case m.op.Is(OpUpdate | OpDelete):
		return m.Client().PostLikes.Query().Where(m.predicates...).IDs(ctx)
	default:
		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
	}
}

// SetPostID sets the "post_id" field.
func (m *PostLikesMutation) SetPostID(i int64) {
	m.post_id = &i
	m.addpost_id = nil
}

// PostID returns the value of the "post_id" field in the mutation.
func (m *PostLikesMutation) PostID() (r int64, exists bool) {
	v := m.post_id
	if v == nil {
		return
	}
	return *v, true
}

// OldPostID returns the old "post_id" field's value of the PostLikes entity.
// If the PostLikes object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostLikesMutation) OldPostID(ctx context.Context) (v int64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldPostID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldPostID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldPostID: %w", err)
	}
	return oldValue.PostID, nil
}

// AddPostID adds i to the "post_id" field.
func (m *PostLikesMutation) AddPostID(i int64) {
	if m.addpost_id != nil {
		*m.addpost_id += i
	} else {
		m.addpost_id = &i
	}
}

// AddedPostID returns the value that was added to the "post_id" field in this mutation.
func (m *PostLikesMutation) AddedPostID() (r int64, exists bool) {
	v := m.addpost_id
	if v == nil {
		return
	}
	return *v, true
}

// ResetPostID resets all changes to the "post_id" field.
func (m *PostLikesMutation) ResetPostID() {
	m.post_id = nil
	m.addpost_id = nil
}

// SetUserID sets the "user_id" field.
func (m *PostLikesMutation) SetUserID(i int64) {
	m.user_id = &i
	m.adduser_id = nil
}

// UserID returns the value of the "user_id" field in the mutation.
func (m *PostLikesMutation) UserID() (r int64, exists bool) {
	v := m.user_id
	if v == nil {
		return
	}
	return *v, true
}

// OldUserID returns the old "user_id" field's value of the PostLikes entity.
// If the PostLikes object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostLikesMutation) OldUserID(ctx context.Context) (v int64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUserID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUserID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUserID: %w", err)
	}
	return oldValue.UserID, nil
}

// AddUserID adds i to the "user_id" field.
func (m *PostLikesMutation) AddUserID(i int64) {
	if m.adduser_id != nil {
		*m.adduser_id += i
	} else {
		m.adduser_id = &i
	}
}

// AddedUserID returns the value that was added to the "user_id" field in this mutation.
func (m *PostLikesMutation) AddedUserID() (r int64, exists bool) {
	v := m.adduser_id
	if v == nil {
		return
	}
	return *v, true
}

// ResetUserID resets all changes to the "user_id" field.
func (m *PostLikesMutation) ResetUserID() {
	m.user_id = nil
	m.adduser_id = nil
}

// SetCreatedAt sets the "created_at" field.
func (m *PostLikesMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *PostLikesMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the PostLikes entity.
// If the PostLikes object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostLikesMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *PostLikesMutation) ResetCreatedAt() {
	m.created_at = nil
}

// Where appends a list predicates to the PostLikesMutation builder.
func (m *PostLikesMutation) Where(ps ...predicate.PostLikes) {
	m.predicates = append(m.predicates, ps...)
}

// WhereP appends storage-level predicates to the PostLikesMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *PostLikesMutation) WhereP(ps ...func(*sql.Selector)) {
	p := make([]predicate.PostLikes, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	m.Where(p...)
}

// Op returns the operation name.
func (m *PostLikesMutation) Op() Op {
	return m.op
}

// SetOp allows setting the mutation operation.
func (m *PostLikesMutation) SetOp(op Op) {
	m.op = op
}

// Type returns the node type of this mutation (PostLikes).
func (m *PostLikesMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *PostLikesMutation) Fields() []string {
	fields := make([]string, 0, 3)
	if m.post_id != nil {
		fields = append(fields, postlikes.FieldPostID)
	}
	if m.user_id != nil {
		fields = append(fields, postlikes.FieldUserID)
	}
	if m.created_at != nil {
		fields = append(fields, postlikes.FieldCreatedAt)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *PostLikesMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case postlikes.FieldPostID:
		return m.PostID()
	case postlikes.FieldUserID:
		return m.UserID()
	case postlikes.FieldCreatedAt:
		return m.CreatedAt()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *PostLikesMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case postlikes.FieldPostID:
		return m.OldPostID(ctx)
	case postlikes.FieldUserID:
		return m.OldUserID(ctx)
	case postlikes.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	}
	return nil, fmt.Errorf("unknown PostLikes field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *PostLikesMutation) SetField(name string, value ent.Value) error {
	switch name {
	case postlikes.FieldPostID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetPostID(v)
		return nil
	case postlikes.FieldUserID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUserID(v)
		return nil
	case postlikes.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	}
	return fmt.Errorf("unknown PostLikes field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *PostLikesMutation) AddedFields() []string {
	var fields []string
	if m.addpost_id != nil {
		fields = append(fields, postlikes.FieldPostID)
	}
	if m.adduser_id != nil {
		fields = append(fields, postlikes.FieldUserID)
	}
	return fields
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *PostLikesMutation) AddedField(name string) (ent.Value, bool) {
	switch name {
	case postlikes.FieldPostID:
		return m.AddedPostID()
	case postlikes.FieldUserID:
		return m.AddedUserID()
	}
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *PostLikesMutation) AddField(name string, value ent.Value) error {
	switch name {
	case postlikes.FieldPostID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddPostID(v)
		return nil
	case postlikes.FieldUserID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddUserID(v)
		return nil
	}
	return fmt.Errorf("unknown PostLikes numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *PostLikesMutation) ClearedFields() []string {
	return nil
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *PostLikesMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *PostLikesMutation) ClearField(name string) error {
	return fmt.Errorf("unknown PostLikes nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *PostLikesMutation) ResetField(name string) error {
	switch name {
	case postlikes.FieldPostID:
		m.ResetPostID()
		return nil
	case postlikes.FieldUserID:
		m.ResetUserID()
		return nil
	case postlikes.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	}
	return fmt.Errorf("unknown PostLikes field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *PostLikesMutation) AddedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *PostLikesMutation) AddedIDs(name string) []ent.Value {
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *PostLikesMutation) RemovedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *PostLikesMutation) RemovedIDs(name string) []ent.Value {
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *PostLikesMutation) ClearedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *PostLikesMutation) EdgeCleared(name string) bool {
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *PostLikesMutation) ClearEdge(name string) error {
	return fmt.Errorf("unknown PostLikes unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *PostLikesMutation) ResetEdge(name string) error {
	return fmt.Errorf("unknown PostLikes edge %s", name)
}

// PostsMutation represents an operation that mutates the Posts nodes in the graph.
type PostsMutation struct {
	config
	op                 Op
	typ                string
	id                 *int64
	author_id          *int64
	addauthor_id       *int64
	author_role        *string
	title              *string
	content            *string
	images             *types.TextArray
	tags               *types.TextArray
	linked_order_id    *int64
	addlinked_order_id *int64
	quoted_post_id     *int64
	addquoted_post_id  *int64
	like_count         *int
	addlike_count      *int
	comment_count      *int
	addcomment_count   *int
	pinned             *bool
	created_at         *time.Time
	updated_at         *time.Time
	deleted_at         *time.Time
	clearedFields      map[string]struct{}
	done               bool
	oldValue           func(context.Context) (*Posts, error)
	predicates         []predicate.Posts
}

var _ ent.Mutation = (*PostsMutation)(nil)

// postsOption allows management of the mutation configuration using functional options.
type postsOption func(*PostsMutation)

// newPostsMutation creates new mutation for the Posts entity.
func newPostsMutation(c config, op Op, opts ...postsOption) *PostsMutation {
	m := &PostsMutation{
		config:        c,
		op:            op,
		typ:           TypePosts,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withPostsID sets the ID field of the mutation.
func withPostsID(id int64) postsOption {
	return func(m *PostsMutation) {
		var (
			err   error
			once  sync.Once
			value *Posts
		)
		m.oldValue = func(ctx context.Context) (*Posts, error) {
			once.Do(func() {
				if m.done {
					err = errors.New("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Posts.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withPosts sets the old Posts of the mutation.
func withPosts(node *Posts) postsOption {
	return func(m *PostsMutation) {
		m.oldValue = func(context.Context) (*Posts, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m PostsMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m PostsMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, errors.New("models: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Posts entities.
func (m *PostsMutation) SetID(id int64) {
	m.id = &id
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *PostsMutation) ID() (id int64, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *PostsMutation) IDs(ctx context.Context) ([]int64, error) {
	switch {
	case m.op.Is(OpUpdateOne | OpDeleteOne):
		id, exists := m.ID()
		if exists {
			return []int64{id}, nil
		}
		fallthrough
	case m.op.Is(OpUpdate | OpDelete):
		return m.Client().Posts.Query().Where(m.predicates...).IDs(ctx)
	default:
		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
	}
}

// SetAuthorID sets the "author_id" field.
func (m *PostsMutation) SetAuthorID(i int64) {
	m.author_id = &i
	m.addauthor_id = nil
}

// AuthorID returns the value of the "author_id" field in the mutation.
func (m *PostsMutation) AuthorID() (r int64, exists bool) {
	v := m.author_id
	if v == nil {
		return
	}
	return *v, true
}

// OldAuthorID returns the old "author_id" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldAuthorID(ctx context.Context) (v int64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldAuthorID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldAuthorID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldAuthorID: %w", err)
	}
	return oldValue.AuthorID, nil
}

// AddAuthorID adds i to the "author_id" field.
func (m *PostsMutation) AddAuthorID(i int64) {
	if m.addauthor_id != nil {
		*m.addauthor_id += i
	} else {
		m.addauthor_id = &i
	}
}

// AddedAuthorID returns the value that was added to the "author_id" field in this mutation.
func (m *PostsMutation) AddedAuthorID() (r int64, exists bool) {
	v := m.addauthor_id
	if v == nil {
		return
	}
	return *v, true
}

// ResetAuthorID resets all changes to the "author_id" field.
func (m *PostsMutation) ResetAuthorID() {
	m.author_id = nil
	m.addauthor_id = nil
}

// SetAuthorRole sets the "author_role" field.
func (m *PostsMutation) SetAuthorRole(s string) {
	m.author_role = &s
}

// AuthorRole returns the value of the "author_role" field in the mutation.
func (m *PostsMutation) AuthorRole() (r string, exists bool) {
	v := m.author_role
	if v == nil {
		return
	}
	return *v, true
}

// OldAuthorRole returns the old "author_role" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldAuthorRole(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldAuthorRole is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldAuthorRole requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldAuthorRole: %w", err)
	}
	return oldValue.AuthorRole, nil
}

// ResetAuthorRole resets all changes to the "author_role" field.
func (m *PostsMutation) ResetAuthorRole() {
	m.author_role = nil
}

// SetTitle sets the "title" field.
func (m *PostsMutation) SetTitle(s string) {
	m.title = &s
}

// Title returns the value of the "title" field in the mutation.
func (m *PostsMutation) Title() (r string, exists bool) {
	v := m.title
	if v == nil {
		return
	}
	return *v, true
}

// OldTitle returns the old "title" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldTitle(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldTitle is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("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
}

// ResetTitle resets all changes to the "title" field.
func (m *PostsMutation) ResetTitle() {
	m.title = nil
}

// SetContent sets the "content" field.
func (m *PostsMutation) SetContent(s string) {
	m.content = &s
}

// Content returns the value of the "content" field in the mutation.
func (m *PostsMutation) Content() (r string, exists bool) {
	v := m.content
	if v == nil {
		return
	}
	return *v, true
}

// OldContent returns the old "content" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldContent(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldContent is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldContent requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldContent: %w", err)
	}
	return oldValue.Content, nil
}

// ResetContent resets all changes to the "content" field.
func (m *PostsMutation) ResetContent() {
	m.content = nil
}

// SetImages sets the "images" field.
func (m *PostsMutation) SetImages(ta types.TextArray) {
	m.images = &ta
}

// Images returns the value of the "images" field in the mutation.
func (m *PostsMutation) Images() (r types.TextArray, exists bool) {
	v := m.images
	if v == nil {
		return
	}
	return *v, true
}

// OldImages returns the old "images" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldImages(ctx context.Context) (v types.TextArray, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldImages is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldImages requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldImages: %w", err)
	}
	return oldValue.Images, nil
}

// ClearImages clears the value of the "images" field.
func (m *PostsMutation) ClearImages() {
	m.images = nil
	m.clearedFields[posts.FieldImages] = struct{}{}
}

// ImagesCleared returns if the "images" field was cleared in this mutation.
func (m *PostsMutation) ImagesCleared() bool {
	_, ok := m.clearedFields[posts.FieldImages]
	return ok
}

// ResetImages resets all changes to the "images" field.
func (m *PostsMutation) ResetImages() {
	m.images = nil
	delete(m.clearedFields, posts.FieldImages)
}

// SetTags sets the "tags" field.
func (m *PostsMutation) SetTags(ta types.TextArray) {
	m.tags = &ta
}

// Tags returns the value of the "tags" field in the mutation.
func (m *PostsMutation) Tags() (r types.TextArray, exists bool) {
	v := m.tags
	if v == nil {
		return
	}
	return *v, true
}

// OldTags returns the old "tags" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldTags(ctx context.Context) (v types.TextArray, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldTags is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldTags requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldTags: %w", err)
	}
	return oldValue.Tags, nil
}

// ClearTags clears the value of the "tags" field.
func (m *PostsMutation) ClearTags() {
	m.tags = nil
	m.clearedFields[posts.FieldTags] = struct{}{}
}

// TagsCleared returns if the "tags" field was cleared in this mutation.
func (m *PostsMutation) TagsCleared() bool {
	_, ok := m.clearedFields[posts.FieldTags]
	return ok
}

// ResetTags resets all changes to the "tags" field.
func (m *PostsMutation) ResetTags() {
	m.tags = nil
	delete(m.clearedFields, posts.FieldTags)
}

// SetLinkedOrderID sets the "linked_order_id" field.
func (m *PostsMutation) SetLinkedOrderID(i int64) {
	m.linked_order_id = &i
	m.addlinked_order_id = nil
}

// LinkedOrderID returns the value of the "linked_order_id" field in the mutation.
func (m *PostsMutation) LinkedOrderID() (r int64, exists bool) {
	v := m.linked_order_id
	if v == nil {
		return
	}
	return *v, true
}

// OldLinkedOrderID returns the old "linked_order_id" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldLinkedOrderID(ctx context.Context) (v *int64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldLinkedOrderID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldLinkedOrderID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldLinkedOrderID: %w", err)
	}
	return oldValue.LinkedOrderID, nil
}

// AddLinkedOrderID adds i to the "linked_order_id" field.
func (m *PostsMutation) AddLinkedOrderID(i int64) {
	if m.addlinked_order_id != nil {
		*m.addlinked_order_id += i
	} else {
		m.addlinked_order_id = &i
	}
}

// AddedLinkedOrderID returns the value that was added to the "linked_order_id" field in this mutation.
func (m *PostsMutation) AddedLinkedOrderID() (r int64, exists bool) {
	v := m.addlinked_order_id
	if v == nil {
		return
	}
	return *v, true
}

// ClearLinkedOrderID clears the value of the "linked_order_id" field.
func (m *PostsMutation) ClearLinkedOrderID() {
	m.linked_order_id = nil
	m.addlinked_order_id = nil
	m.clearedFields[posts.FieldLinkedOrderID] = struct{}{}
}

// LinkedOrderIDCleared returns if the "linked_order_id" field was cleared in this mutation.
func (m *PostsMutation) LinkedOrderIDCleared() bool {
	_, ok := m.clearedFields[posts.FieldLinkedOrderID]
	return ok
}

// ResetLinkedOrderID resets all changes to the "linked_order_id" field.
func (m *PostsMutation) ResetLinkedOrderID() {
	m.linked_order_id = nil
	m.addlinked_order_id = nil
	delete(m.clearedFields, posts.FieldLinkedOrderID)
}

// SetQuotedPostID sets the "quoted_post_id" field.
func (m *PostsMutation) SetQuotedPostID(i int64) {
	m.quoted_post_id = &i
	m.addquoted_post_id = nil
}

// QuotedPostID returns the value of the "quoted_post_id" field in the mutation.
func (m *PostsMutation) QuotedPostID() (r int64, exists bool) {
	v := m.quoted_post_id
	if v == nil {
		return
	}
	return *v, true
}

// OldQuotedPostID returns the old "quoted_post_id" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldQuotedPostID(ctx context.Context) (v *int64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldQuotedPostID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldQuotedPostID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldQuotedPostID: %w", err)
	}
	return oldValue.QuotedPostID, nil
}

// AddQuotedPostID adds i to the "quoted_post_id" field.
func (m *PostsMutation) AddQuotedPostID(i int64) {
	if m.addquoted_post_id != nil {
		*m.addquoted_post_id += i
	} else {
		m.addquoted_post_id = &i
	}
}

// AddedQuotedPostID returns the value that was added to the "quoted_post_id" field in this mutation.
func (m *PostsMutation) AddedQuotedPostID() (r int64, exists bool) {
	v := m.addquoted_post_id
	if v == nil {
		return
	}
	return *v, true
}

// ClearQuotedPostID clears the value of the "quoted_post_id" field.
func (m *PostsMutation) ClearQuotedPostID() {
	m.quoted_post_id = nil
	m.addquoted_post_id = nil
	m.clearedFields[posts.FieldQuotedPostID] = struct{}{}
}

// QuotedPostIDCleared returns if the "quoted_post_id" field was cleared in this mutation.
func (m *PostsMutation) QuotedPostIDCleared() bool {
	_, ok := m.clearedFields[posts.FieldQuotedPostID]
	return ok
}

// ResetQuotedPostID resets all changes to the "quoted_post_id" field.
func (m *PostsMutation) ResetQuotedPostID() {
	m.quoted_post_id = nil
	m.addquoted_post_id = nil
	delete(m.clearedFields, posts.FieldQuotedPostID)
}

// SetLikeCount sets the "like_count" field.
func (m *PostsMutation) SetLikeCount(i int) {
	m.like_count = &i
	m.addlike_count = nil
}

// LikeCount returns the value of the "like_count" field in the mutation.
func (m *PostsMutation) LikeCount() (r int, exists bool) {
	v := m.like_count
	if v == nil {
		return
	}
	return *v, true
}

// OldLikeCount returns the old "like_count" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldLikeCount(ctx context.Context) (v int, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldLikeCount is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldLikeCount requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldLikeCount: %w", err)
	}
	return oldValue.LikeCount, nil
}

// AddLikeCount adds i to the "like_count" field.
func (m *PostsMutation) AddLikeCount(i int) {
	if m.addlike_count != nil {
		*m.addlike_count += i
	} else {
		m.addlike_count = &i
	}
}

// AddedLikeCount returns the value that was added to the "like_count" field in this mutation.
func (m *PostsMutation) AddedLikeCount() (r int, exists bool) {
	v := m.addlike_count
	if v == nil {
		return
	}
	return *v, true
}

// ClearLikeCount clears the value of the "like_count" field.
func (m *PostsMutation) ClearLikeCount() {
	m.like_count = nil
	m.addlike_count = nil
	m.clearedFields[posts.FieldLikeCount] = struct{}{}
}

// LikeCountCleared returns if the "like_count" field was cleared in this mutation.
func (m *PostsMutation) LikeCountCleared() bool {
	_, ok := m.clearedFields[posts.FieldLikeCount]
	return ok
}

// ResetLikeCount resets all changes to the "like_count" field.
func (m *PostsMutation) ResetLikeCount() {
	m.like_count = nil
	m.addlike_count = nil
	delete(m.clearedFields, posts.FieldLikeCount)
}

// SetCommentCount sets the "comment_count" field.
func (m *PostsMutation) SetCommentCount(i int) {
	m.comment_count = &i
	m.addcomment_count = nil
}

// CommentCount returns the value of the "comment_count" field in the mutation.
func (m *PostsMutation) CommentCount() (r int, exists bool) {
	v := m.comment_count
	if v == nil {
		return
	}
	return *v, true
}

// OldCommentCount returns the old "comment_count" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldCommentCount(ctx context.Context) (v int, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCommentCount is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCommentCount requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCommentCount: %w", err)
	}
	return oldValue.CommentCount, nil
}

// AddCommentCount adds i to the "comment_count" field.
func (m *PostsMutation) AddCommentCount(i int) {
	if m.addcomment_count != nil {
		*m.addcomment_count += i
	} else {
		m.addcomment_count = &i
	}
}

// AddedCommentCount returns the value that was added to the "comment_count" field in this mutation.
func (m *PostsMutation) AddedCommentCount() (r int, exists bool) {
	v := m.addcomment_count
	if v == nil {
		return
	}
	return *v, true
}

// ClearCommentCount clears the value of the "comment_count" field.
func (m *PostsMutation) ClearCommentCount() {
	m.comment_count = nil
	m.addcomment_count = nil
	m.clearedFields[posts.FieldCommentCount] = struct{}{}
}

// CommentCountCleared returns if the "comment_count" field was cleared in this mutation.
func (m *PostsMutation) CommentCountCleared() bool {
	_, ok := m.clearedFields[posts.FieldCommentCount]
	return ok
}

// ResetCommentCount resets all changes to the "comment_count" field.
func (m *PostsMutation) ResetCommentCount() {
	m.comment_count = nil
	m.addcomment_count = nil
	delete(m.clearedFields, posts.FieldCommentCount)
}

// SetPinned sets the "pinned" field.
func (m *PostsMutation) SetPinned(b bool) {
	m.pinned = &b
}

// Pinned returns the value of the "pinned" field in the mutation.
func (m *PostsMutation) Pinned() (r bool, exists bool) {
	v := m.pinned
	if v == nil {
		return
	}
	return *v, true
}

// OldPinned returns the old "pinned" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldPinned(ctx context.Context) (v bool, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldPinned is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldPinned requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldPinned: %w", err)
	}
	return oldValue.Pinned, nil
}

// ClearPinned clears the value of the "pinned" field.
func (m *PostsMutation) ClearPinned() {
	m.pinned = nil
	m.clearedFields[posts.FieldPinned] = struct{}{}
}

// PinnedCleared returns if the "pinned" field was cleared in this mutation.
func (m *PostsMutation) PinnedCleared() bool {
	_, ok := m.clearedFields[posts.FieldPinned]
	return ok
}

// ResetPinned resets all changes to the "pinned" field.
func (m *PostsMutation) ResetPinned() {
	m.pinned = nil
	delete(m.clearedFields, posts.FieldPinned)
}

// SetCreatedAt sets the "created_at" field.
func (m *PostsMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *PostsMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *PostsMutation) ResetCreatedAt() {
	m.created_at = nil
}

// SetUpdatedAt sets the "updated_at" field.
func (m *PostsMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *PostsMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

// OldUpdatedAt returns the old "updated_at" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *PostsMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

// SetDeletedAt sets the "deleted_at" field.
func (m *PostsMutation) SetDeletedAt(t time.Time) {
	m.deleted_at = &t
}

// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *PostsMutation) DeletedAt() (r time.Time, exists bool) {
	v := m.deleted_at
	if v == nil {
		return
	}
	return *v, true
}

// OldDeletedAt returns the old "deleted_at" field's value of the Posts entity.
// If the Posts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PostsMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldDeletedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
	}
	return oldValue.DeletedAt, nil
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (m *PostsMutation) ClearDeletedAt() {
	m.deleted_at = nil
	m.clearedFields[posts.FieldDeletedAt] = struct{}{}
}

// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *PostsMutation) DeletedAtCleared() bool {
	_, ok := m.clearedFields[posts.FieldDeletedAt]
	return ok
}

// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *PostsMutation) ResetDeletedAt() {
	m.deleted_at = nil
	delete(m.clearedFields, posts.FieldDeletedAt)
}

// Where appends a list predicates to the PostsMutation builder.
func (m *PostsMutation) Where(ps ...predicate.Posts) {
	m.predicates = append(m.predicates, ps...)
}

// WhereP appends storage-level predicates to the PostsMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *PostsMutation) WhereP(ps ...func(*sql.Selector)) {
	p := make([]predicate.Posts, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	m.Where(p...)
}

// Op returns the operation name.
func (m *PostsMutation) Op() Op {
	return m.op
}

// SetOp allows setting the mutation operation.
func (m *PostsMutation) SetOp(op Op) {
	m.op = op
}

// Type returns the node type of this mutation (Posts).
func (m *PostsMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *PostsMutation) Fields() []string {
	fields := make([]string, 0, 14)
	if m.author_id != nil {
		fields = append(fields, posts.FieldAuthorID)
	}
	if m.author_role != nil {
		fields = append(fields, posts.FieldAuthorRole)
	}
	if m.title != nil {
		fields = append(fields, posts.FieldTitle)
	}
	if m.content != nil {
		fields = append(fields, posts.FieldContent)
	}
	if m.images != nil {
		fields = append(fields, posts.FieldImages)
	}
	if m.tags != nil {
		fields = append(fields, posts.FieldTags)
	}
	if m.linked_order_id != nil {
		fields = append(fields, posts.FieldLinkedOrderID)
	}
	if m.quoted_post_id != nil {
		fields = append(fields, posts.FieldQuotedPostID)
	}
	if m.like_count != nil {
		fields = append(fields, posts.FieldLikeCount)
	}
	if m.comment_count != nil {
		fields = append(fields, posts.FieldCommentCount)
	}
	if m.pinned != nil {
		fields = append(fields, posts.FieldPinned)
	}
	if m.created_at != nil {
		fields = append(fields, posts.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, posts.FieldUpdatedAt)
	}
	if m.deleted_at != nil {
		fields = append(fields, posts.FieldDeletedAt)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *PostsMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case posts.FieldAuthorID:
		return m.AuthorID()
	case posts.FieldAuthorRole:
		return m.AuthorRole()
	case posts.FieldTitle:
		return m.Title()
	case posts.FieldContent:
		return m.Content()
	case posts.FieldImages:
		return m.Images()
	case posts.FieldTags:
		return m.Tags()
	case posts.FieldLinkedOrderID:
		return m.LinkedOrderID()
	case posts.FieldQuotedPostID:
		return m.QuotedPostID()
	case posts.FieldLikeCount:
		return m.LikeCount()
	case posts.FieldCommentCount:
		return m.CommentCount()
	case posts.FieldPinned:
		return m.Pinned()
	case posts.FieldCreatedAt:
		return m.CreatedAt()
	case posts.FieldUpdatedAt:
		return m.UpdatedAt()
	case posts.FieldDeletedAt:
		return m.DeletedAt()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *PostsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case posts.FieldAuthorID:
		return m.OldAuthorID(ctx)
	case posts.FieldAuthorRole:
		return m.OldAuthorRole(ctx)
	case posts.FieldTitle:
		return m.OldTitle(ctx)
	case posts.FieldContent:
		return m.OldContent(ctx)
	case posts.FieldImages:
		return m.OldImages(ctx)
	case posts.FieldTags:
		return m.OldTags(ctx)
	case posts.FieldLinkedOrderID:
		return m.OldLinkedOrderID(ctx)
	case posts.FieldQuotedPostID:
		return m.OldQuotedPostID(ctx)
	case posts.FieldLikeCount:
		return m.OldLikeCount(ctx)
	case posts.FieldCommentCount:
		return m.OldCommentCount(ctx)
	case posts.FieldPinned:
		return m.OldPinned(ctx)
	case posts.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case posts.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	case posts.FieldDeletedAt:
		return m.OldDeletedAt(ctx)
	}
	return nil, fmt.Errorf("unknown Posts field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *PostsMutation) SetField(name string, value ent.Value) error {
	switch name {
	case posts.FieldAuthorID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetAuthorID(v)
		return nil
	case posts.FieldAuthorRole:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetAuthorRole(v)
		return nil
	case posts.FieldTitle:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetTitle(v)
		return nil
	case posts.FieldContent:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetContent(v)
		return nil
	case posts.FieldImages:
		v, ok := value.(types.TextArray)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetImages(v)
		return nil
	case posts.FieldTags:
		v, ok := value.(types.TextArray)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetTags(v)
		return nil
	case posts.FieldLinkedOrderID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetLinkedOrderID(v)
		return nil
	case posts.FieldQuotedPostID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetQuotedPostID(v)
		return nil
	case posts.FieldLikeCount:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetLikeCount(v)
		return nil
	case posts.FieldCommentCount:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCommentCount(v)
		return nil
	case posts.FieldPinned:
		v, ok := value.(bool)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetPinned(v)
		return nil
	case posts.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case posts.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	case posts.FieldDeletedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetDeletedAt(v)
		return nil
	}
	return fmt.Errorf("unknown Posts field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *PostsMutation) AddedFields() []string {
	var fields []string
	if m.addauthor_id != nil {
		fields = append(fields, posts.FieldAuthorID)
	}
	if m.addlinked_order_id != nil {
		fields = append(fields, posts.FieldLinkedOrderID)
	}
	if m.addquoted_post_id != nil {
		fields = append(fields, posts.FieldQuotedPostID)
	}
	if m.addlike_count != nil {
		fields = append(fields, posts.FieldLikeCount)
	}
	if m.addcomment_count != nil {
		fields = append(fields, posts.FieldCommentCount)
	}
	return fields
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *PostsMutation) AddedField(name string) (ent.Value, bool) {
	switch name {
	case posts.FieldAuthorID:
		return m.AddedAuthorID()
	case posts.FieldLinkedOrderID:
		return m.AddedLinkedOrderID()
	case posts.FieldQuotedPostID:
		return m.AddedQuotedPostID()
	case posts.FieldLikeCount:
		return m.AddedLikeCount()
	case posts.FieldCommentCount:
		return m.AddedCommentCount()
	}
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *PostsMutation) AddField(name string, value ent.Value) error {
	switch name {
	case posts.FieldAuthorID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddAuthorID(v)
		return nil
	case posts.FieldLinkedOrderID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddLinkedOrderID(v)
		return nil
	case posts.FieldQuotedPostID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddQuotedPostID(v)
		return nil
	case posts.FieldLikeCount:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddLikeCount(v)
		return nil
	case posts.FieldCommentCount:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddCommentCount(v)
		return nil
	}
	return fmt.Errorf("unknown Posts numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *PostsMutation) ClearedFields() []string {
	var fields []string
	if m.FieldCleared(posts.FieldImages) {
		fields = append(fields, posts.FieldImages)
	}
	if m.FieldCleared(posts.FieldTags) {
		fields = append(fields, posts.FieldTags)
	}
	if m.FieldCleared(posts.FieldLinkedOrderID) {
		fields = append(fields, posts.FieldLinkedOrderID)
	}
	if m.FieldCleared(posts.FieldQuotedPostID) {
		fields = append(fields, posts.FieldQuotedPostID)
	}
	if m.FieldCleared(posts.FieldLikeCount) {
		fields = append(fields, posts.FieldLikeCount)
	}
	if m.FieldCleared(posts.FieldCommentCount) {
		fields = append(fields, posts.FieldCommentCount)
	}
	if m.FieldCleared(posts.FieldPinned) {
		fields = append(fields, posts.FieldPinned)
	}
	if m.FieldCleared(posts.FieldDeletedAt) {
		fields = append(fields, posts.FieldDeletedAt)
	}
	return fields
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *PostsMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *PostsMutation) ClearField(name string) error {
	switch name {
	case posts.FieldImages:
		m.ClearImages()
		return nil
	case posts.FieldTags:
		m.ClearTags()
		return nil
	case posts.FieldLinkedOrderID:
		m.ClearLinkedOrderID()
		return nil
	case posts.FieldQuotedPostID:
		m.ClearQuotedPostID()
		return nil
	case posts.FieldLikeCount:
		m.ClearLikeCount()
		return nil
	case posts.FieldCommentCount:
		m.ClearCommentCount()
		return nil
	case posts.FieldPinned:
		m.ClearPinned()
		return nil
	case posts.FieldDeletedAt:
		m.ClearDeletedAt()
		return nil
	}
	return fmt.Errorf("unknown Posts nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *PostsMutation) ResetField(name string) error {
	switch name {
	case posts.FieldAuthorID:
		m.ResetAuthorID()
		return nil
	case posts.FieldAuthorRole:
		m.ResetAuthorRole()
		return nil
	case posts.FieldTitle:
		m.ResetTitle()
		return nil
	case posts.FieldContent:
		m.ResetContent()
		return nil
	case posts.FieldImages:
		m.ResetImages()
		return nil
	case posts.FieldTags:
		m.ResetTags()
		return nil
	case posts.FieldLinkedOrderID:
		m.ResetLinkedOrderID()
		return nil
	case posts.FieldQuotedPostID:
		m.ResetQuotedPostID()
		return nil
	case posts.FieldLikeCount:
		m.ResetLikeCount()
		return nil
	case posts.FieldCommentCount:
		m.ResetCommentCount()
		return nil
	case posts.FieldPinned:
		m.ResetPinned()
		return nil
	case posts.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case posts.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	case posts.FieldDeletedAt:
		m.ResetDeletedAt()
		return nil
	}
	return fmt.Errorf("unknown Posts field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *PostsMutation) AddedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *PostsMutation) AddedIDs(name string) []ent.Value {
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *PostsMutation) RemovedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *PostsMutation) RemovedIDs(name string) []ent.Value {
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *PostsMutation) ClearedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *PostsMutation) EdgeCleared(name string) bool {
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *PostsMutation) ClearEdge(name string) error {
	return fmt.Errorf("unknown Posts unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *PostsMutation) ResetEdge(name string) error {
	return fmt.Errorf("unknown Posts edge %s", name)
}
