// 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/comment"
	"github.com/anzhiyu-c/anheyu-app/ent/postcategory"
	"github.com/anzhiyu-c/anheyu-app/ent/posttag"
)

// ArticleCreate is the builder for creating a Article entity.
type ArticleCreate struct {
	config
	mutation *ArticleMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

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

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

// SetCreatedAt sets the "created_at" field.
func (_c *ArticleCreate) SetCreatedAt(v time.Time) *ArticleCreate {
	_c.mutation.SetCreatedAt(v)
	return _c
}

// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableCreatedAt(v *time.Time) *ArticleCreate {
	if v != nil {
		_c.SetCreatedAt(*v)
	}
	return _c
}

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

// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableUpdatedAt(v *time.Time) *ArticleCreate {
	if v != nil {
		_c.SetUpdatedAt(*v)
	}
	return _c
}

// SetTitle sets the "title" field.
func (_c *ArticleCreate) SetTitle(v string) *ArticleCreate {
	_c.mutation.SetTitle(v)
	return _c
}

// SetContentMd sets the "content_md" field.
func (_c *ArticleCreate) SetContentMd(v string) *ArticleCreate {
	_c.mutation.SetContentMd(v)
	return _c
}

// SetNillableContentMd sets the "content_md" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableContentMd(v *string) *ArticleCreate {
	if v != nil {
		_c.SetContentMd(*v)
	}
	return _c
}

// SetContentHTML sets the "content_html" field.
func (_c *ArticleCreate) SetContentHTML(v string) *ArticleCreate {
	_c.mutation.SetContentHTML(v)
	return _c
}

// SetNillableContentHTML sets the "content_html" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableContentHTML(v *string) *ArticleCreate {
	if v != nil {
		_c.SetContentHTML(*v)
	}
	return _c
}

// SetCoverURL sets the "cover_url" field.
func (_c *ArticleCreate) SetCoverURL(v string) *ArticleCreate {
	_c.mutation.SetCoverURL(v)
	return _c
}

// SetNillableCoverURL sets the "cover_url" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableCoverURL(v *string) *ArticleCreate {
	if v != nil {
		_c.SetCoverURL(*v)
	}
	return _c
}

// SetStatus sets the "status" field.
func (_c *ArticleCreate) SetStatus(v article.Status) *ArticleCreate {
	_c.mutation.SetStatus(v)
	return _c
}

// SetNillableStatus sets the "status" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableStatus(v *article.Status) *ArticleCreate {
	if v != nil {
		_c.SetStatus(*v)
	}
	return _c
}

// SetViewCount sets the "view_count" field.
func (_c *ArticleCreate) SetViewCount(v int) *ArticleCreate {
	_c.mutation.SetViewCount(v)
	return _c
}

// SetNillableViewCount sets the "view_count" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableViewCount(v *int) *ArticleCreate {
	if v != nil {
		_c.SetViewCount(*v)
	}
	return _c
}

// SetWordCount sets the "word_count" field.
func (_c *ArticleCreate) SetWordCount(v int) *ArticleCreate {
	_c.mutation.SetWordCount(v)
	return _c
}

// SetNillableWordCount sets the "word_count" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableWordCount(v *int) *ArticleCreate {
	if v != nil {
		_c.SetWordCount(*v)
	}
	return _c
}

// SetReadingTime sets the "reading_time" field.
func (_c *ArticleCreate) SetReadingTime(v int) *ArticleCreate {
	_c.mutation.SetReadingTime(v)
	return _c
}

// SetNillableReadingTime sets the "reading_time" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableReadingTime(v *int) *ArticleCreate {
	if v != nil {
		_c.SetReadingTime(*v)
	}
	return _c
}

// SetIPLocation sets the "ip_location" field.
func (_c *ArticleCreate) SetIPLocation(v string) *ArticleCreate {
	_c.mutation.SetIPLocation(v)
	return _c
}

// SetNillableIPLocation sets the "ip_location" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableIPLocation(v *string) *ArticleCreate {
	if v != nil {
		_c.SetIPLocation(*v)
	}
	return _c
}

// SetPrimaryColor sets the "primary_color" field.
func (_c *ArticleCreate) SetPrimaryColor(v string) *ArticleCreate {
	_c.mutation.SetPrimaryColor(v)
	return _c
}

// SetNillablePrimaryColor sets the "primary_color" field if the given value is not nil.
func (_c *ArticleCreate) SetNillablePrimaryColor(v *string) *ArticleCreate {
	if v != nil {
		_c.SetPrimaryColor(*v)
	}
	return _c
}

// SetIsPrimaryColorManual sets the "is_primary_color_manual" field.
func (_c *ArticleCreate) SetIsPrimaryColorManual(v bool) *ArticleCreate {
	_c.mutation.SetIsPrimaryColorManual(v)
	return _c
}

// SetNillableIsPrimaryColorManual sets the "is_primary_color_manual" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableIsPrimaryColorManual(v *bool) *ArticleCreate {
	if v != nil {
		_c.SetIsPrimaryColorManual(*v)
	}
	return _c
}

// SetHomeSort sets the "home_sort" field.
func (_c *ArticleCreate) SetHomeSort(v int) *ArticleCreate {
	_c.mutation.SetHomeSort(v)
	return _c
}

// SetNillableHomeSort sets the "home_sort" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableHomeSort(v *int) *ArticleCreate {
	if v != nil {
		_c.SetHomeSort(*v)
	}
	return _c
}

// SetPinSort sets the "pin_sort" field.
func (_c *ArticleCreate) SetPinSort(v int) *ArticleCreate {
	_c.mutation.SetPinSort(v)
	return _c
}

// SetNillablePinSort sets the "pin_sort" field if the given value is not nil.
func (_c *ArticleCreate) SetNillablePinSort(v *int) *ArticleCreate {
	if v != nil {
		_c.SetPinSort(*v)
	}
	return _c
}

// SetTopImgURL sets the "top_img_url" field.
func (_c *ArticleCreate) SetTopImgURL(v string) *ArticleCreate {
	_c.mutation.SetTopImgURL(v)
	return _c
}

// SetNillableTopImgURL sets the "top_img_url" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableTopImgURL(v *string) *ArticleCreate {
	if v != nil {
		_c.SetTopImgURL(*v)
	}
	return _c
}

// SetSummaries sets the "summaries" field.
func (_c *ArticleCreate) SetSummaries(v []string) *ArticleCreate {
	_c.mutation.SetSummaries(v)
	return _c
}

// SetAbbrlink sets the "abbrlink" field.
func (_c *ArticleCreate) SetAbbrlink(v string) *ArticleCreate {
	_c.mutation.SetAbbrlink(v)
	return _c
}

// SetNillableAbbrlink sets the "abbrlink" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableAbbrlink(v *string) *ArticleCreate {
	if v != nil {
		_c.SetAbbrlink(*v)
	}
	return _c
}

// SetCopyright sets the "copyright" field.
func (_c *ArticleCreate) SetCopyright(v bool) *ArticleCreate {
	_c.mutation.SetCopyright(v)
	return _c
}

// SetNillableCopyright sets the "copyright" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableCopyright(v *bool) *ArticleCreate {
	if v != nil {
		_c.SetCopyright(*v)
	}
	return _c
}

// SetCopyrightAuthor sets the "copyright_author" field.
func (_c *ArticleCreate) SetCopyrightAuthor(v string) *ArticleCreate {
	_c.mutation.SetCopyrightAuthor(v)
	return _c
}

// SetNillableCopyrightAuthor sets the "copyright_author" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableCopyrightAuthor(v *string) *ArticleCreate {
	if v != nil {
		_c.SetCopyrightAuthor(*v)
	}
	return _c
}

// SetCopyrightAuthorHref sets the "copyright_author_href" field.
func (_c *ArticleCreate) SetCopyrightAuthorHref(v string) *ArticleCreate {
	_c.mutation.SetCopyrightAuthorHref(v)
	return _c
}

// SetNillableCopyrightAuthorHref sets the "copyright_author_href" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableCopyrightAuthorHref(v *string) *ArticleCreate {
	if v != nil {
		_c.SetCopyrightAuthorHref(*v)
	}
	return _c
}

// SetCopyrightURL sets the "copyright_url" field.
func (_c *ArticleCreate) SetCopyrightURL(v string) *ArticleCreate {
	_c.mutation.SetCopyrightURL(v)
	return _c
}

// SetNillableCopyrightURL sets the "copyright_url" field if the given value is not nil.
func (_c *ArticleCreate) SetNillableCopyrightURL(v *string) *ArticleCreate {
	if v != nil {
		_c.SetCopyrightURL(*v)
	}
	return _c
}

// SetID sets the "id" field.
func (_c *ArticleCreate) SetID(v uint) *ArticleCreate {
	_c.mutation.SetID(v)
	return _c
}

// AddPostTagIDs adds the "post_tags" edge to the PostTag entity by IDs.
func (_c *ArticleCreate) AddPostTagIDs(ids ...uint) *ArticleCreate {
	_c.mutation.AddPostTagIDs(ids...)
	return _c
}

// AddPostTags adds the "post_tags" edges to the PostTag entity.
func (_c *ArticleCreate) AddPostTags(v ...*PostTag) *ArticleCreate {
	ids := make([]uint, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _c.AddPostTagIDs(ids...)
}

// AddPostCategoryIDs adds the "post_categories" edge to the PostCategory entity by IDs.
func (_c *ArticleCreate) AddPostCategoryIDs(ids ...uint) *ArticleCreate {
	_c.mutation.AddPostCategoryIDs(ids...)
	return _c
}

// AddPostCategories adds the "post_categories" edges to the PostCategory entity.
func (_c *ArticleCreate) AddPostCategories(v ...*PostCategory) *ArticleCreate {
	ids := make([]uint, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _c.AddPostCategoryIDs(ids...)
}

// AddCommentIDs adds the "comments" edge to the Comment entity by IDs.
func (_c *ArticleCreate) AddCommentIDs(ids ...uint) *ArticleCreate {
	_c.mutation.AddCommentIDs(ids...)
	return _c
}

// AddComments adds the "comments" edges to the Comment entity.
func (_c *ArticleCreate) AddComments(v ...*Comment) *ArticleCreate {
	ids := make([]uint, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _c.AddCommentIDs(ids...)
}

// Mutation returns the ArticleMutation object of the builder.
func (_c *ArticleCreate) Mutation() *ArticleMutation {
	return _c.mutation
}

// Save creates the Article in the database.
func (_c *ArticleCreate) Save(ctx context.Context) (*Article, error) {
	if err := _c.defaults(); err != nil {
		return nil, err
	}
	return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}

// SaveX calls Save and panics if Save returns an error.
func (_c *ArticleCreate) SaveX(ctx context.Context) *Article {
	v, err := _c.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

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

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

// defaults sets the default values of the builder before save.
func (_c *ArticleCreate) defaults() error {
	if _, ok := _c.mutation.CreatedAt(); !ok {
		if article.DefaultCreatedAt == nil {
			return fmt.Errorf("ent: uninitialized article.DefaultCreatedAt (forgotten import ent/runtime?)")
		}
		v := article.DefaultCreatedAt()
		_c.mutation.SetCreatedAt(v)
	}
	if _, ok := _c.mutation.UpdatedAt(); !ok {
		if article.DefaultUpdatedAt == nil {
			return fmt.Errorf("ent: uninitialized article.DefaultUpdatedAt (forgotten import ent/runtime?)")
		}
		v := article.DefaultUpdatedAt()
		_c.mutation.SetUpdatedAt(v)
	}
	if _, ok := _c.mutation.Status(); !ok {
		v := article.DefaultStatus
		_c.mutation.SetStatus(v)
	}
	if _, ok := _c.mutation.ViewCount(); !ok {
		v := article.DefaultViewCount
		_c.mutation.SetViewCount(v)
	}
	if _, ok := _c.mutation.WordCount(); !ok {
		v := article.DefaultWordCount
		_c.mutation.SetWordCount(v)
	}
	if _, ok := _c.mutation.ReadingTime(); !ok {
		v := article.DefaultReadingTime
		_c.mutation.SetReadingTime(v)
	}
	if _, ok := _c.mutation.PrimaryColor(); !ok {
		v := article.DefaultPrimaryColor
		_c.mutation.SetPrimaryColor(v)
	}
	if _, ok := _c.mutation.IsPrimaryColorManual(); !ok {
		v := article.DefaultIsPrimaryColorManual
		_c.mutation.SetIsPrimaryColorManual(v)
	}
	if _, ok := _c.mutation.HomeSort(); !ok {
		v := article.DefaultHomeSort
		_c.mutation.SetHomeSort(v)
	}
	if _, ok := _c.mutation.PinSort(); !ok {
		v := article.DefaultPinSort
		_c.mutation.SetPinSort(v)
	}
	if _, ok := _c.mutation.Copyright(); !ok {
		v := article.DefaultCopyright
		_c.mutation.SetCopyright(v)
	}
	return nil
}

// check runs all checks and user-defined validators on the builder.
func (_c *ArticleCreate) check() error {
	if _, ok := _c.mutation.CreatedAt(); !ok {
		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Article.created_at"`)}
	}
	if _, ok := _c.mutation.UpdatedAt(); !ok {
		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Article.updated_at"`)}
	}
	if _, ok := _c.mutation.Title(); !ok {
		return &ValidationError{Name: "title", err: errors.New(`ent: missing required field "Article.title"`)}
	}
	if v, ok := _c.mutation.Title(); ok {
		if err := article.TitleValidator(v); err != nil {
			return &ValidationError{Name: "title", err: fmt.Errorf(`ent: validator failed for field "Article.title": %w`, err)}
		}
	}
	if _, ok := _c.mutation.Status(); !ok {
		return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Article.status"`)}
	}
	if v, ok := _c.mutation.Status(); ok {
		if err := article.StatusValidator(v); err != nil {
			return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Article.status": %w`, err)}
		}
	}
	if _, ok := _c.mutation.ViewCount(); !ok {
		return &ValidationError{Name: "view_count", err: errors.New(`ent: missing required field "Article.view_count"`)}
	}
	if v, ok := _c.mutation.ViewCount(); ok {
		if err := article.ViewCountValidator(v); err != nil {
			return &ValidationError{Name: "view_count", err: fmt.Errorf(`ent: validator failed for field "Article.view_count": %w`, err)}
		}
	}
	if _, ok := _c.mutation.WordCount(); !ok {
		return &ValidationError{Name: "word_count", err: errors.New(`ent: missing required field "Article.word_count"`)}
	}
	if v, ok := _c.mutation.WordCount(); ok {
		if err := article.WordCountValidator(v); err != nil {
			return &ValidationError{Name: "word_count", err: fmt.Errorf(`ent: validator failed for field "Article.word_count": %w`, err)}
		}
	}
	if _, ok := _c.mutation.ReadingTime(); !ok {
		return &ValidationError{Name: "reading_time", err: errors.New(`ent: missing required field "Article.reading_time"`)}
	}
	if v, ok := _c.mutation.ReadingTime(); ok {
		if err := article.ReadingTimeValidator(v); err != nil {
			return &ValidationError{Name: "reading_time", err: fmt.Errorf(`ent: validator failed for field "Article.reading_time": %w`, err)}
		}
	}
	if _, ok := _c.mutation.IsPrimaryColorManual(); !ok {
		return &ValidationError{Name: "is_primary_color_manual", err: errors.New(`ent: missing required field "Article.is_primary_color_manual"`)}
	}
	if _, ok := _c.mutation.HomeSort(); !ok {
		return &ValidationError{Name: "home_sort", err: errors.New(`ent: missing required field "Article.home_sort"`)}
	}
	if v, ok := _c.mutation.HomeSort(); ok {
		if err := article.HomeSortValidator(v); err != nil {
			return &ValidationError{Name: "home_sort", err: fmt.Errorf(`ent: validator failed for field "Article.home_sort": %w`, err)}
		}
	}
	if _, ok := _c.mutation.PinSort(); !ok {
		return &ValidationError{Name: "pin_sort", err: errors.New(`ent: missing required field "Article.pin_sort"`)}
	}
	if v, ok := _c.mutation.PinSort(); ok {
		if err := article.PinSortValidator(v); err != nil {
			return &ValidationError{Name: "pin_sort", err: fmt.Errorf(`ent: validator failed for field "Article.pin_sort": %w`, err)}
		}
	}
	if _, ok := _c.mutation.Copyright(); !ok {
		return &ValidationError{Name: "copyright", err: errors.New(`ent: missing required field "Article.copyright"`)}
	}
	return nil
}

func (_c *ArticleCreate) sqlSave(ctx context.Context) (*Article, error) {
	if err := _c.check(); err != nil {
		return nil, err
	}
	_node, _spec := _c.createSpec()
	if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
		if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	if _spec.ID.Value != _node.ID {
		id := _spec.ID.Value.(int64)
		_node.ID = uint(id)
	}
	_c.mutation.id = &_node.ID
	_c.mutation.done = true
	return _node, nil
}

func (_c *ArticleCreate) createSpec() (*Article, *sqlgraph.CreateSpec) {
	var (
		_node = &Article{config: _c.config}
		_spec = sqlgraph.NewCreateSpec(article.Table, sqlgraph.NewFieldSpec(article.FieldID, field.TypeUint))
	)
	_spec.OnConflict = _c.conflict
	if id, ok := _c.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = id
	}
	if value, ok := _c.mutation.DeletedAt(); ok {
		_spec.SetField(article.FieldDeletedAt, field.TypeTime, value)
		_node.DeletedAt = &value
	}
	if value, ok := _c.mutation.CreatedAt(); ok {
		_spec.SetField(article.FieldCreatedAt, field.TypeTime, value)
		_node.CreatedAt = value
	}
	if value, ok := _c.mutation.UpdatedAt(); ok {
		_spec.SetField(article.FieldUpdatedAt, field.TypeTime, value)
		_node.UpdatedAt = value
	}
	if value, ok := _c.mutation.Title(); ok {
		_spec.SetField(article.FieldTitle, field.TypeString, value)
		_node.Title = value
	}
	if value, ok := _c.mutation.ContentMd(); ok {
		_spec.SetField(article.FieldContentMd, field.TypeString, value)
		_node.ContentMd = value
	}
	if value, ok := _c.mutation.ContentHTML(); ok {
		_spec.SetField(article.FieldContentHTML, field.TypeString, value)
		_node.ContentHTML = value
	}
	if value, ok := _c.mutation.CoverURL(); ok {
		_spec.SetField(article.FieldCoverURL, field.TypeString, value)
		_node.CoverURL = value
	}
	if value, ok := _c.mutation.Status(); ok {
		_spec.SetField(article.FieldStatus, field.TypeEnum, value)
		_node.Status = value
	}
	if value, ok := _c.mutation.ViewCount(); ok {
		_spec.SetField(article.FieldViewCount, field.TypeInt, value)
		_node.ViewCount = value
	}
	if value, ok := _c.mutation.WordCount(); ok {
		_spec.SetField(article.FieldWordCount, field.TypeInt, value)
		_node.WordCount = value
	}
	if value, ok := _c.mutation.ReadingTime(); ok {
		_spec.SetField(article.FieldReadingTime, field.TypeInt, value)
		_node.ReadingTime = value
	}
	if value, ok := _c.mutation.IPLocation(); ok {
		_spec.SetField(article.FieldIPLocation, field.TypeString, value)
		_node.IPLocation = value
	}
	if value, ok := _c.mutation.PrimaryColor(); ok {
		_spec.SetField(article.FieldPrimaryColor, field.TypeString, value)
		_node.PrimaryColor = value
	}
	if value, ok := _c.mutation.IsPrimaryColorManual(); ok {
		_spec.SetField(article.FieldIsPrimaryColorManual, field.TypeBool, value)
		_node.IsPrimaryColorManual = value
	}
	if value, ok := _c.mutation.HomeSort(); ok {
		_spec.SetField(article.FieldHomeSort, field.TypeInt, value)
		_node.HomeSort = value
	}
	if value, ok := _c.mutation.PinSort(); ok {
		_spec.SetField(article.FieldPinSort, field.TypeInt, value)
		_node.PinSort = value
	}
	if value, ok := _c.mutation.TopImgURL(); ok {
		_spec.SetField(article.FieldTopImgURL, field.TypeString, value)
		_node.TopImgURL = value
	}
	if value, ok := _c.mutation.Summaries(); ok {
		_spec.SetField(article.FieldSummaries, field.TypeJSON, value)
		_node.Summaries = value
	}
	if value, ok := _c.mutation.Abbrlink(); ok {
		_spec.SetField(article.FieldAbbrlink, field.TypeString, value)
		_node.Abbrlink = &value
	}
	if value, ok := _c.mutation.Copyright(); ok {
		_spec.SetField(article.FieldCopyright, field.TypeBool, value)
		_node.Copyright = value
	}
	if value, ok := _c.mutation.CopyrightAuthor(); ok {
		_spec.SetField(article.FieldCopyrightAuthor, field.TypeString, value)
		_node.CopyrightAuthor = value
	}
	if value, ok := _c.mutation.CopyrightAuthorHref(); ok {
		_spec.SetField(article.FieldCopyrightAuthorHref, field.TypeString, value)
		_node.CopyrightAuthorHref = value
	}
	if value, ok := _c.mutation.CopyrightURL(); ok {
		_spec.SetField(article.FieldCopyrightURL, field.TypeString, value)
		_node.CopyrightURL = value
	}
	if nodes := _c.mutation.PostTagsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: false,
			Table:   article.PostTagsTable,
			Columns: article.PostTagsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(posttag.FieldID, field.TypeUint),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := _c.mutation.PostCategoriesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: false,
			Table:   article.PostCategoriesTable,
			Columns: article.PostCategoriesPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(postcategory.FieldID, field.TypeUint),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := _c.mutation.CommentsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   article.CommentsTable,
			Columns: []string{article.CommentsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(comment.FieldID, field.TypeUint),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges = append(_spec.Edges, edge)
	}
	return _node, _spec
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.Article.Create().
//		SetDeletedAt(v).
//		OnConflict(
//			// Update the row with the new values
//			// the was proposed for insertion.
//			sql.ResolveWithNewValues(),
//		).
//		// Override some of the fields with custom
//		// update values.
//		Update(func(u *ent.ArticleUpsert) {
//			SetDeletedAt(v+v).
//		}).
//		Exec(ctx)
func (_c *ArticleCreate) OnConflict(opts ...sql.ConflictOption) *ArticleUpsertOne {
	_c.conflict = opts
	return &ArticleUpsertOne{
		create: _c,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.Article.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (_c *ArticleCreate) OnConflictColumns(columns ...string) *ArticleUpsertOne {
	_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
	return &ArticleUpsertOne{
		create: _c,
	}
}

type (
	// ArticleUpsertOne is the builder for "upsert"-ing
	//  one Article node.
	ArticleUpsertOne struct {
		create *ArticleCreate
	}

	// ArticleUpsert is the "OnConflict" setter.
	ArticleUpsert struct {
		*sql.UpdateSet
	}
)

// SetDeletedAt sets the "deleted_at" field.
func (u *ArticleUpsert) SetDeletedAt(v time.Time) *ArticleUpsert {
	u.Set(article.FieldDeletedAt, v)
	return u
}

// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateDeletedAt() *ArticleUpsert {
	u.SetExcluded(article.FieldDeletedAt)
	return u
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *ArticleUpsert) ClearDeletedAt() *ArticleUpsert {
	u.SetNull(article.FieldDeletedAt)
	return u
}

// SetUpdatedAt sets the "updated_at" field.
func (u *ArticleUpsert) SetUpdatedAt(v time.Time) *ArticleUpsert {
	u.Set(article.FieldUpdatedAt, v)
	return u
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateUpdatedAt() *ArticleUpsert {
	u.SetExcluded(article.FieldUpdatedAt)
	return u
}

// SetTitle sets the "title" field.
func (u *ArticleUpsert) SetTitle(v string) *ArticleUpsert {
	u.Set(article.FieldTitle, v)
	return u
}

// UpdateTitle sets the "title" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateTitle() *ArticleUpsert {
	u.SetExcluded(article.FieldTitle)
	return u
}

// SetContentMd sets the "content_md" field.
func (u *ArticleUpsert) SetContentMd(v string) *ArticleUpsert {
	u.Set(article.FieldContentMd, v)
	return u
}

// UpdateContentMd sets the "content_md" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateContentMd() *ArticleUpsert {
	u.SetExcluded(article.FieldContentMd)
	return u
}

// ClearContentMd clears the value of the "content_md" field.
func (u *ArticleUpsert) ClearContentMd() *ArticleUpsert {
	u.SetNull(article.FieldContentMd)
	return u
}

// SetContentHTML sets the "content_html" field.
func (u *ArticleUpsert) SetContentHTML(v string) *ArticleUpsert {
	u.Set(article.FieldContentHTML, v)
	return u
}

// UpdateContentHTML sets the "content_html" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateContentHTML() *ArticleUpsert {
	u.SetExcluded(article.FieldContentHTML)
	return u
}

// ClearContentHTML clears the value of the "content_html" field.
func (u *ArticleUpsert) ClearContentHTML() *ArticleUpsert {
	u.SetNull(article.FieldContentHTML)
	return u
}

// SetCoverURL sets the "cover_url" field.
func (u *ArticleUpsert) SetCoverURL(v string) *ArticleUpsert {
	u.Set(article.FieldCoverURL, v)
	return u
}

// UpdateCoverURL sets the "cover_url" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateCoverURL() *ArticleUpsert {
	u.SetExcluded(article.FieldCoverURL)
	return u
}

// ClearCoverURL clears the value of the "cover_url" field.
func (u *ArticleUpsert) ClearCoverURL() *ArticleUpsert {
	u.SetNull(article.FieldCoverURL)
	return u
}

// SetStatus sets the "status" field.
func (u *ArticleUpsert) SetStatus(v article.Status) *ArticleUpsert {
	u.Set(article.FieldStatus, v)
	return u
}

// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateStatus() *ArticleUpsert {
	u.SetExcluded(article.FieldStatus)
	return u
}

// SetViewCount sets the "view_count" field.
func (u *ArticleUpsert) SetViewCount(v int) *ArticleUpsert {
	u.Set(article.FieldViewCount, v)
	return u
}

// UpdateViewCount sets the "view_count" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateViewCount() *ArticleUpsert {
	u.SetExcluded(article.FieldViewCount)
	return u
}

// AddViewCount adds v to the "view_count" field.
func (u *ArticleUpsert) AddViewCount(v int) *ArticleUpsert {
	u.Add(article.FieldViewCount, v)
	return u
}

// SetWordCount sets the "word_count" field.
func (u *ArticleUpsert) SetWordCount(v int) *ArticleUpsert {
	u.Set(article.FieldWordCount, v)
	return u
}

// UpdateWordCount sets the "word_count" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateWordCount() *ArticleUpsert {
	u.SetExcluded(article.FieldWordCount)
	return u
}

// AddWordCount adds v to the "word_count" field.
func (u *ArticleUpsert) AddWordCount(v int) *ArticleUpsert {
	u.Add(article.FieldWordCount, v)
	return u
}

// SetReadingTime sets the "reading_time" field.
func (u *ArticleUpsert) SetReadingTime(v int) *ArticleUpsert {
	u.Set(article.FieldReadingTime, v)
	return u
}

// UpdateReadingTime sets the "reading_time" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateReadingTime() *ArticleUpsert {
	u.SetExcluded(article.FieldReadingTime)
	return u
}

// AddReadingTime adds v to the "reading_time" field.
func (u *ArticleUpsert) AddReadingTime(v int) *ArticleUpsert {
	u.Add(article.FieldReadingTime, v)
	return u
}

// SetIPLocation sets the "ip_location" field.
func (u *ArticleUpsert) SetIPLocation(v string) *ArticleUpsert {
	u.Set(article.FieldIPLocation, v)
	return u
}

// UpdateIPLocation sets the "ip_location" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateIPLocation() *ArticleUpsert {
	u.SetExcluded(article.FieldIPLocation)
	return u
}

// ClearIPLocation clears the value of the "ip_location" field.
func (u *ArticleUpsert) ClearIPLocation() *ArticleUpsert {
	u.SetNull(article.FieldIPLocation)
	return u
}

// SetPrimaryColor sets the "primary_color" field.
func (u *ArticleUpsert) SetPrimaryColor(v string) *ArticleUpsert {
	u.Set(article.FieldPrimaryColor, v)
	return u
}

// UpdatePrimaryColor sets the "primary_color" field to the value that was provided on create.
func (u *ArticleUpsert) UpdatePrimaryColor() *ArticleUpsert {
	u.SetExcluded(article.FieldPrimaryColor)
	return u
}

// ClearPrimaryColor clears the value of the "primary_color" field.
func (u *ArticleUpsert) ClearPrimaryColor() *ArticleUpsert {
	u.SetNull(article.FieldPrimaryColor)
	return u
}

// SetIsPrimaryColorManual sets the "is_primary_color_manual" field.
func (u *ArticleUpsert) SetIsPrimaryColorManual(v bool) *ArticleUpsert {
	u.Set(article.FieldIsPrimaryColorManual, v)
	return u
}

// UpdateIsPrimaryColorManual sets the "is_primary_color_manual" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateIsPrimaryColorManual() *ArticleUpsert {
	u.SetExcluded(article.FieldIsPrimaryColorManual)
	return u
}

// SetHomeSort sets the "home_sort" field.
func (u *ArticleUpsert) SetHomeSort(v int) *ArticleUpsert {
	u.Set(article.FieldHomeSort, v)
	return u
}

// UpdateHomeSort sets the "home_sort" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateHomeSort() *ArticleUpsert {
	u.SetExcluded(article.FieldHomeSort)
	return u
}

// AddHomeSort adds v to the "home_sort" field.
func (u *ArticleUpsert) AddHomeSort(v int) *ArticleUpsert {
	u.Add(article.FieldHomeSort, v)
	return u
}

// SetPinSort sets the "pin_sort" field.
func (u *ArticleUpsert) SetPinSort(v int) *ArticleUpsert {
	u.Set(article.FieldPinSort, v)
	return u
}

// UpdatePinSort sets the "pin_sort" field to the value that was provided on create.
func (u *ArticleUpsert) UpdatePinSort() *ArticleUpsert {
	u.SetExcluded(article.FieldPinSort)
	return u
}

// AddPinSort adds v to the "pin_sort" field.
func (u *ArticleUpsert) AddPinSort(v int) *ArticleUpsert {
	u.Add(article.FieldPinSort, v)
	return u
}

// SetTopImgURL sets the "top_img_url" field.
func (u *ArticleUpsert) SetTopImgURL(v string) *ArticleUpsert {
	u.Set(article.FieldTopImgURL, v)
	return u
}

// UpdateTopImgURL sets the "top_img_url" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateTopImgURL() *ArticleUpsert {
	u.SetExcluded(article.FieldTopImgURL)
	return u
}

// ClearTopImgURL clears the value of the "top_img_url" field.
func (u *ArticleUpsert) ClearTopImgURL() *ArticleUpsert {
	u.SetNull(article.FieldTopImgURL)
	return u
}

// SetSummaries sets the "summaries" field.
func (u *ArticleUpsert) SetSummaries(v []string) *ArticleUpsert {
	u.Set(article.FieldSummaries, v)
	return u
}

// UpdateSummaries sets the "summaries" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateSummaries() *ArticleUpsert {
	u.SetExcluded(article.FieldSummaries)
	return u
}

// ClearSummaries clears the value of the "summaries" field.
func (u *ArticleUpsert) ClearSummaries() *ArticleUpsert {
	u.SetNull(article.FieldSummaries)
	return u
}

// SetAbbrlink sets the "abbrlink" field.
func (u *ArticleUpsert) SetAbbrlink(v string) *ArticleUpsert {
	u.Set(article.FieldAbbrlink, v)
	return u
}

// UpdateAbbrlink sets the "abbrlink" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateAbbrlink() *ArticleUpsert {
	u.SetExcluded(article.FieldAbbrlink)
	return u
}

// ClearAbbrlink clears the value of the "abbrlink" field.
func (u *ArticleUpsert) ClearAbbrlink() *ArticleUpsert {
	u.SetNull(article.FieldAbbrlink)
	return u
}

// SetCopyright sets the "copyright" field.
func (u *ArticleUpsert) SetCopyright(v bool) *ArticleUpsert {
	u.Set(article.FieldCopyright, v)
	return u
}

// UpdateCopyright sets the "copyright" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateCopyright() *ArticleUpsert {
	u.SetExcluded(article.FieldCopyright)
	return u
}

// SetCopyrightAuthor sets the "copyright_author" field.
func (u *ArticleUpsert) SetCopyrightAuthor(v string) *ArticleUpsert {
	u.Set(article.FieldCopyrightAuthor, v)
	return u
}

// UpdateCopyrightAuthor sets the "copyright_author" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateCopyrightAuthor() *ArticleUpsert {
	u.SetExcluded(article.FieldCopyrightAuthor)
	return u
}

// ClearCopyrightAuthor clears the value of the "copyright_author" field.
func (u *ArticleUpsert) ClearCopyrightAuthor() *ArticleUpsert {
	u.SetNull(article.FieldCopyrightAuthor)
	return u
}

// SetCopyrightAuthorHref sets the "copyright_author_href" field.
func (u *ArticleUpsert) SetCopyrightAuthorHref(v string) *ArticleUpsert {
	u.Set(article.FieldCopyrightAuthorHref, v)
	return u
}

// UpdateCopyrightAuthorHref sets the "copyright_author_href" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateCopyrightAuthorHref() *ArticleUpsert {
	u.SetExcluded(article.FieldCopyrightAuthorHref)
	return u
}

// ClearCopyrightAuthorHref clears the value of the "copyright_author_href" field.
func (u *ArticleUpsert) ClearCopyrightAuthorHref() *ArticleUpsert {
	u.SetNull(article.FieldCopyrightAuthorHref)
	return u
}

// SetCopyrightURL sets the "copyright_url" field.
func (u *ArticleUpsert) SetCopyrightURL(v string) *ArticleUpsert {
	u.Set(article.FieldCopyrightURL, v)
	return u
}

// UpdateCopyrightURL sets the "copyright_url" field to the value that was provided on create.
func (u *ArticleUpsert) UpdateCopyrightURL() *ArticleUpsert {
	u.SetExcluded(article.FieldCopyrightURL)
	return u
}

// ClearCopyrightURL clears the value of the "copyright_url" field.
func (u *ArticleUpsert) ClearCopyrightURL() *ArticleUpsert {
	u.SetNull(article.FieldCopyrightURL)
	return u
}

// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
// Using this option is equivalent to using:
//
//	client.Article.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(article.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *ArticleUpsertOne) UpdateNewValues() *ArticleUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		if _, exists := u.create.mutation.ID(); exists {
			s.SetIgnore(article.FieldID)
		}
		if _, exists := u.create.mutation.CreatedAt(); exists {
			s.SetIgnore(article.FieldCreatedAt)
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.Article.Create().
//	    OnConflict(sql.ResolveWithIgnore()).
//	    Exec(ctx)
func (u *ArticleUpsertOne) Ignore() *ArticleUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
	return u
}

// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *ArticleUpsertOne) DoNothing() *ArticleUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the ArticleCreate.OnConflict
// documentation for more info.
func (u *ArticleUpsertOne) Update(set func(*ArticleUpsert)) *ArticleUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&ArticleUpsert{UpdateSet: update})
	}))
	return u
}

// SetDeletedAt sets the "deleted_at" field.
func (u *ArticleUpsertOne) SetDeletedAt(v time.Time) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetDeletedAt(v)
	})
}

// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateDeletedAt() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateDeletedAt()
	})
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *ArticleUpsertOne) ClearDeletedAt() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearDeletedAt()
	})
}

// SetUpdatedAt sets the "updated_at" field.
func (u *ArticleUpsertOne) SetUpdatedAt(v time.Time) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetUpdatedAt(v)
	})
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateUpdatedAt() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateUpdatedAt()
	})
}

// SetTitle sets the "title" field.
func (u *ArticleUpsertOne) SetTitle(v string) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetTitle(v)
	})
}

// UpdateTitle sets the "title" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateTitle() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateTitle()
	})
}

// SetContentMd sets the "content_md" field.
func (u *ArticleUpsertOne) SetContentMd(v string) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetContentMd(v)
	})
}

// UpdateContentMd sets the "content_md" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateContentMd() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateContentMd()
	})
}

// ClearContentMd clears the value of the "content_md" field.
func (u *ArticleUpsertOne) ClearContentMd() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearContentMd()
	})
}

// SetContentHTML sets the "content_html" field.
func (u *ArticleUpsertOne) SetContentHTML(v string) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetContentHTML(v)
	})
}

// UpdateContentHTML sets the "content_html" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateContentHTML() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateContentHTML()
	})
}

// ClearContentHTML clears the value of the "content_html" field.
func (u *ArticleUpsertOne) ClearContentHTML() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearContentHTML()
	})
}

// SetCoverURL sets the "cover_url" field.
func (u *ArticleUpsertOne) SetCoverURL(v string) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetCoverURL(v)
	})
}

// UpdateCoverURL sets the "cover_url" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateCoverURL() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateCoverURL()
	})
}

// ClearCoverURL clears the value of the "cover_url" field.
func (u *ArticleUpsertOne) ClearCoverURL() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearCoverURL()
	})
}

// SetStatus sets the "status" field.
func (u *ArticleUpsertOne) SetStatus(v article.Status) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetStatus(v)
	})
}

// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateStatus() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateStatus()
	})
}

// SetViewCount sets the "view_count" field.
func (u *ArticleUpsertOne) SetViewCount(v int) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetViewCount(v)
	})
}

// AddViewCount adds v to the "view_count" field.
func (u *ArticleUpsertOne) AddViewCount(v int) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.AddViewCount(v)
	})
}

// UpdateViewCount sets the "view_count" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateViewCount() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateViewCount()
	})
}

// SetWordCount sets the "word_count" field.
func (u *ArticleUpsertOne) SetWordCount(v int) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetWordCount(v)
	})
}

// AddWordCount adds v to the "word_count" field.
func (u *ArticleUpsertOne) AddWordCount(v int) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.AddWordCount(v)
	})
}

// UpdateWordCount sets the "word_count" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateWordCount() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateWordCount()
	})
}

// SetReadingTime sets the "reading_time" field.
func (u *ArticleUpsertOne) SetReadingTime(v int) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetReadingTime(v)
	})
}

// AddReadingTime adds v to the "reading_time" field.
func (u *ArticleUpsertOne) AddReadingTime(v int) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.AddReadingTime(v)
	})
}

// UpdateReadingTime sets the "reading_time" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateReadingTime() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateReadingTime()
	})
}

// SetIPLocation sets the "ip_location" field.
func (u *ArticleUpsertOne) SetIPLocation(v string) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetIPLocation(v)
	})
}

// UpdateIPLocation sets the "ip_location" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateIPLocation() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateIPLocation()
	})
}

// ClearIPLocation clears the value of the "ip_location" field.
func (u *ArticleUpsertOne) ClearIPLocation() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearIPLocation()
	})
}

// SetPrimaryColor sets the "primary_color" field.
func (u *ArticleUpsertOne) SetPrimaryColor(v string) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetPrimaryColor(v)
	})
}

// UpdatePrimaryColor sets the "primary_color" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdatePrimaryColor() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdatePrimaryColor()
	})
}

// ClearPrimaryColor clears the value of the "primary_color" field.
func (u *ArticleUpsertOne) ClearPrimaryColor() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearPrimaryColor()
	})
}

// SetIsPrimaryColorManual sets the "is_primary_color_manual" field.
func (u *ArticleUpsertOne) SetIsPrimaryColorManual(v bool) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetIsPrimaryColorManual(v)
	})
}

// UpdateIsPrimaryColorManual sets the "is_primary_color_manual" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateIsPrimaryColorManual() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateIsPrimaryColorManual()
	})
}

// SetHomeSort sets the "home_sort" field.
func (u *ArticleUpsertOne) SetHomeSort(v int) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetHomeSort(v)
	})
}

// AddHomeSort adds v to the "home_sort" field.
func (u *ArticleUpsertOne) AddHomeSort(v int) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.AddHomeSort(v)
	})
}

// UpdateHomeSort sets the "home_sort" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateHomeSort() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateHomeSort()
	})
}

// SetPinSort sets the "pin_sort" field.
func (u *ArticleUpsertOne) SetPinSort(v int) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetPinSort(v)
	})
}

// AddPinSort adds v to the "pin_sort" field.
func (u *ArticleUpsertOne) AddPinSort(v int) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.AddPinSort(v)
	})
}

// UpdatePinSort sets the "pin_sort" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdatePinSort() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdatePinSort()
	})
}

// SetTopImgURL sets the "top_img_url" field.
func (u *ArticleUpsertOne) SetTopImgURL(v string) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetTopImgURL(v)
	})
}

// UpdateTopImgURL sets the "top_img_url" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateTopImgURL() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateTopImgURL()
	})
}

// ClearTopImgURL clears the value of the "top_img_url" field.
func (u *ArticleUpsertOne) ClearTopImgURL() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearTopImgURL()
	})
}

// SetSummaries sets the "summaries" field.
func (u *ArticleUpsertOne) SetSummaries(v []string) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetSummaries(v)
	})
}

// UpdateSummaries sets the "summaries" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateSummaries() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateSummaries()
	})
}

// ClearSummaries clears the value of the "summaries" field.
func (u *ArticleUpsertOne) ClearSummaries() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearSummaries()
	})
}

// SetAbbrlink sets the "abbrlink" field.
func (u *ArticleUpsertOne) SetAbbrlink(v string) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetAbbrlink(v)
	})
}

// UpdateAbbrlink sets the "abbrlink" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateAbbrlink() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateAbbrlink()
	})
}

// ClearAbbrlink clears the value of the "abbrlink" field.
func (u *ArticleUpsertOne) ClearAbbrlink() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearAbbrlink()
	})
}

// SetCopyright sets the "copyright" field.
func (u *ArticleUpsertOne) SetCopyright(v bool) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetCopyright(v)
	})
}

// UpdateCopyright sets the "copyright" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateCopyright() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateCopyright()
	})
}

// SetCopyrightAuthor sets the "copyright_author" field.
func (u *ArticleUpsertOne) SetCopyrightAuthor(v string) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetCopyrightAuthor(v)
	})
}

// UpdateCopyrightAuthor sets the "copyright_author" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateCopyrightAuthor() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateCopyrightAuthor()
	})
}

// ClearCopyrightAuthor clears the value of the "copyright_author" field.
func (u *ArticleUpsertOne) ClearCopyrightAuthor() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearCopyrightAuthor()
	})
}

// SetCopyrightAuthorHref sets the "copyright_author_href" field.
func (u *ArticleUpsertOne) SetCopyrightAuthorHref(v string) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetCopyrightAuthorHref(v)
	})
}

// UpdateCopyrightAuthorHref sets the "copyright_author_href" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateCopyrightAuthorHref() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateCopyrightAuthorHref()
	})
}

// ClearCopyrightAuthorHref clears the value of the "copyright_author_href" field.
func (u *ArticleUpsertOne) ClearCopyrightAuthorHref() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearCopyrightAuthorHref()
	})
}

// SetCopyrightURL sets the "copyright_url" field.
func (u *ArticleUpsertOne) SetCopyrightURL(v string) *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.SetCopyrightURL(v)
	})
}

// UpdateCopyrightURL sets the "copyright_url" field to the value that was provided on create.
func (u *ArticleUpsertOne) UpdateCopyrightURL() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateCopyrightURL()
	})
}

// ClearCopyrightURL clears the value of the "copyright_url" field.
func (u *ArticleUpsertOne) ClearCopyrightURL() *ArticleUpsertOne {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearCopyrightURL()
	})
}

// Exec executes the query.
func (u *ArticleUpsertOne) Exec(ctx context.Context) error {
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for ArticleCreate.OnConflict")
	}
	return u.create.Exec(ctx)
}

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

// Exec executes the UPSERT query and returns the inserted/updated ID.
func (u *ArticleUpsertOne) ID(ctx context.Context) (id uint, err error) {
	node, err := u.create.Save(ctx)
	if err != nil {
		return id, err
	}
	return node.ID, nil
}

// IDX is like ID, but panics if an error occurs.
func (u *ArticleUpsertOne) IDX(ctx context.Context) uint {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

// ArticleCreateBulk is the builder for creating many Article entities in bulk.
type ArticleCreateBulk struct {
	config
	err      error
	builders []*ArticleCreate
	conflict []sql.ConflictOption
}

// Save creates the Article entities in the database.
func (_c *ArticleCreateBulk) Save(ctx context.Context) ([]*Article, error) {
	if _c.err != nil {
		return nil, _c.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
	nodes := make([]*Article, len(_c.builders))
	mutators := make([]Mutator, len(_c.builders))
	for i := range _c.builders {
		func(i int, root context.Context) {
			builder := _c.builders[i]
			builder.defaults()
			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
				mutation, ok := m.(*ArticleMutation)
				if !ok {
					return nil, fmt.Errorf("unexpected mutation type %T", m)
				}
				if err := builder.check(); err != nil {
					return nil, err
				}
				builder.mutation = mutation
				var err error
				nodes[i], specs[i] = builder.createSpec()
				if i < len(mutators)-1 {
					_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
				} else {
					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
					spec.OnConflict = _c.conflict
					// Invoke the actual operation on the latest mutation in the chain.
					if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
						if sqlgraph.IsConstraintError(err) {
							err = &ConstraintError{msg: err.Error(), wrap: err}
						}
					}
				}
				if err != nil {
					return nil, err
				}
				mutation.id = &nodes[i].ID
				if specs[i].ID.Value != nil && nodes[i].ID == 0 {
					id := specs[i].ID.Value.(int64)
					nodes[i].ID = uint(id)
				}
				mutation.done = true
				return nodes[i], nil
			})
			for i := len(builder.hooks) - 1; i >= 0; i-- {
				mut = builder.hooks[i](mut)
			}
			mutators[i] = mut
		}(i, ctx)
	}
	if len(mutators) > 0 {
		if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
			return nil, err
		}
	}
	return nodes, nil
}

// SaveX is like Save, but panics if an error occurs.
func (_c *ArticleCreateBulk) SaveX(ctx context.Context) []*Article {
	v, err := _c.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

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

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

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.Article.CreateBulk(builders...).
//		OnConflict(
//			// Update the row with the new values
//			// the was proposed for insertion.
//			sql.ResolveWithNewValues(),
//		).
//		// Override some of the fields with custom
//		// update values.
//		Update(func(u *ent.ArticleUpsert) {
//			SetDeletedAt(v+v).
//		}).
//		Exec(ctx)
func (_c *ArticleCreateBulk) OnConflict(opts ...sql.ConflictOption) *ArticleUpsertBulk {
	_c.conflict = opts
	return &ArticleUpsertBulk{
		create: _c,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.Article.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (_c *ArticleCreateBulk) OnConflictColumns(columns ...string) *ArticleUpsertBulk {
	_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
	return &ArticleUpsertBulk{
		create: _c,
	}
}

// ArticleUpsertBulk is the builder for "upsert"-ing
// a bulk of Article nodes.
type ArticleUpsertBulk struct {
	create *ArticleCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.Article.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(article.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *ArticleUpsertBulk) UpdateNewValues() *ArticleUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		for _, b := range u.create.builders {
			if _, exists := b.mutation.ID(); exists {
				s.SetIgnore(article.FieldID)
			}
			if _, exists := b.mutation.CreatedAt(); exists {
				s.SetIgnore(article.FieldCreatedAt)
			}
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.Article.Create().
//		OnConflict(sql.ResolveWithIgnore()).
//		Exec(ctx)
func (u *ArticleUpsertBulk) Ignore() *ArticleUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
	return u
}

// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *ArticleUpsertBulk) DoNothing() *ArticleUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the ArticleCreateBulk.OnConflict
// documentation for more info.
func (u *ArticleUpsertBulk) Update(set func(*ArticleUpsert)) *ArticleUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&ArticleUpsert{UpdateSet: update})
	}))
	return u
}

// SetDeletedAt sets the "deleted_at" field.
func (u *ArticleUpsertBulk) SetDeletedAt(v time.Time) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetDeletedAt(v)
	})
}

// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateDeletedAt() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateDeletedAt()
	})
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *ArticleUpsertBulk) ClearDeletedAt() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearDeletedAt()
	})
}

// SetUpdatedAt sets the "updated_at" field.
func (u *ArticleUpsertBulk) SetUpdatedAt(v time.Time) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetUpdatedAt(v)
	})
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateUpdatedAt() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateUpdatedAt()
	})
}

// SetTitle sets the "title" field.
func (u *ArticleUpsertBulk) SetTitle(v string) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetTitle(v)
	})
}

// UpdateTitle sets the "title" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateTitle() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateTitle()
	})
}

// SetContentMd sets the "content_md" field.
func (u *ArticleUpsertBulk) SetContentMd(v string) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetContentMd(v)
	})
}

// UpdateContentMd sets the "content_md" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateContentMd() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateContentMd()
	})
}

// ClearContentMd clears the value of the "content_md" field.
func (u *ArticleUpsertBulk) ClearContentMd() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearContentMd()
	})
}

// SetContentHTML sets the "content_html" field.
func (u *ArticleUpsertBulk) SetContentHTML(v string) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetContentHTML(v)
	})
}

// UpdateContentHTML sets the "content_html" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateContentHTML() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateContentHTML()
	})
}

// ClearContentHTML clears the value of the "content_html" field.
func (u *ArticleUpsertBulk) ClearContentHTML() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearContentHTML()
	})
}

// SetCoverURL sets the "cover_url" field.
func (u *ArticleUpsertBulk) SetCoverURL(v string) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetCoverURL(v)
	})
}

// UpdateCoverURL sets the "cover_url" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateCoverURL() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateCoverURL()
	})
}

// ClearCoverURL clears the value of the "cover_url" field.
func (u *ArticleUpsertBulk) ClearCoverURL() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearCoverURL()
	})
}

// SetStatus sets the "status" field.
func (u *ArticleUpsertBulk) SetStatus(v article.Status) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetStatus(v)
	})
}

// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateStatus() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateStatus()
	})
}

// SetViewCount sets the "view_count" field.
func (u *ArticleUpsertBulk) SetViewCount(v int) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetViewCount(v)
	})
}

// AddViewCount adds v to the "view_count" field.
func (u *ArticleUpsertBulk) AddViewCount(v int) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.AddViewCount(v)
	})
}

// UpdateViewCount sets the "view_count" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateViewCount() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateViewCount()
	})
}

// SetWordCount sets the "word_count" field.
func (u *ArticleUpsertBulk) SetWordCount(v int) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetWordCount(v)
	})
}

// AddWordCount adds v to the "word_count" field.
func (u *ArticleUpsertBulk) AddWordCount(v int) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.AddWordCount(v)
	})
}

// UpdateWordCount sets the "word_count" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateWordCount() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateWordCount()
	})
}

// SetReadingTime sets the "reading_time" field.
func (u *ArticleUpsertBulk) SetReadingTime(v int) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetReadingTime(v)
	})
}

// AddReadingTime adds v to the "reading_time" field.
func (u *ArticleUpsertBulk) AddReadingTime(v int) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.AddReadingTime(v)
	})
}

// UpdateReadingTime sets the "reading_time" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateReadingTime() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateReadingTime()
	})
}

// SetIPLocation sets the "ip_location" field.
func (u *ArticleUpsertBulk) SetIPLocation(v string) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetIPLocation(v)
	})
}

// UpdateIPLocation sets the "ip_location" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateIPLocation() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateIPLocation()
	})
}

// ClearIPLocation clears the value of the "ip_location" field.
func (u *ArticleUpsertBulk) ClearIPLocation() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearIPLocation()
	})
}

// SetPrimaryColor sets the "primary_color" field.
func (u *ArticleUpsertBulk) SetPrimaryColor(v string) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetPrimaryColor(v)
	})
}

// UpdatePrimaryColor sets the "primary_color" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdatePrimaryColor() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdatePrimaryColor()
	})
}

// ClearPrimaryColor clears the value of the "primary_color" field.
func (u *ArticleUpsertBulk) ClearPrimaryColor() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearPrimaryColor()
	})
}

// SetIsPrimaryColorManual sets the "is_primary_color_manual" field.
func (u *ArticleUpsertBulk) SetIsPrimaryColorManual(v bool) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetIsPrimaryColorManual(v)
	})
}

// UpdateIsPrimaryColorManual sets the "is_primary_color_manual" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateIsPrimaryColorManual() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateIsPrimaryColorManual()
	})
}

// SetHomeSort sets the "home_sort" field.
func (u *ArticleUpsertBulk) SetHomeSort(v int) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetHomeSort(v)
	})
}

// AddHomeSort adds v to the "home_sort" field.
func (u *ArticleUpsertBulk) AddHomeSort(v int) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.AddHomeSort(v)
	})
}

// UpdateHomeSort sets the "home_sort" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateHomeSort() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateHomeSort()
	})
}

// SetPinSort sets the "pin_sort" field.
func (u *ArticleUpsertBulk) SetPinSort(v int) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetPinSort(v)
	})
}

// AddPinSort adds v to the "pin_sort" field.
func (u *ArticleUpsertBulk) AddPinSort(v int) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.AddPinSort(v)
	})
}

// UpdatePinSort sets the "pin_sort" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdatePinSort() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdatePinSort()
	})
}

// SetTopImgURL sets the "top_img_url" field.
func (u *ArticleUpsertBulk) SetTopImgURL(v string) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetTopImgURL(v)
	})
}

// UpdateTopImgURL sets the "top_img_url" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateTopImgURL() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateTopImgURL()
	})
}

// ClearTopImgURL clears the value of the "top_img_url" field.
func (u *ArticleUpsertBulk) ClearTopImgURL() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearTopImgURL()
	})
}

// SetSummaries sets the "summaries" field.
func (u *ArticleUpsertBulk) SetSummaries(v []string) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetSummaries(v)
	})
}

// UpdateSummaries sets the "summaries" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateSummaries() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateSummaries()
	})
}

// ClearSummaries clears the value of the "summaries" field.
func (u *ArticleUpsertBulk) ClearSummaries() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearSummaries()
	})
}

// SetAbbrlink sets the "abbrlink" field.
func (u *ArticleUpsertBulk) SetAbbrlink(v string) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetAbbrlink(v)
	})
}

// UpdateAbbrlink sets the "abbrlink" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateAbbrlink() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateAbbrlink()
	})
}

// ClearAbbrlink clears the value of the "abbrlink" field.
func (u *ArticleUpsertBulk) ClearAbbrlink() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearAbbrlink()
	})
}

// SetCopyright sets the "copyright" field.
func (u *ArticleUpsertBulk) SetCopyright(v bool) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetCopyright(v)
	})
}

// UpdateCopyright sets the "copyright" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateCopyright() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateCopyright()
	})
}

// SetCopyrightAuthor sets the "copyright_author" field.
func (u *ArticleUpsertBulk) SetCopyrightAuthor(v string) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetCopyrightAuthor(v)
	})
}

// UpdateCopyrightAuthor sets the "copyright_author" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateCopyrightAuthor() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateCopyrightAuthor()
	})
}

// ClearCopyrightAuthor clears the value of the "copyright_author" field.
func (u *ArticleUpsertBulk) ClearCopyrightAuthor() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearCopyrightAuthor()
	})
}

// SetCopyrightAuthorHref sets the "copyright_author_href" field.
func (u *ArticleUpsertBulk) SetCopyrightAuthorHref(v string) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetCopyrightAuthorHref(v)
	})
}

// UpdateCopyrightAuthorHref sets the "copyright_author_href" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateCopyrightAuthorHref() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateCopyrightAuthorHref()
	})
}

// ClearCopyrightAuthorHref clears the value of the "copyright_author_href" field.
func (u *ArticleUpsertBulk) ClearCopyrightAuthorHref() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearCopyrightAuthorHref()
	})
}

// SetCopyrightURL sets the "copyright_url" field.
func (u *ArticleUpsertBulk) SetCopyrightURL(v string) *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.SetCopyrightURL(v)
	})
}

// UpdateCopyrightURL sets the "copyright_url" field to the value that was provided on create.
func (u *ArticleUpsertBulk) UpdateCopyrightURL() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.UpdateCopyrightURL()
	})
}

// ClearCopyrightURL clears the value of the "copyright_url" field.
func (u *ArticleUpsertBulk) ClearCopyrightURL() *ArticleUpsertBulk {
	return u.Update(func(s *ArticleUpsert) {
		s.ClearCopyrightURL()
	})
}

// Exec executes the query.
func (u *ArticleUpsertBulk) Exec(ctx context.Context) error {
	if u.create.err != nil {
		return u.create.err
	}
	for i, b := range u.create.builders {
		if len(b.conflict) != 0 {
			return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ArticleCreateBulk instead", i)
		}
	}
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for ArticleCreateBulk.OnConflict")
	}
	return u.create.Exec(ctx)
}

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