// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/anzhiyu-c/anheyu-app/ent/article"
	"github.com/anzhiyu-c/anheyu-app/ent/postcategory"
	"github.com/anzhiyu-c/anheyu-app/ent/predicate"
)

// PostCategoryUpdate is the builder for updating PostCategory entities.
type PostCategoryUpdate struct {
	config
	hooks     []Hook
	mutation  *PostCategoryMutation
	modifiers []func(*sql.UpdateBuilder)
}

// Where appends a list predicates to the PostCategoryUpdate builder.
func (_u *PostCategoryUpdate) Where(ps ...predicate.PostCategory) *PostCategoryUpdate {
	_u.mutation.Where(ps...)
	return _u
}

// SetDeletedAt sets the "deleted_at" field.
func (_u *PostCategoryUpdate) SetDeletedAt(v time.Time) *PostCategoryUpdate {
	_u.mutation.SetDeletedAt(v)
	return _u
}

// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_u *PostCategoryUpdate) SetNillableDeletedAt(v *time.Time) *PostCategoryUpdate {
	if v != nil {
		_u.SetDeletedAt(*v)
	}
	return _u
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (_u *PostCategoryUpdate) ClearDeletedAt() *PostCategoryUpdate {
	_u.mutation.ClearDeletedAt()
	return _u
}

// SetUpdatedAt sets the "updated_at" field.
func (_u *PostCategoryUpdate) SetUpdatedAt(v time.Time) *PostCategoryUpdate {
	_u.mutation.SetUpdatedAt(v)
	return _u
}

// SetName sets the "name" field.
func (_u *PostCategoryUpdate) SetName(v string) *PostCategoryUpdate {
	_u.mutation.SetName(v)
	return _u
}

// SetNillableName sets the "name" field if the given value is not nil.
func (_u *PostCategoryUpdate) SetNillableName(v *string) *PostCategoryUpdate {
	if v != nil {
		_u.SetName(*v)
	}
	return _u
}

// SetDescription sets the "description" field.
func (_u *PostCategoryUpdate) SetDescription(v string) *PostCategoryUpdate {
	_u.mutation.SetDescription(v)
	return _u
}

// SetNillableDescription sets the "description" field if the given value is not nil.
func (_u *PostCategoryUpdate) SetNillableDescription(v *string) *PostCategoryUpdate {
	if v != nil {
		_u.SetDescription(*v)
	}
	return _u
}

// ClearDescription clears the value of the "description" field.
func (_u *PostCategoryUpdate) ClearDescription() *PostCategoryUpdate {
	_u.mutation.ClearDescription()
	return _u
}

// SetCount sets the "count" field.
func (_u *PostCategoryUpdate) SetCount(v int) *PostCategoryUpdate {
	_u.mutation.ResetCount()
	_u.mutation.SetCount(v)
	return _u
}

// SetNillableCount sets the "count" field if the given value is not nil.
func (_u *PostCategoryUpdate) SetNillableCount(v *int) *PostCategoryUpdate {
	if v != nil {
		_u.SetCount(*v)
	}
	return _u
}

// AddCount adds value to the "count" field.
func (_u *PostCategoryUpdate) AddCount(v int) *PostCategoryUpdate {
	_u.mutation.AddCount(v)
	return _u
}

// SetIsSeries sets the "is_series" field.
func (_u *PostCategoryUpdate) SetIsSeries(v bool) *PostCategoryUpdate {
	_u.mutation.SetIsSeries(v)
	return _u
}

// SetNillableIsSeries sets the "is_series" field if the given value is not nil.
func (_u *PostCategoryUpdate) SetNillableIsSeries(v *bool) *PostCategoryUpdate {
	if v != nil {
		_u.SetIsSeries(*v)
	}
	return _u
}

// AddArticleIDs adds the "articles" edge to the Article entity by IDs.
func (_u *PostCategoryUpdate) AddArticleIDs(ids ...uint) *PostCategoryUpdate {
	_u.mutation.AddArticleIDs(ids...)
	return _u
}

// AddArticles adds the "articles" edges to the Article entity.
func (_u *PostCategoryUpdate) AddArticles(v ...*Article) *PostCategoryUpdate {
	ids := make([]uint, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _u.AddArticleIDs(ids...)
}

// Mutation returns the PostCategoryMutation object of the builder.
func (_u *PostCategoryUpdate) Mutation() *PostCategoryMutation {
	return _u.mutation
}

// ClearArticles clears all "articles" edges to the Article entity.
func (_u *PostCategoryUpdate) ClearArticles() *PostCategoryUpdate {
	_u.mutation.ClearArticles()
	return _u
}

// RemoveArticleIDs removes the "articles" edge to Article entities by IDs.
func (_u *PostCategoryUpdate) RemoveArticleIDs(ids ...uint) *PostCategoryUpdate {
	_u.mutation.RemoveArticleIDs(ids...)
	return _u
}

// RemoveArticles removes "articles" edges to Article entities.
func (_u *PostCategoryUpdate) RemoveArticles(v ...*Article) *PostCategoryUpdate {
	ids := make([]uint, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _u.RemoveArticleIDs(ids...)
}

// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *PostCategoryUpdate) Save(ctx context.Context) (int, error) {
	if err := _u.defaults(); err != nil {
		return 0, err
	}
	return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}

// SaveX is like Save, but panics if an error occurs.
func (_u *PostCategoryUpdate) SaveX(ctx context.Context) int {
	affected, err := _u.Save(ctx)
	if err != nil {
		panic(err)
	}
	return affected
}

// Exec executes the query.
func (_u *PostCategoryUpdate) Exec(ctx context.Context) error {
	_, err := _u.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (_u *PostCategoryUpdate) ExecX(ctx context.Context) {
	if err := _u.Exec(ctx); err != nil {
		panic(err)
	}
}

// defaults sets the default values of the builder before save.
func (_u *PostCategoryUpdate) defaults() error {
	if _, ok := _u.mutation.UpdatedAt(); !ok {
		if postcategory.UpdateDefaultUpdatedAt == nil {
			return fmt.Errorf("ent: uninitialized postcategory.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
		}
		v := postcategory.UpdateDefaultUpdatedAt()
		_u.mutation.SetUpdatedAt(v)
	}
	return nil
}

// check runs all checks and user-defined validators on the builder.
func (_u *PostCategoryUpdate) check() error {
	if v, ok := _u.mutation.Name(); ok {
		if err := postcategory.NameValidator(v); err != nil {
			return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "PostCategory.name": %w`, err)}
		}
	}
	if v, ok := _u.mutation.Count(); ok {
		if err := postcategory.CountValidator(v); err != nil {
			return &ValidationError{Name: "count", err: fmt.Errorf(`ent: validator failed for field "PostCategory.count": %w`, err)}
		}
	}
	return nil
}

// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *PostCategoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PostCategoryUpdate {
	_u.modifiers = append(_u.modifiers, modifiers...)
	return _u
}

func (_u *PostCategoryUpdate) sqlSave(ctx context.Context) (_node int, err error) {
	if err := _u.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(postcategory.Table, postcategory.Columns, sqlgraph.NewFieldSpec(postcategory.FieldID, field.TypeUint))
	if ps := _u.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := _u.mutation.DeletedAt(); ok {
		_spec.SetField(postcategory.FieldDeletedAt, field.TypeTime, value)
	}
	if _u.mutation.DeletedAtCleared() {
		_spec.ClearField(postcategory.FieldDeletedAt, field.TypeTime)
	}
	if value, ok := _u.mutation.UpdatedAt(); ok {
		_spec.SetField(postcategory.FieldUpdatedAt, field.TypeTime, value)
	}
	if value, ok := _u.mutation.Name(); ok {
		_spec.SetField(postcategory.FieldName, field.TypeString, value)
	}
	if value, ok := _u.mutation.Description(); ok {
		_spec.SetField(postcategory.FieldDescription, field.TypeString, value)
	}
	if _u.mutation.DescriptionCleared() {
		_spec.ClearField(postcategory.FieldDescription, field.TypeString)
	}
	if value, ok := _u.mutation.Count(); ok {
		_spec.SetField(postcategory.FieldCount, field.TypeInt, value)
	}
	if value, ok := _u.mutation.AddedCount(); ok {
		_spec.AddField(postcategory.FieldCount, field.TypeInt, value)
	}
	if value, ok := _u.mutation.IsSeries(); ok {
		_spec.SetField(postcategory.FieldIsSeries, field.TypeBool, value)
	}
	if _u.mutation.ArticlesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   postcategory.ArticlesTable,
			Columns: postcategory.ArticlesPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(article.FieldID, field.TypeUint),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := _u.mutation.RemovedArticlesIDs(); len(nodes) > 0 && !_u.mutation.ArticlesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   postcategory.ArticlesTable,
			Columns: postcategory.ArticlesPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(article.FieldID, field.TypeUint),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := _u.mutation.ArticlesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   postcategory.ArticlesTable,
			Columns: postcategory.ArticlesPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(article.FieldID, field.TypeUint),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	_spec.AddModifiers(_u.modifiers...)
	if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{postcategory.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return 0, err
	}
	_u.mutation.done = true
	return _node, nil
}

// PostCategoryUpdateOne is the builder for updating a single PostCategory entity.
type PostCategoryUpdateOne struct {
	config
	fields    []string
	hooks     []Hook
	mutation  *PostCategoryMutation
	modifiers []func(*sql.UpdateBuilder)
}

// SetDeletedAt sets the "deleted_at" field.
func (_u *PostCategoryUpdateOne) SetDeletedAt(v time.Time) *PostCategoryUpdateOne {
	_u.mutation.SetDeletedAt(v)
	return _u
}

// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_u *PostCategoryUpdateOne) SetNillableDeletedAt(v *time.Time) *PostCategoryUpdateOne {
	if v != nil {
		_u.SetDeletedAt(*v)
	}
	return _u
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (_u *PostCategoryUpdateOne) ClearDeletedAt() *PostCategoryUpdateOne {
	_u.mutation.ClearDeletedAt()
	return _u
}

// SetUpdatedAt sets the "updated_at" field.
func (_u *PostCategoryUpdateOne) SetUpdatedAt(v time.Time) *PostCategoryUpdateOne {
	_u.mutation.SetUpdatedAt(v)
	return _u
}

// SetName sets the "name" field.
func (_u *PostCategoryUpdateOne) SetName(v string) *PostCategoryUpdateOne {
	_u.mutation.SetName(v)
	return _u
}

// SetNillableName sets the "name" field if the given value is not nil.
func (_u *PostCategoryUpdateOne) SetNillableName(v *string) *PostCategoryUpdateOne {
	if v != nil {
		_u.SetName(*v)
	}
	return _u
}

// SetDescription sets the "description" field.
func (_u *PostCategoryUpdateOne) SetDescription(v string) *PostCategoryUpdateOne {
	_u.mutation.SetDescription(v)
	return _u
}

// SetNillableDescription sets the "description" field if the given value is not nil.
func (_u *PostCategoryUpdateOne) SetNillableDescription(v *string) *PostCategoryUpdateOne {
	if v != nil {
		_u.SetDescription(*v)
	}
	return _u
}

// ClearDescription clears the value of the "description" field.
func (_u *PostCategoryUpdateOne) ClearDescription() *PostCategoryUpdateOne {
	_u.mutation.ClearDescription()
	return _u
}

// SetCount sets the "count" field.
func (_u *PostCategoryUpdateOne) SetCount(v int) *PostCategoryUpdateOne {
	_u.mutation.ResetCount()
	_u.mutation.SetCount(v)
	return _u
}

// SetNillableCount sets the "count" field if the given value is not nil.
func (_u *PostCategoryUpdateOne) SetNillableCount(v *int) *PostCategoryUpdateOne {
	if v != nil {
		_u.SetCount(*v)
	}
	return _u
}

// AddCount adds value to the "count" field.
func (_u *PostCategoryUpdateOne) AddCount(v int) *PostCategoryUpdateOne {
	_u.mutation.AddCount(v)
	return _u
}

// SetIsSeries sets the "is_series" field.
func (_u *PostCategoryUpdateOne) SetIsSeries(v bool) *PostCategoryUpdateOne {
	_u.mutation.SetIsSeries(v)
	return _u
}

// SetNillableIsSeries sets the "is_series" field if the given value is not nil.
func (_u *PostCategoryUpdateOne) SetNillableIsSeries(v *bool) *PostCategoryUpdateOne {
	if v != nil {
		_u.SetIsSeries(*v)
	}
	return _u
}

// AddArticleIDs adds the "articles" edge to the Article entity by IDs.
func (_u *PostCategoryUpdateOne) AddArticleIDs(ids ...uint) *PostCategoryUpdateOne {
	_u.mutation.AddArticleIDs(ids...)
	return _u
}

// AddArticles adds the "articles" edges to the Article entity.
func (_u *PostCategoryUpdateOne) AddArticles(v ...*Article) *PostCategoryUpdateOne {
	ids := make([]uint, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _u.AddArticleIDs(ids...)
}

// Mutation returns the PostCategoryMutation object of the builder.
func (_u *PostCategoryUpdateOne) Mutation() *PostCategoryMutation {
	return _u.mutation
}

// ClearArticles clears all "articles" edges to the Article entity.
func (_u *PostCategoryUpdateOne) ClearArticles() *PostCategoryUpdateOne {
	_u.mutation.ClearArticles()
	return _u
}

// RemoveArticleIDs removes the "articles" edge to Article entities by IDs.
func (_u *PostCategoryUpdateOne) RemoveArticleIDs(ids ...uint) *PostCategoryUpdateOne {
	_u.mutation.RemoveArticleIDs(ids...)
	return _u
}

// RemoveArticles removes "articles" edges to Article entities.
func (_u *PostCategoryUpdateOne) RemoveArticles(v ...*Article) *PostCategoryUpdateOne {
	ids := make([]uint, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _u.RemoveArticleIDs(ids...)
}

// Where appends a list predicates to the PostCategoryUpdate builder.
func (_u *PostCategoryUpdateOne) Where(ps ...predicate.PostCategory) *PostCategoryUpdateOne {
	_u.mutation.Where(ps...)
	return _u
}

// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *PostCategoryUpdateOne) Select(field string, fields ...string) *PostCategoryUpdateOne {
	_u.fields = append([]string{field}, fields...)
	return _u
}

// Save executes the query and returns the updated PostCategory entity.
func (_u *PostCategoryUpdateOne) Save(ctx context.Context) (*PostCategory, error) {
	if err := _u.defaults(); err != nil {
		return nil, err
	}
	return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}

// SaveX is like Save, but panics if an error occurs.
func (_u *PostCategoryUpdateOne) SaveX(ctx context.Context) *PostCategory {
	node, err := _u.Save(ctx)
	if err != nil {
		panic(err)
	}
	return node
}

// Exec executes the query on the entity.
func (_u *PostCategoryUpdateOne) Exec(ctx context.Context) error {
	_, err := _u.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (_u *PostCategoryUpdateOne) ExecX(ctx context.Context) {
	if err := _u.Exec(ctx); err != nil {
		panic(err)
	}
}

// defaults sets the default values of the builder before save.
func (_u *PostCategoryUpdateOne) defaults() error {
	if _, ok := _u.mutation.UpdatedAt(); !ok {
		if postcategory.UpdateDefaultUpdatedAt == nil {
			return fmt.Errorf("ent: uninitialized postcategory.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
		}
		v := postcategory.UpdateDefaultUpdatedAt()
		_u.mutation.SetUpdatedAt(v)
	}
	return nil
}

// check runs all checks and user-defined validators on the builder.
func (_u *PostCategoryUpdateOne) check() error {
	if v, ok := _u.mutation.Name(); ok {
		if err := postcategory.NameValidator(v); err != nil {
			return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "PostCategory.name": %w`, err)}
		}
	}
	if v, ok := _u.mutation.Count(); ok {
		if err := postcategory.CountValidator(v); err != nil {
			return &ValidationError{Name: "count", err: fmt.Errorf(`ent: validator failed for field "PostCategory.count": %w`, err)}
		}
	}
	return nil
}

// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *PostCategoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PostCategoryUpdateOne {
	_u.modifiers = append(_u.modifiers, modifiers...)
	return _u
}

func (_u *PostCategoryUpdateOne) sqlSave(ctx context.Context) (_node *PostCategory, err error) {
	if err := _u.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(postcategory.Table, postcategory.Columns, sqlgraph.NewFieldSpec(postcategory.FieldID, field.TypeUint))
	id, ok := _u.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PostCategory.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := _u.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, postcategory.FieldID)
		for _, f := range fields {
			if !postcategory.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != postcategory.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := _u.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := _u.mutation.DeletedAt(); ok {
		_spec.SetField(postcategory.FieldDeletedAt, field.TypeTime, value)
	}
	if _u.mutation.DeletedAtCleared() {
		_spec.ClearField(postcategory.FieldDeletedAt, field.TypeTime)
	}
	if value, ok := _u.mutation.UpdatedAt(); ok {
		_spec.SetField(postcategory.FieldUpdatedAt, field.TypeTime, value)
	}
	if value, ok := _u.mutation.Name(); ok {
		_spec.SetField(postcategory.FieldName, field.TypeString, value)
	}
	if value, ok := _u.mutation.Description(); ok {
		_spec.SetField(postcategory.FieldDescription, field.TypeString, value)
	}
	if _u.mutation.DescriptionCleared() {
		_spec.ClearField(postcategory.FieldDescription, field.TypeString)
	}
	if value, ok := _u.mutation.Count(); ok {
		_spec.SetField(postcategory.FieldCount, field.TypeInt, value)
	}
	if value, ok := _u.mutation.AddedCount(); ok {
		_spec.AddField(postcategory.FieldCount, field.TypeInt, value)
	}
	if value, ok := _u.mutation.IsSeries(); ok {
		_spec.SetField(postcategory.FieldIsSeries, field.TypeBool, value)
	}
	if _u.mutation.ArticlesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   postcategory.ArticlesTable,
			Columns: postcategory.ArticlesPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(article.FieldID, field.TypeUint),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := _u.mutation.RemovedArticlesIDs(); len(nodes) > 0 && !_u.mutation.ArticlesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   postcategory.ArticlesTable,
			Columns: postcategory.ArticlesPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(article.FieldID, field.TypeUint),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := _u.mutation.ArticlesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   postcategory.ArticlesTable,
			Columns: postcategory.ArticlesPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(article.FieldID, field.TypeUint),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	_spec.AddModifiers(_u.modifiers...)
	_node = &PostCategory{config: _u.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{postcategory.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	_u.mutation.done = true
	return _node, nil
}
