github.com/ngocphuongnb/tetua@v0.0.7-alpha/packages/entrepository/ent/post_create.go (about)

     1  // Code generated by entc, DO NOT EDIT.
     2  
     3  package ent
     4  
     5  import (
     6  	"context"
     7  	"errors"
     8  	"fmt"
     9  	"time"
    10  
    11  	"entgo.io/ent/dialect/sql"
    12  	"entgo.io/ent/dialect/sql/sqlgraph"
    13  	"entgo.io/ent/schema/field"
    14  	"github.com/ngocphuongnb/tetua/packages/entrepository/ent/comment"
    15  	"github.com/ngocphuongnb/tetua/packages/entrepository/ent/file"
    16  	"github.com/ngocphuongnb/tetua/packages/entrepository/ent/post"
    17  	"github.com/ngocphuongnb/tetua/packages/entrepository/ent/topic"
    18  	"github.com/ngocphuongnb/tetua/packages/entrepository/ent/user"
    19  )
    20  
    21  // PostCreate is the builder for creating a Post entity.
    22  type PostCreate struct {
    23  	config
    24  	mutation *PostMutation
    25  	hooks    []Hook
    26  	conflict []sql.ConflictOption
    27  }
    28  
    29  // SetCreatedAt sets the "created_at" field.
    30  func (pc *PostCreate) SetCreatedAt(t time.Time) *PostCreate {
    31  	pc.mutation.SetCreatedAt(t)
    32  	return pc
    33  }
    34  
    35  // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
    36  func (pc *PostCreate) SetNillableCreatedAt(t *time.Time) *PostCreate {
    37  	if t != nil {
    38  		pc.SetCreatedAt(*t)
    39  	}
    40  	return pc
    41  }
    42  
    43  // SetUpdatedAt sets the "updated_at" field.
    44  func (pc *PostCreate) SetUpdatedAt(t time.Time) *PostCreate {
    45  	pc.mutation.SetUpdatedAt(t)
    46  	return pc
    47  }
    48  
    49  // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
    50  func (pc *PostCreate) SetNillableUpdatedAt(t *time.Time) *PostCreate {
    51  	if t != nil {
    52  		pc.SetUpdatedAt(*t)
    53  	}
    54  	return pc
    55  }
    56  
    57  // SetDeletedAt sets the "deleted_at" field.
    58  func (pc *PostCreate) SetDeletedAt(t time.Time) *PostCreate {
    59  	pc.mutation.SetDeletedAt(t)
    60  	return pc
    61  }
    62  
    63  // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
    64  func (pc *PostCreate) SetNillableDeletedAt(t *time.Time) *PostCreate {
    65  	if t != nil {
    66  		pc.SetDeletedAt(*t)
    67  	}
    68  	return pc
    69  }
    70  
    71  // SetName sets the "name" field.
    72  func (pc *PostCreate) SetName(s string) *PostCreate {
    73  	pc.mutation.SetName(s)
    74  	return pc
    75  }
    76  
    77  // SetSlug sets the "slug" field.
    78  func (pc *PostCreate) SetSlug(s string) *PostCreate {
    79  	pc.mutation.SetSlug(s)
    80  	return pc
    81  }
    82  
    83  // SetDescription sets the "description" field.
    84  func (pc *PostCreate) SetDescription(s string) *PostCreate {
    85  	pc.mutation.SetDescription(s)
    86  	return pc
    87  }
    88  
    89  // SetNillableDescription sets the "description" field if the given value is not nil.
    90  func (pc *PostCreate) SetNillableDescription(s *string) *PostCreate {
    91  	if s != nil {
    92  		pc.SetDescription(*s)
    93  	}
    94  	return pc
    95  }
    96  
    97  // SetContent sets the "content" field.
    98  func (pc *PostCreate) SetContent(s string) *PostCreate {
    99  	pc.mutation.SetContent(s)
   100  	return pc
   101  }
   102  
   103  // SetContentHTML sets the "content_html" field.
   104  func (pc *PostCreate) SetContentHTML(s string) *PostCreate {
   105  	pc.mutation.SetContentHTML(s)
   106  	return pc
   107  }
   108  
   109  // SetViewCount sets the "view_count" field.
   110  func (pc *PostCreate) SetViewCount(i int64) *PostCreate {
   111  	pc.mutation.SetViewCount(i)
   112  	return pc
   113  }
   114  
   115  // SetNillableViewCount sets the "view_count" field if the given value is not nil.
   116  func (pc *PostCreate) SetNillableViewCount(i *int64) *PostCreate {
   117  	if i != nil {
   118  		pc.SetViewCount(*i)
   119  	}
   120  	return pc
   121  }
   122  
   123  // SetCommentCount sets the "comment_count" field.
   124  func (pc *PostCreate) SetCommentCount(i int64) *PostCreate {
   125  	pc.mutation.SetCommentCount(i)
   126  	return pc
   127  }
   128  
   129  // SetNillableCommentCount sets the "comment_count" field if the given value is not nil.
   130  func (pc *PostCreate) SetNillableCommentCount(i *int64) *PostCreate {
   131  	if i != nil {
   132  		pc.SetCommentCount(*i)
   133  	}
   134  	return pc
   135  }
   136  
   137  // SetRatingCount sets the "rating_count" field.
   138  func (pc *PostCreate) SetRatingCount(i int64) *PostCreate {
   139  	pc.mutation.SetRatingCount(i)
   140  	return pc
   141  }
   142  
   143  // SetNillableRatingCount sets the "rating_count" field if the given value is not nil.
   144  func (pc *PostCreate) SetNillableRatingCount(i *int64) *PostCreate {
   145  	if i != nil {
   146  		pc.SetRatingCount(*i)
   147  	}
   148  	return pc
   149  }
   150  
   151  // SetRatingTotal sets the "rating_total" field.
   152  func (pc *PostCreate) SetRatingTotal(i int64) *PostCreate {
   153  	pc.mutation.SetRatingTotal(i)
   154  	return pc
   155  }
   156  
   157  // SetNillableRatingTotal sets the "rating_total" field if the given value is not nil.
   158  func (pc *PostCreate) SetNillableRatingTotal(i *int64) *PostCreate {
   159  	if i != nil {
   160  		pc.SetRatingTotal(*i)
   161  	}
   162  	return pc
   163  }
   164  
   165  // SetDraft sets the "draft" field.
   166  func (pc *PostCreate) SetDraft(b bool) *PostCreate {
   167  	pc.mutation.SetDraft(b)
   168  	return pc
   169  }
   170  
   171  // SetNillableDraft sets the "draft" field if the given value is not nil.
   172  func (pc *PostCreate) SetNillableDraft(b *bool) *PostCreate {
   173  	if b != nil {
   174  		pc.SetDraft(*b)
   175  	}
   176  	return pc
   177  }
   178  
   179  // SetApproved sets the "approved" field.
   180  func (pc *PostCreate) SetApproved(b bool) *PostCreate {
   181  	pc.mutation.SetApproved(b)
   182  	return pc
   183  }
   184  
   185  // SetNillableApproved sets the "approved" field if the given value is not nil.
   186  func (pc *PostCreate) SetNillableApproved(b *bool) *PostCreate {
   187  	if b != nil {
   188  		pc.SetApproved(*b)
   189  	}
   190  	return pc
   191  }
   192  
   193  // SetFeaturedImageID sets the "featured_image_id" field.
   194  func (pc *PostCreate) SetFeaturedImageID(i int) *PostCreate {
   195  	pc.mutation.SetFeaturedImageID(i)
   196  	return pc
   197  }
   198  
   199  // SetNillableFeaturedImageID sets the "featured_image_id" field if the given value is not nil.
   200  func (pc *PostCreate) SetNillableFeaturedImageID(i *int) *PostCreate {
   201  	if i != nil {
   202  		pc.SetFeaturedImageID(*i)
   203  	}
   204  	return pc
   205  }
   206  
   207  // SetUserID sets the "user_id" field.
   208  func (pc *PostCreate) SetUserID(i int) *PostCreate {
   209  	pc.mutation.SetUserID(i)
   210  	return pc
   211  }
   212  
   213  // SetNillableUserID sets the "user_id" field if the given value is not nil.
   214  func (pc *PostCreate) SetNillableUserID(i *int) *PostCreate {
   215  	if i != nil {
   216  		pc.SetUserID(*i)
   217  	}
   218  	return pc
   219  }
   220  
   221  // SetUser sets the "user" edge to the User entity.
   222  func (pc *PostCreate) SetUser(u *User) *PostCreate {
   223  	return pc.SetUserID(u.ID)
   224  }
   225  
   226  // AddTopicIDs adds the "topics" edge to the Topic entity by IDs.
   227  func (pc *PostCreate) AddTopicIDs(ids ...int) *PostCreate {
   228  	pc.mutation.AddTopicIDs(ids...)
   229  	return pc
   230  }
   231  
   232  // AddTopics adds the "topics" edges to the Topic entity.
   233  func (pc *PostCreate) AddTopics(t ...*Topic) *PostCreate {
   234  	ids := make([]int, len(t))
   235  	for i := range t {
   236  		ids[i] = t[i].ID
   237  	}
   238  	return pc.AddTopicIDs(ids...)
   239  }
   240  
   241  // SetFeaturedImage sets the "featured_image" edge to the File entity.
   242  func (pc *PostCreate) SetFeaturedImage(f *File) *PostCreate {
   243  	return pc.SetFeaturedImageID(f.ID)
   244  }
   245  
   246  // AddCommentIDs adds the "comments" edge to the Comment entity by IDs.
   247  func (pc *PostCreate) AddCommentIDs(ids ...int) *PostCreate {
   248  	pc.mutation.AddCommentIDs(ids...)
   249  	return pc
   250  }
   251  
   252  // AddComments adds the "comments" edges to the Comment entity.
   253  func (pc *PostCreate) AddComments(c ...*Comment) *PostCreate {
   254  	ids := make([]int, len(c))
   255  	for i := range c {
   256  		ids[i] = c[i].ID
   257  	}
   258  	return pc.AddCommentIDs(ids...)
   259  }
   260  
   261  // Mutation returns the PostMutation object of the builder.
   262  func (pc *PostCreate) Mutation() *PostMutation {
   263  	return pc.mutation
   264  }
   265  
   266  // Save creates the Post in the database.
   267  func (pc *PostCreate) Save(ctx context.Context) (*Post, error) {
   268  	var (
   269  		err  error
   270  		node *Post
   271  	)
   272  	pc.defaults()
   273  	if len(pc.hooks) == 0 {
   274  		if err = pc.check(); err != nil {
   275  			return nil, err
   276  		}
   277  		node, err = pc.sqlSave(ctx)
   278  	} else {
   279  		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
   280  			mutation, ok := m.(*PostMutation)
   281  			if !ok {
   282  				return nil, fmt.Errorf("unexpected mutation type %T", m)
   283  			}
   284  			if err = pc.check(); err != nil {
   285  				return nil, err
   286  			}
   287  			pc.mutation = mutation
   288  			if node, err = pc.sqlSave(ctx); err != nil {
   289  				return nil, err
   290  			}
   291  			mutation.id = &node.ID
   292  			mutation.done = true
   293  			return node, err
   294  		})
   295  		for i := len(pc.hooks) - 1; i >= 0; i-- {
   296  			if pc.hooks[i] == nil {
   297  				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
   298  			}
   299  			mut = pc.hooks[i](mut)
   300  		}
   301  		if _, err := mut.Mutate(ctx, pc.mutation); err != nil {
   302  			return nil, err
   303  		}
   304  	}
   305  	return node, err
   306  }
   307  
   308  // SaveX calls Save and panics if Save returns an error.
   309  func (pc *PostCreate) SaveX(ctx context.Context) *Post {
   310  	v, err := pc.Save(ctx)
   311  	if err != nil {
   312  		panic(err)
   313  	}
   314  	return v
   315  }
   316  
   317  // Exec executes the query.
   318  func (pc *PostCreate) Exec(ctx context.Context) error {
   319  	_, err := pc.Save(ctx)
   320  	return err
   321  }
   322  
   323  // ExecX is like Exec, but panics if an error occurs.
   324  func (pc *PostCreate) ExecX(ctx context.Context) {
   325  	if err := pc.Exec(ctx); err != nil {
   326  		panic(err)
   327  	}
   328  }
   329  
   330  // defaults sets the default values of the builder before save.
   331  func (pc *PostCreate) defaults() {
   332  	if _, ok := pc.mutation.CreatedAt(); !ok {
   333  		v := post.DefaultCreatedAt()
   334  		pc.mutation.SetCreatedAt(v)
   335  	}
   336  	if _, ok := pc.mutation.UpdatedAt(); !ok {
   337  		v := post.DefaultUpdatedAt()
   338  		pc.mutation.SetUpdatedAt(v)
   339  	}
   340  	if _, ok := pc.mutation.ViewCount(); !ok {
   341  		v := post.DefaultViewCount
   342  		pc.mutation.SetViewCount(v)
   343  	}
   344  	if _, ok := pc.mutation.CommentCount(); !ok {
   345  		v := post.DefaultCommentCount
   346  		pc.mutation.SetCommentCount(v)
   347  	}
   348  	if _, ok := pc.mutation.RatingCount(); !ok {
   349  		v := post.DefaultRatingCount
   350  		pc.mutation.SetRatingCount(v)
   351  	}
   352  	if _, ok := pc.mutation.RatingTotal(); !ok {
   353  		v := post.DefaultRatingTotal
   354  		pc.mutation.SetRatingTotal(v)
   355  	}
   356  	if _, ok := pc.mutation.Draft(); !ok {
   357  		v := post.DefaultDraft
   358  		pc.mutation.SetDraft(v)
   359  	}
   360  	if _, ok := pc.mutation.Approved(); !ok {
   361  		v := post.DefaultApproved
   362  		pc.mutation.SetApproved(v)
   363  	}
   364  }
   365  
   366  // check runs all checks and user-defined validators on the builder.
   367  func (pc *PostCreate) check() error {
   368  	if _, ok := pc.mutation.CreatedAt(); !ok {
   369  		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Post.created_at"`)}
   370  	}
   371  	if _, ok := pc.mutation.UpdatedAt(); !ok {
   372  		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Post.updated_at"`)}
   373  	}
   374  	if _, ok := pc.mutation.Name(); !ok {
   375  		return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Post.name"`)}
   376  	}
   377  	if _, ok := pc.mutation.Slug(); !ok {
   378  		return &ValidationError{Name: "slug", err: errors.New(`ent: missing required field "Post.slug"`)}
   379  	}
   380  	if _, ok := pc.mutation.Content(); !ok {
   381  		return &ValidationError{Name: "content", err: errors.New(`ent: missing required field "Post.content"`)}
   382  	}
   383  	if _, ok := pc.mutation.ContentHTML(); !ok {
   384  		return &ValidationError{Name: "content_html", err: errors.New(`ent: missing required field "Post.content_html"`)}
   385  	}
   386  	if _, ok := pc.mutation.ViewCount(); !ok {
   387  		return &ValidationError{Name: "view_count", err: errors.New(`ent: missing required field "Post.view_count"`)}
   388  	}
   389  	if _, ok := pc.mutation.CommentCount(); !ok {
   390  		return &ValidationError{Name: "comment_count", err: errors.New(`ent: missing required field "Post.comment_count"`)}
   391  	}
   392  	return nil
   393  }
   394  
   395  func (pc *PostCreate) sqlSave(ctx context.Context) (*Post, error) {
   396  	_node, _spec := pc.createSpec()
   397  	if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil {
   398  		if sqlgraph.IsConstraintError(err) {
   399  			err = &ConstraintError{err.Error(), err}
   400  		}
   401  		return nil, err
   402  	}
   403  	id := _spec.ID.Value.(int64)
   404  	_node.ID = int(id)
   405  	return _node, nil
   406  }
   407  
   408  func (pc *PostCreate) createSpec() (*Post, *sqlgraph.CreateSpec) {
   409  	var (
   410  		_node = &Post{config: pc.config}
   411  		_spec = &sqlgraph.CreateSpec{
   412  			Table: post.Table,
   413  			ID: &sqlgraph.FieldSpec{
   414  				Type:   field.TypeInt,
   415  				Column: post.FieldID,
   416  			},
   417  		}
   418  	)
   419  	_spec.OnConflict = pc.conflict
   420  	if value, ok := pc.mutation.CreatedAt(); ok {
   421  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   422  			Type:   field.TypeTime,
   423  			Value:  value,
   424  			Column: post.FieldCreatedAt,
   425  		})
   426  		_node.CreatedAt = value
   427  	}
   428  	if value, ok := pc.mutation.UpdatedAt(); ok {
   429  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   430  			Type:   field.TypeTime,
   431  			Value:  value,
   432  			Column: post.FieldUpdatedAt,
   433  		})
   434  		_node.UpdatedAt = value
   435  	}
   436  	if value, ok := pc.mutation.DeletedAt(); ok {
   437  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   438  			Type:   field.TypeTime,
   439  			Value:  value,
   440  			Column: post.FieldDeletedAt,
   441  		})
   442  		_node.DeletedAt = value
   443  	}
   444  	if value, ok := pc.mutation.Name(); ok {
   445  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   446  			Type:   field.TypeString,
   447  			Value:  value,
   448  			Column: post.FieldName,
   449  		})
   450  		_node.Name = value
   451  	}
   452  	if value, ok := pc.mutation.Slug(); ok {
   453  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   454  			Type:   field.TypeString,
   455  			Value:  value,
   456  			Column: post.FieldSlug,
   457  		})
   458  		_node.Slug = value
   459  	}
   460  	if value, ok := pc.mutation.Description(); ok {
   461  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   462  			Type:   field.TypeString,
   463  			Value:  value,
   464  			Column: post.FieldDescription,
   465  		})
   466  		_node.Description = value
   467  	}
   468  	if value, ok := pc.mutation.Content(); ok {
   469  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   470  			Type:   field.TypeString,
   471  			Value:  value,
   472  			Column: post.FieldContent,
   473  		})
   474  		_node.Content = value
   475  	}
   476  	if value, ok := pc.mutation.ContentHTML(); ok {
   477  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   478  			Type:   field.TypeString,
   479  			Value:  value,
   480  			Column: post.FieldContentHTML,
   481  		})
   482  		_node.ContentHTML = value
   483  	}
   484  	if value, ok := pc.mutation.ViewCount(); ok {
   485  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   486  			Type:   field.TypeInt64,
   487  			Value:  value,
   488  			Column: post.FieldViewCount,
   489  		})
   490  		_node.ViewCount = value
   491  	}
   492  	if value, ok := pc.mutation.CommentCount(); ok {
   493  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   494  			Type:   field.TypeInt64,
   495  			Value:  value,
   496  			Column: post.FieldCommentCount,
   497  		})
   498  		_node.CommentCount = value
   499  	}
   500  	if value, ok := pc.mutation.RatingCount(); ok {
   501  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   502  			Type:   field.TypeInt64,
   503  			Value:  value,
   504  			Column: post.FieldRatingCount,
   505  		})
   506  		_node.RatingCount = value
   507  	}
   508  	if value, ok := pc.mutation.RatingTotal(); ok {
   509  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   510  			Type:   field.TypeInt64,
   511  			Value:  value,
   512  			Column: post.FieldRatingTotal,
   513  		})
   514  		_node.RatingTotal = value
   515  	}
   516  	if value, ok := pc.mutation.Draft(); ok {
   517  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   518  			Type:   field.TypeBool,
   519  			Value:  value,
   520  			Column: post.FieldDraft,
   521  		})
   522  		_node.Draft = value
   523  	}
   524  	if value, ok := pc.mutation.Approved(); ok {
   525  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   526  			Type:   field.TypeBool,
   527  			Value:  value,
   528  			Column: post.FieldApproved,
   529  		})
   530  		_node.Approved = value
   531  	}
   532  	if nodes := pc.mutation.UserIDs(); len(nodes) > 0 {
   533  		edge := &sqlgraph.EdgeSpec{
   534  			Rel:     sqlgraph.M2O,
   535  			Inverse: true,
   536  			Table:   post.UserTable,
   537  			Columns: []string{post.UserColumn},
   538  			Bidi:    false,
   539  			Target: &sqlgraph.EdgeTarget{
   540  				IDSpec: &sqlgraph.FieldSpec{
   541  					Type:   field.TypeInt,
   542  					Column: user.FieldID,
   543  				},
   544  			},
   545  		}
   546  		for _, k := range nodes {
   547  			edge.Target.Nodes = append(edge.Target.Nodes, k)
   548  		}
   549  		_node.UserID = nodes[0]
   550  		_spec.Edges = append(_spec.Edges, edge)
   551  	}
   552  	if nodes := pc.mutation.TopicsIDs(); len(nodes) > 0 {
   553  		edge := &sqlgraph.EdgeSpec{
   554  			Rel:     sqlgraph.M2M,
   555  			Inverse: true,
   556  			Table:   post.TopicsTable,
   557  			Columns: post.TopicsPrimaryKey,
   558  			Bidi:    false,
   559  			Target: &sqlgraph.EdgeTarget{
   560  				IDSpec: &sqlgraph.FieldSpec{
   561  					Type:   field.TypeInt,
   562  					Column: topic.FieldID,
   563  				},
   564  			},
   565  		}
   566  		for _, k := range nodes {
   567  			edge.Target.Nodes = append(edge.Target.Nodes, k)
   568  		}
   569  		_spec.Edges = append(_spec.Edges, edge)
   570  	}
   571  	if nodes := pc.mutation.FeaturedImageIDs(); len(nodes) > 0 {
   572  		edge := &sqlgraph.EdgeSpec{
   573  			Rel:     sqlgraph.M2O,
   574  			Inverse: true,
   575  			Table:   post.FeaturedImageTable,
   576  			Columns: []string{post.FeaturedImageColumn},
   577  			Bidi:    false,
   578  			Target: &sqlgraph.EdgeTarget{
   579  				IDSpec: &sqlgraph.FieldSpec{
   580  					Type:   field.TypeInt,
   581  					Column: file.FieldID,
   582  				},
   583  			},
   584  		}
   585  		for _, k := range nodes {
   586  			edge.Target.Nodes = append(edge.Target.Nodes, k)
   587  		}
   588  		_node.FeaturedImageID = nodes[0]
   589  		_spec.Edges = append(_spec.Edges, edge)
   590  	}
   591  	if nodes := pc.mutation.CommentsIDs(); len(nodes) > 0 {
   592  		edge := &sqlgraph.EdgeSpec{
   593  			Rel:     sqlgraph.O2M,
   594  			Inverse: false,
   595  			Table:   post.CommentsTable,
   596  			Columns: []string{post.CommentsColumn},
   597  			Bidi:    false,
   598  			Target: &sqlgraph.EdgeTarget{
   599  				IDSpec: &sqlgraph.FieldSpec{
   600  					Type:   field.TypeInt,
   601  					Column: comment.FieldID,
   602  				},
   603  			},
   604  		}
   605  		for _, k := range nodes {
   606  			edge.Target.Nodes = append(edge.Target.Nodes, k)
   607  		}
   608  		_spec.Edges = append(_spec.Edges, edge)
   609  	}
   610  	return _node, _spec
   611  }
   612  
   613  // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
   614  // of the `INSERT` statement. For example:
   615  //
   616  //	client.Post.Create().
   617  //		SetCreatedAt(v).
   618  //		OnConflict(
   619  //			// Update the row with the new values
   620  //			// the was proposed for insertion.
   621  //			sql.ResolveWithNewValues(),
   622  //		).
   623  //		// Override some of the fields with custom
   624  //		// update values.
   625  //		Update(func(u *ent.PostUpsert) {
   626  //			SetCreatedAt(v+v).
   627  //		}).
   628  //		Exec(ctx)
   629  //
   630  func (pc *PostCreate) OnConflict(opts ...sql.ConflictOption) *PostUpsertOne {
   631  	pc.conflict = opts
   632  	return &PostUpsertOne{
   633  		create: pc,
   634  	}
   635  }
   636  
   637  // OnConflictColumns calls `OnConflict` and configures the columns
   638  // as conflict target. Using this option is equivalent to using:
   639  //
   640  //	client.Post.Create().
   641  //		OnConflict(sql.ConflictColumns(columns...)).
   642  //		Exec(ctx)
   643  //
   644  func (pc *PostCreate) OnConflictColumns(columns ...string) *PostUpsertOne {
   645  	pc.conflict = append(pc.conflict, sql.ConflictColumns(columns...))
   646  	return &PostUpsertOne{
   647  		create: pc,
   648  	}
   649  }
   650  
   651  type (
   652  	// PostUpsertOne is the builder for "upsert"-ing
   653  	//  one Post node.
   654  	PostUpsertOne struct {
   655  		create *PostCreate
   656  	}
   657  
   658  	// PostUpsert is the "OnConflict" setter.
   659  	PostUpsert struct {
   660  		*sql.UpdateSet
   661  	}
   662  )
   663  
   664  // SetCreatedAt sets the "created_at" field.
   665  func (u *PostUpsert) SetCreatedAt(v time.Time) *PostUpsert {
   666  	u.Set(post.FieldCreatedAt, v)
   667  	return u
   668  }
   669  
   670  // UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
   671  func (u *PostUpsert) UpdateCreatedAt() *PostUpsert {
   672  	u.SetExcluded(post.FieldCreatedAt)
   673  	return u
   674  }
   675  
   676  // SetUpdatedAt sets the "updated_at" field.
   677  func (u *PostUpsert) SetUpdatedAt(v time.Time) *PostUpsert {
   678  	u.Set(post.FieldUpdatedAt, v)
   679  	return u
   680  }
   681  
   682  // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
   683  func (u *PostUpsert) UpdateUpdatedAt() *PostUpsert {
   684  	u.SetExcluded(post.FieldUpdatedAt)
   685  	return u
   686  }
   687  
   688  // SetDeletedAt sets the "deleted_at" field.
   689  func (u *PostUpsert) SetDeletedAt(v time.Time) *PostUpsert {
   690  	u.Set(post.FieldDeletedAt, v)
   691  	return u
   692  }
   693  
   694  // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
   695  func (u *PostUpsert) UpdateDeletedAt() *PostUpsert {
   696  	u.SetExcluded(post.FieldDeletedAt)
   697  	return u
   698  }
   699  
   700  // ClearDeletedAt clears the value of the "deleted_at" field.
   701  func (u *PostUpsert) ClearDeletedAt() *PostUpsert {
   702  	u.SetNull(post.FieldDeletedAt)
   703  	return u
   704  }
   705  
   706  // SetName sets the "name" field.
   707  func (u *PostUpsert) SetName(v string) *PostUpsert {
   708  	u.Set(post.FieldName, v)
   709  	return u
   710  }
   711  
   712  // UpdateName sets the "name" field to the value that was provided on create.
   713  func (u *PostUpsert) UpdateName() *PostUpsert {
   714  	u.SetExcluded(post.FieldName)
   715  	return u
   716  }
   717  
   718  // SetSlug sets the "slug" field.
   719  func (u *PostUpsert) SetSlug(v string) *PostUpsert {
   720  	u.Set(post.FieldSlug, v)
   721  	return u
   722  }
   723  
   724  // UpdateSlug sets the "slug" field to the value that was provided on create.
   725  func (u *PostUpsert) UpdateSlug() *PostUpsert {
   726  	u.SetExcluded(post.FieldSlug)
   727  	return u
   728  }
   729  
   730  // SetDescription sets the "description" field.
   731  func (u *PostUpsert) SetDescription(v string) *PostUpsert {
   732  	u.Set(post.FieldDescription, v)
   733  	return u
   734  }
   735  
   736  // UpdateDescription sets the "description" field to the value that was provided on create.
   737  func (u *PostUpsert) UpdateDescription() *PostUpsert {
   738  	u.SetExcluded(post.FieldDescription)
   739  	return u
   740  }
   741  
   742  // ClearDescription clears the value of the "description" field.
   743  func (u *PostUpsert) ClearDescription() *PostUpsert {
   744  	u.SetNull(post.FieldDescription)
   745  	return u
   746  }
   747  
   748  // SetContent sets the "content" field.
   749  func (u *PostUpsert) SetContent(v string) *PostUpsert {
   750  	u.Set(post.FieldContent, v)
   751  	return u
   752  }
   753  
   754  // UpdateContent sets the "content" field to the value that was provided on create.
   755  func (u *PostUpsert) UpdateContent() *PostUpsert {
   756  	u.SetExcluded(post.FieldContent)
   757  	return u
   758  }
   759  
   760  // SetContentHTML sets the "content_html" field.
   761  func (u *PostUpsert) SetContentHTML(v string) *PostUpsert {
   762  	u.Set(post.FieldContentHTML, v)
   763  	return u
   764  }
   765  
   766  // UpdateContentHTML sets the "content_html" field to the value that was provided on create.
   767  func (u *PostUpsert) UpdateContentHTML() *PostUpsert {
   768  	u.SetExcluded(post.FieldContentHTML)
   769  	return u
   770  }
   771  
   772  // SetViewCount sets the "view_count" field.
   773  func (u *PostUpsert) SetViewCount(v int64) *PostUpsert {
   774  	u.Set(post.FieldViewCount, v)
   775  	return u
   776  }
   777  
   778  // UpdateViewCount sets the "view_count" field to the value that was provided on create.
   779  func (u *PostUpsert) UpdateViewCount() *PostUpsert {
   780  	u.SetExcluded(post.FieldViewCount)
   781  	return u
   782  }
   783  
   784  // AddViewCount adds v to the "view_count" field.
   785  func (u *PostUpsert) AddViewCount(v int64) *PostUpsert {
   786  	u.Add(post.FieldViewCount, v)
   787  	return u
   788  }
   789  
   790  // SetCommentCount sets the "comment_count" field.
   791  func (u *PostUpsert) SetCommentCount(v int64) *PostUpsert {
   792  	u.Set(post.FieldCommentCount, v)
   793  	return u
   794  }
   795  
   796  // UpdateCommentCount sets the "comment_count" field to the value that was provided on create.
   797  func (u *PostUpsert) UpdateCommentCount() *PostUpsert {
   798  	u.SetExcluded(post.FieldCommentCount)
   799  	return u
   800  }
   801  
   802  // AddCommentCount adds v to the "comment_count" field.
   803  func (u *PostUpsert) AddCommentCount(v int64) *PostUpsert {
   804  	u.Add(post.FieldCommentCount, v)
   805  	return u
   806  }
   807  
   808  // SetRatingCount sets the "rating_count" field.
   809  func (u *PostUpsert) SetRatingCount(v int64) *PostUpsert {
   810  	u.Set(post.FieldRatingCount, v)
   811  	return u
   812  }
   813  
   814  // UpdateRatingCount sets the "rating_count" field to the value that was provided on create.
   815  func (u *PostUpsert) UpdateRatingCount() *PostUpsert {
   816  	u.SetExcluded(post.FieldRatingCount)
   817  	return u
   818  }
   819  
   820  // AddRatingCount adds v to the "rating_count" field.
   821  func (u *PostUpsert) AddRatingCount(v int64) *PostUpsert {
   822  	u.Add(post.FieldRatingCount, v)
   823  	return u
   824  }
   825  
   826  // ClearRatingCount clears the value of the "rating_count" field.
   827  func (u *PostUpsert) ClearRatingCount() *PostUpsert {
   828  	u.SetNull(post.FieldRatingCount)
   829  	return u
   830  }
   831  
   832  // SetRatingTotal sets the "rating_total" field.
   833  func (u *PostUpsert) SetRatingTotal(v int64) *PostUpsert {
   834  	u.Set(post.FieldRatingTotal, v)
   835  	return u
   836  }
   837  
   838  // UpdateRatingTotal sets the "rating_total" field to the value that was provided on create.
   839  func (u *PostUpsert) UpdateRatingTotal() *PostUpsert {
   840  	u.SetExcluded(post.FieldRatingTotal)
   841  	return u
   842  }
   843  
   844  // AddRatingTotal adds v to the "rating_total" field.
   845  func (u *PostUpsert) AddRatingTotal(v int64) *PostUpsert {
   846  	u.Add(post.FieldRatingTotal, v)
   847  	return u
   848  }
   849  
   850  // ClearRatingTotal clears the value of the "rating_total" field.
   851  func (u *PostUpsert) ClearRatingTotal() *PostUpsert {
   852  	u.SetNull(post.FieldRatingTotal)
   853  	return u
   854  }
   855  
   856  // SetDraft sets the "draft" field.
   857  func (u *PostUpsert) SetDraft(v bool) *PostUpsert {
   858  	u.Set(post.FieldDraft, v)
   859  	return u
   860  }
   861  
   862  // UpdateDraft sets the "draft" field to the value that was provided on create.
   863  func (u *PostUpsert) UpdateDraft() *PostUpsert {
   864  	u.SetExcluded(post.FieldDraft)
   865  	return u
   866  }
   867  
   868  // ClearDraft clears the value of the "draft" field.
   869  func (u *PostUpsert) ClearDraft() *PostUpsert {
   870  	u.SetNull(post.FieldDraft)
   871  	return u
   872  }
   873  
   874  // SetApproved sets the "approved" field.
   875  func (u *PostUpsert) SetApproved(v bool) *PostUpsert {
   876  	u.Set(post.FieldApproved, v)
   877  	return u
   878  }
   879  
   880  // UpdateApproved sets the "approved" field to the value that was provided on create.
   881  func (u *PostUpsert) UpdateApproved() *PostUpsert {
   882  	u.SetExcluded(post.FieldApproved)
   883  	return u
   884  }
   885  
   886  // ClearApproved clears the value of the "approved" field.
   887  func (u *PostUpsert) ClearApproved() *PostUpsert {
   888  	u.SetNull(post.FieldApproved)
   889  	return u
   890  }
   891  
   892  // SetFeaturedImageID sets the "featured_image_id" field.
   893  func (u *PostUpsert) SetFeaturedImageID(v int) *PostUpsert {
   894  	u.Set(post.FieldFeaturedImageID, v)
   895  	return u
   896  }
   897  
   898  // UpdateFeaturedImageID sets the "featured_image_id" field to the value that was provided on create.
   899  func (u *PostUpsert) UpdateFeaturedImageID() *PostUpsert {
   900  	u.SetExcluded(post.FieldFeaturedImageID)
   901  	return u
   902  }
   903  
   904  // ClearFeaturedImageID clears the value of the "featured_image_id" field.
   905  func (u *PostUpsert) ClearFeaturedImageID() *PostUpsert {
   906  	u.SetNull(post.FieldFeaturedImageID)
   907  	return u
   908  }
   909  
   910  // SetUserID sets the "user_id" field.
   911  func (u *PostUpsert) SetUserID(v int) *PostUpsert {
   912  	u.Set(post.FieldUserID, v)
   913  	return u
   914  }
   915  
   916  // UpdateUserID sets the "user_id" field to the value that was provided on create.
   917  func (u *PostUpsert) UpdateUserID() *PostUpsert {
   918  	u.SetExcluded(post.FieldUserID)
   919  	return u
   920  }
   921  
   922  // ClearUserID clears the value of the "user_id" field.
   923  func (u *PostUpsert) ClearUserID() *PostUpsert {
   924  	u.SetNull(post.FieldUserID)
   925  	return u
   926  }
   927  
   928  // UpdateNewValues updates the mutable fields using the new values that were set on create.
   929  // Using this option is equivalent to using:
   930  //
   931  //	client.Post.Create().
   932  //		OnConflict(
   933  //			sql.ResolveWithNewValues(),
   934  //		).
   935  //		Exec(ctx)
   936  //
   937  func (u *PostUpsertOne) UpdateNewValues() *PostUpsertOne {
   938  	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
   939  	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
   940  		if _, exists := u.create.mutation.CreatedAt(); exists {
   941  			s.SetIgnore(post.FieldCreatedAt)
   942  		}
   943  	}))
   944  	return u
   945  }
   946  
   947  // Ignore sets each column to itself in case of conflict.
   948  // Using this option is equivalent to using:
   949  //
   950  //  client.Post.Create().
   951  //      OnConflict(sql.ResolveWithIgnore()).
   952  //      Exec(ctx)
   953  //
   954  func (u *PostUpsertOne) Ignore() *PostUpsertOne {
   955  	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
   956  	return u
   957  }
   958  
   959  // DoNothing configures the conflict_action to `DO NOTHING`.
   960  // Supported only by SQLite and PostgreSQL.
   961  func (u *PostUpsertOne) DoNothing() *PostUpsertOne {
   962  	u.create.conflict = append(u.create.conflict, sql.DoNothing())
   963  	return u
   964  }
   965  
   966  // Update allows overriding fields `UPDATE` values. See the PostCreate.OnConflict
   967  // documentation for more info.
   968  func (u *PostUpsertOne) Update(set func(*PostUpsert)) *PostUpsertOne {
   969  	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
   970  		set(&PostUpsert{UpdateSet: update})
   971  	}))
   972  	return u
   973  }
   974  
   975  // SetCreatedAt sets the "created_at" field.
   976  func (u *PostUpsertOne) SetCreatedAt(v time.Time) *PostUpsertOne {
   977  	return u.Update(func(s *PostUpsert) {
   978  		s.SetCreatedAt(v)
   979  	})
   980  }
   981  
   982  // UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
   983  func (u *PostUpsertOne) UpdateCreatedAt() *PostUpsertOne {
   984  	return u.Update(func(s *PostUpsert) {
   985  		s.UpdateCreatedAt()
   986  	})
   987  }
   988  
   989  // SetUpdatedAt sets the "updated_at" field.
   990  func (u *PostUpsertOne) SetUpdatedAt(v time.Time) *PostUpsertOne {
   991  	return u.Update(func(s *PostUpsert) {
   992  		s.SetUpdatedAt(v)
   993  	})
   994  }
   995  
   996  // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
   997  func (u *PostUpsertOne) UpdateUpdatedAt() *PostUpsertOne {
   998  	return u.Update(func(s *PostUpsert) {
   999  		s.UpdateUpdatedAt()
  1000  	})
  1001  }
  1002  
  1003  // SetDeletedAt sets the "deleted_at" field.
  1004  func (u *PostUpsertOne) SetDeletedAt(v time.Time) *PostUpsertOne {
  1005  	return u.Update(func(s *PostUpsert) {
  1006  		s.SetDeletedAt(v)
  1007  	})
  1008  }
  1009  
  1010  // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1011  func (u *PostUpsertOne) UpdateDeletedAt() *PostUpsertOne {
  1012  	return u.Update(func(s *PostUpsert) {
  1013  		s.UpdateDeletedAt()
  1014  	})
  1015  }
  1016  
  1017  // ClearDeletedAt clears the value of the "deleted_at" field.
  1018  func (u *PostUpsertOne) ClearDeletedAt() *PostUpsertOne {
  1019  	return u.Update(func(s *PostUpsert) {
  1020  		s.ClearDeletedAt()
  1021  	})
  1022  }
  1023  
  1024  // SetName sets the "name" field.
  1025  func (u *PostUpsertOne) SetName(v string) *PostUpsertOne {
  1026  	return u.Update(func(s *PostUpsert) {
  1027  		s.SetName(v)
  1028  	})
  1029  }
  1030  
  1031  // UpdateName sets the "name" field to the value that was provided on create.
  1032  func (u *PostUpsertOne) UpdateName() *PostUpsertOne {
  1033  	return u.Update(func(s *PostUpsert) {
  1034  		s.UpdateName()
  1035  	})
  1036  }
  1037  
  1038  // SetSlug sets the "slug" field.
  1039  func (u *PostUpsertOne) SetSlug(v string) *PostUpsertOne {
  1040  	return u.Update(func(s *PostUpsert) {
  1041  		s.SetSlug(v)
  1042  	})
  1043  }
  1044  
  1045  // UpdateSlug sets the "slug" field to the value that was provided on create.
  1046  func (u *PostUpsertOne) UpdateSlug() *PostUpsertOne {
  1047  	return u.Update(func(s *PostUpsert) {
  1048  		s.UpdateSlug()
  1049  	})
  1050  }
  1051  
  1052  // SetDescription sets the "description" field.
  1053  func (u *PostUpsertOne) SetDescription(v string) *PostUpsertOne {
  1054  	return u.Update(func(s *PostUpsert) {
  1055  		s.SetDescription(v)
  1056  	})
  1057  }
  1058  
  1059  // UpdateDescription sets the "description" field to the value that was provided on create.
  1060  func (u *PostUpsertOne) UpdateDescription() *PostUpsertOne {
  1061  	return u.Update(func(s *PostUpsert) {
  1062  		s.UpdateDescription()
  1063  	})
  1064  }
  1065  
  1066  // ClearDescription clears the value of the "description" field.
  1067  func (u *PostUpsertOne) ClearDescription() *PostUpsertOne {
  1068  	return u.Update(func(s *PostUpsert) {
  1069  		s.ClearDescription()
  1070  	})
  1071  }
  1072  
  1073  // SetContent sets the "content" field.
  1074  func (u *PostUpsertOne) SetContent(v string) *PostUpsertOne {
  1075  	return u.Update(func(s *PostUpsert) {
  1076  		s.SetContent(v)
  1077  	})
  1078  }
  1079  
  1080  // UpdateContent sets the "content" field to the value that was provided on create.
  1081  func (u *PostUpsertOne) UpdateContent() *PostUpsertOne {
  1082  	return u.Update(func(s *PostUpsert) {
  1083  		s.UpdateContent()
  1084  	})
  1085  }
  1086  
  1087  // SetContentHTML sets the "content_html" field.
  1088  func (u *PostUpsertOne) SetContentHTML(v string) *PostUpsertOne {
  1089  	return u.Update(func(s *PostUpsert) {
  1090  		s.SetContentHTML(v)
  1091  	})
  1092  }
  1093  
  1094  // UpdateContentHTML sets the "content_html" field to the value that was provided on create.
  1095  func (u *PostUpsertOne) UpdateContentHTML() *PostUpsertOne {
  1096  	return u.Update(func(s *PostUpsert) {
  1097  		s.UpdateContentHTML()
  1098  	})
  1099  }
  1100  
  1101  // SetViewCount sets the "view_count" field.
  1102  func (u *PostUpsertOne) SetViewCount(v int64) *PostUpsertOne {
  1103  	return u.Update(func(s *PostUpsert) {
  1104  		s.SetViewCount(v)
  1105  	})
  1106  }
  1107  
  1108  // AddViewCount adds v to the "view_count" field.
  1109  func (u *PostUpsertOne) AddViewCount(v int64) *PostUpsertOne {
  1110  	return u.Update(func(s *PostUpsert) {
  1111  		s.AddViewCount(v)
  1112  	})
  1113  }
  1114  
  1115  // UpdateViewCount sets the "view_count" field to the value that was provided on create.
  1116  func (u *PostUpsertOne) UpdateViewCount() *PostUpsertOne {
  1117  	return u.Update(func(s *PostUpsert) {
  1118  		s.UpdateViewCount()
  1119  	})
  1120  }
  1121  
  1122  // SetCommentCount sets the "comment_count" field.
  1123  func (u *PostUpsertOne) SetCommentCount(v int64) *PostUpsertOne {
  1124  	return u.Update(func(s *PostUpsert) {
  1125  		s.SetCommentCount(v)
  1126  	})
  1127  }
  1128  
  1129  // AddCommentCount adds v to the "comment_count" field.
  1130  func (u *PostUpsertOne) AddCommentCount(v int64) *PostUpsertOne {
  1131  	return u.Update(func(s *PostUpsert) {
  1132  		s.AddCommentCount(v)
  1133  	})
  1134  }
  1135  
  1136  // UpdateCommentCount sets the "comment_count" field to the value that was provided on create.
  1137  func (u *PostUpsertOne) UpdateCommentCount() *PostUpsertOne {
  1138  	return u.Update(func(s *PostUpsert) {
  1139  		s.UpdateCommentCount()
  1140  	})
  1141  }
  1142  
  1143  // SetRatingCount sets the "rating_count" field.
  1144  func (u *PostUpsertOne) SetRatingCount(v int64) *PostUpsertOne {
  1145  	return u.Update(func(s *PostUpsert) {
  1146  		s.SetRatingCount(v)
  1147  	})
  1148  }
  1149  
  1150  // AddRatingCount adds v to the "rating_count" field.
  1151  func (u *PostUpsertOne) AddRatingCount(v int64) *PostUpsertOne {
  1152  	return u.Update(func(s *PostUpsert) {
  1153  		s.AddRatingCount(v)
  1154  	})
  1155  }
  1156  
  1157  // UpdateRatingCount sets the "rating_count" field to the value that was provided on create.
  1158  func (u *PostUpsertOne) UpdateRatingCount() *PostUpsertOne {
  1159  	return u.Update(func(s *PostUpsert) {
  1160  		s.UpdateRatingCount()
  1161  	})
  1162  }
  1163  
  1164  // ClearRatingCount clears the value of the "rating_count" field.
  1165  func (u *PostUpsertOne) ClearRatingCount() *PostUpsertOne {
  1166  	return u.Update(func(s *PostUpsert) {
  1167  		s.ClearRatingCount()
  1168  	})
  1169  }
  1170  
  1171  // SetRatingTotal sets the "rating_total" field.
  1172  func (u *PostUpsertOne) SetRatingTotal(v int64) *PostUpsertOne {
  1173  	return u.Update(func(s *PostUpsert) {
  1174  		s.SetRatingTotal(v)
  1175  	})
  1176  }
  1177  
  1178  // AddRatingTotal adds v to the "rating_total" field.
  1179  func (u *PostUpsertOne) AddRatingTotal(v int64) *PostUpsertOne {
  1180  	return u.Update(func(s *PostUpsert) {
  1181  		s.AddRatingTotal(v)
  1182  	})
  1183  }
  1184  
  1185  // UpdateRatingTotal sets the "rating_total" field to the value that was provided on create.
  1186  func (u *PostUpsertOne) UpdateRatingTotal() *PostUpsertOne {
  1187  	return u.Update(func(s *PostUpsert) {
  1188  		s.UpdateRatingTotal()
  1189  	})
  1190  }
  1191  
  1192  // ClearRatingTotal clears the value of the "rating_total" field.
  1193  func (u *PostUpsertOne) ClearRatingTotal() *PostUpsertOne {
  1194  	return u.Update(func(s *PostUpsert) {
  1195  		s.ClearRatingTotal()
  1196  	})
  1197  }
  1198  
  1199  // SetDraft sets the "draft" field.
  1200  func (u *PostUpsertOne) SetDraft(v bool) *PostUpsertOne {
  1201  	return u.Update(func(s *PostUpsert) {
  1202  		s.SetDraft(v)
  1203  	})
  1204  }
  1205  
  1206  // UpdateDraft sets the "draft" field to the value that was provided on create.
  1207  func (u *PostUpsertOne) UpdateDraft() *PostUpsertOne {
  1208  	return u.Update(func(s *PostUpsert) {
  1209  		s.UpdateDraft()
  1210  	})
  1211  }
  1212  
  1213  // ClearDraft clears the value of the "draft" field.
  1214  func (u *PostUpsertOne) ClearDraft() *PostUpsertOne {
  1215  	return u.Update(func(s *PostUpsert) {
  1216  		s.ClearDraft()
  1217  	})
  1218  }
  1219  
  1220  // SetApproved sets the "approved" field.
  1221  func (u *PostUpsertOne) SetApproved(v bool) *PostUpsertOne {
  1222  	return u.Update(func(s *PostUpsert) {
  1223  		s.SetApproved(v)
  1224  	})
  1225  }
  1226  
  1227  // UpdateApproved sets the "approved" field to the value that was provided on create.
  1228  func (u *PostUpsertOne) UpdateApproved() *PostUpsertOne {
  1229  	return u.Update(func(s *PostUpsert) {
  1230  		s.UpdateApproved()
  1231  	})
  1232  }
  1233  
  1234  // ClearApproved clears the value of the "approved" field.
  1235  func (u *PostUpsertOne) ClearApproved() *PostUpsertOne {
  1236  	return u.Update(func(s *PostUpsert) {
  1237  		s.ClearApproved()
  1238  	})
  1239  }
  1240  
  1241  // SetFeaturedImageID sets the "featured_image_id" field.
  1242  func (u *PostUpsertOne) SetFeaturedImageID(v int) *PostUpsertOne {
  1243  	return u.Update(func(s *PostUpsert) {
  1244  		s.SetFeaturedImageID(v)
  1245  	})
  1246  }
  1247  
  1248  // UpdateFeaturedImageID sets the "featured_image_id" field to the value that was provided on create.
  1249  func (u *PostUpsertOne) UpdateFeaturedImageID() *PostUpsertOne {
  1250  	return u.Update(func(s *PostUpsert) {
  1251  		s.UpdateFeaturedImageID()
  1252  	})
  1253  }
  1254  
  1255  // ClearFeaturedImageID clears the value of the "featured_image_id" field.
  1256  func (u *PostUpsertOne) ClearFeaturedImageID() *PostUpsertOne {
  1257  	return u.Update(func(s *PostUpsert) {
  1258  		s.ClearFeaturedImageID()
  1259  	})
  1260  }
  1261  
  1262  // SetUserID sets the "user_id" field.
  1263  func (u *PostUpsertOne) SetUserID(v int) *PostUpsertOne {
  1264  	return u.Update(func(s *PostUpsert) {
  1265  		s.SetUserID(v)
  1266  	})
  1267  }
  1268  
  1269  // UpdateUserID sets the "user_id" field to the value that was provided on create.
  1270  func (u *PostUpsertOne) UpdateUserID() *PostUpsertOne {
  1271  	return u.Update(func(s *PostUpsert) {
  1272  		s.UpdateUserID()
  1273  	})
  1274  }
  1275  
  1276  // ClearUserID clears the value of the "user_id" field.
  1277  func (u *PostUpsertOne) ClearUserID() *PostUpsertOne {
  1278  	return u.Update(func(s *PostUpsert) {
  1279  		s.ClearUserID()
  1280  	})
  1281  }
  1282  
  1283  // Exec executes the query.
  1284  func (u *PostUpsertOne) Exec(ctx context.Context) error {
  1285  	if len(u.create.conflict) == 0 {
  1286  		return errors.New("ent: missing options for PostCreate.OnConflict")
  1287  	}
  1288  	return u.create.Exec(ctx)
  1289  }
  1290  
  1291  // ExecX is like Exec, but panics if an error occurs.
  1292  func (u *PostUpsertOne) ExecX(ctx context.Context) {
  1293  	if err := u.create.Exec(ctx); err != nil {
  1294  		panic(err)
  1295  	}
  1296  }
  1297  
  1298  // Exec executes the UPSERT query and returns the inserted/updated ID.
  1299  func (u *PostUpsertOne) ID(ctx context.Context) (id int, err error) {
  1300  	node, err := u.create.Save(ctx)
  1301  	if err != nil {
  1302  		return id, err
  1303  	}
  1304  	return node.ID, nil
  1305  }
  1306  
  1307  // IDX is like ID, but panics if an error occurs.
  1308  func (u *PostUpsertOne) IDX(ctx context.Context) int {
  1309  	id, err := u.ID(ctx)
  1310  	if err != nil {
  1311  		panic(err)
  1312  	}
  1313  	return id
  1314  }
  1315  
  1316  // PostCreateBulk is the builder for creating many Post entities in bulk.
  1317  type PostCreateBulk struct {
  1318  	config
  1319  	builders []*PostCreate
  1320  	conflict []sql.ConflictOption
  1321  }
  1322  
  1323  // Save creates the Post entities in the database.
  1324  func (pcb *PostCreateBulk) Save(ctx context.Context) ([]*Post, error) {
  1325  	specs := make([]*sqlgraph.CreateSpec, len(pcb.builders))
  1326  	nodes := make([]*Post, len(pcb.builders))
  1327  	mutators := make([]Mutator, len(pcb.builders))
  1328  	for i := range pcb.builders {
  1329  		func(i int, root context.Context) {
  1330  			builder := pcb.builders[i]
  1331  			builder.defaults()
  1332  			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1333  				mutation, ok := m.(*PostMutation)
  1334  				if !ok {
  1335  					return nil, fmt.Errorf("unexpected mutation type %T", m)
  1336  				}
  1337  				if err := builder.check(); err != nil {
  1338  					return nil, err
  1339  				}
  1340  				builder.mutation = mutation
  1341  				nodes[i], specs[i] = builder.createSpec()
  1342  				var err error
  1343  				if i < len(mutators)-1 {
  1344  					_, err = mutators[i+1].Mutate(root, pcb.builders[i+1].mutation)
  1345  				} else {
  1346  					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1347  					spec.OnConflict = pcb.conflict
  1348  					// Invoke the actual operation on the latest mutation in the chain.
  1349  					if err = sqlgraph.BatchCreate(ctx, pcb.driver, spec); err != nil {
  1350  						if sqlgraph.IsConstraintError(err) {
  1351  							err = &ConstraintError{err.Error(), err}
  1352  						}
  1353  					}
  1354  				}
  1355  				if err != nil {
  1356  					return nil, err
  1357  				}
  1358  				mutation.id = &nodes[i].ID
  1359  				mutation.done = true
  1360  				if specs[i].ID.Value != nil {
  1361  					id := specs[i].ID.Value.(int64)
  1362  					nodes[i].ID = int(id)
  1363  				}
  1364  				return nodes[i], nil
  1365  			})
  1366  			for i := len(builder.hooks) - 1; i >= 0; i-- {
  1367  				mut = builder.hooks[i](mut)
  1368  			}
  1369  			mutators[i] = mut
  1370  		}(i, ctx)
  1371  	}
  1372  	if len(mutators) > 0 {
  1373  		if _, err := mutators[0].Mutate(ctx, pcb.builders[0].mutation); err != nil {
  1374  			return nil, err
  1375  		}
  1376  	}
  1377  	return nodes, nil
  1378  }
  1379  
  1380  // SaveX is like Save, but panics if an error occurs.
  1381  func (pcb *PostCreateBulk) SaveX(ctx context.Context) []*Post {
  1382  	v, err := pcb.Save(ctx)
  1383  	if err != nil {
  1384  		panic(err)
  1385  	}
  1386  	return v
  1387  }
  1388  
  1389  // Exec executes the query.
  1390  func (pcb *PostCreateBulk) Exec(ctx context.Context) error {
  1391  	_, err := pcb.Save(ctx)
  1392  	return err
  1393  }
  1394  
  1395  // ExecX is like Exec, but panics if an error occurs.
  1396  func (pcb *PostCreateBulk) ExecX(ctx context.Context) {
  1397  	if err := pcb.Exec(ctx); err != nil {
  1398  		panic(err)
  1399  	}
  1400  }
  1401  
  1402  // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1403  // of the `INSERT` statement. For example:
  1404  //
  1405  //	client.Post.CreateBulk(builders...).
  1406  //		OnConflict(
  1407  //			// Update the row with the new values
  1408  //			// the was proposed for insertion.
  1409  //			sql.ResolveWithNewValues(),
  1410  //		).
  1411  //		// Override some of the fields with custom
  1412  //		// update values.
  1413  //		Update(func(u *ent.PostUpsert) {
  1414  //			SetCreatedAt(v+v).
  1415  //		}).
  1416  //		Exec(ctx)
  1417  //
  1418  func (pcb *PostCreateBulk) OnConflict(opts ...sql.ConflictOption) *PostUpsertBulk {
  1419  	pcb.conflict = opts
  1420  	return &PostUpsertBulk{
  1421  		create: pcb,
  1422  	}
  1423  }
  1424  
  1425  // OnConflictColumns calls `OnConflict` and configures the columns
  1426  // as conflict target. Using this option is equivalent to using:
  1427  //
  1428  //	client.Post.Create().
  1429  //		OnConflict(sql.ConflictColumns(columns...)).
  1430  //		Exec(ctx)
  1431  //
  1432  func (pcb *PostCreateBulk) OnConflictColumns(columns ...string) *PostUpsertBulk {
  1433  	pcb.conflict = append(pcb.conflict, sql.ConflictColumns(columns...))
  1434  	return &PostUpsertBulk{
  1435  		create: pcb,
  1436  	}
  1437  }
  1438  
  1439  // PostUpsertBulk is the builder for "upsert"-ing
  1440  // a bulk of Post nodes.
  1441  type PostUpsertBulk struct {
  1442  	create *PostCreateBulk
  1443  }
  1444  
  1445  // UpdateNewValues updates the mutable fields using the new values that
  1446  // were set on create. Using this option is equivalent to using:
  1447  //
  1448  //	client.Post.Create().
  1449  //		OnConflict(
  1450  //			sql.ResolveWithNewValues(),
  1451  //		).
  1452  //		Exec(ctx)
  1453  //
  1454  func (u *PostUpsertBulk) UpdateNewValues() *PostUpsertBulk {
  1455  	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1456  	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1457  		for _, b := range u.create.builders {
  1458  			if _, exists := b.mutation.CreatedAt(); exists {
  1459  				s.SetIgnore(post.FieldCreatedAt)
  1460  			}
  1461  		}
  1462  	}))
  1463  	return u
  1464  }
  1465  
  1466  // Ignore sets each column to itself in case of conflict.
  1467  // Using this option is equivalent to using:
  1468  //
  1469  //	client.Post.Create().
  1470  //		OnConflict(sql.ResolveWithIgnore()).
  1471  //		Exec(ctx)
  1472  //
  1473  func (u *PostUpsertBulk) Ignore() *PostUpsertBulk {
  1474  	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1475  	return u
  1476  }
  1477  
  1478  // DoNothing configures the conflict_action to `DO NOTHING`.
  1479  // Supported only by SQLite and PostgreSQL.
  1480  func (u *PostUpsertBulk) DoNothing() *PostUpsertBulk {
  1481  	u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1482  	return u
  1483  }
  1484  
  1485  // Update allows overriding fields `UPDATE` values. See the PostCreateBulk.OnConflict
  1486  // documentation for more info.
  1487  func (u *PostUpsertBulk) Update(set func(*PostUpsert)) *PostUpsertBulk {
  1488  	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1489  		set(&PostUpsert{UpdateSet: update})
  1490  	}))
  1491  	return u
  1492  }
  1493  
  1494  // SetCreatedAt sets the "created_at" field.
  1495  func (u *PostUpsertBulk) SetCreatedAt(v time.Time) *PostUpsertBulk {
  1496  	return u.Update(func(s *PostUpsert) {
  1497  		s.SetCreatedAt(v)
  1498  	})
  1499  }
  1500  
  1501  // UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
  1502  func (u *PostUpsertBulk) UpdateCreatedAt() *PostUpsertBulk {
  1503  	return u.Update(func(s *PostUpsert) {
  1504  		s.UpdateCreatedAt()
  1505  	})
  1506  }
  1507  
  1508  // SetUpdatedAt sets the "updated_at" field.
  1509  func (u *PostUpsertBulk) SetUpdatedAt(v time.Time) *PostUpsertBulk {
  1510  	return u.Update(func(s *PostUpsert) {
  1511  		s.SetUpdatedAt(v)
  1512  	})
  1513  }
  1514  
  1515  // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1516  func (u *PostUpsertBulk) UpdateUpdatedAt() *PostUpsertBulk {
  1517  	return u.Update(func(s *PostUpsert) {
  1518  		s.UpdateUpdatedAt()
  1519  	})
  1520  }
  1521  
  1522  // SetDeletedAt sets the "deleted_at" field.
  1523  func (u *PostUpsertBulk) SetDeletedAt(v time.Time) *PostUpsertBulk {
  1524  	return u.Update(func(s *PostUpsert) {
  1525  		s.SetDeletedAt(v)
  1526  	})
  1527  }
  1528  
  1529  // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1530  func (u *PostUpsertBulk) UpdateDeletedAt() *PostUpsertBulk {
  1531  	return u.Update(func(s *PostUpsert) {
  1532  		s.UpdateDeletedAt()
  1533  	})
  1534  }
  1535  
  1536  // ClearDeletedAt clears the value of the "deleted_at" field.
  1537  func (u *PostUpsertBulk) ClearDeletedAt() *PostUpsertBulk {
  1538  	return u.Update(func(s *PostUpsert) {
  1539  		s.ClearDeletedAt()
  1540  	})
  1541  }
  1542  
  1543  // SetName sets the "name" field.
  1544  func (u *PostUpsertBulk) SetName(v string) *PostUpsertBulk {
  1545  	return u.Update(func(s *PostUpsert) {
  1546  		s.SetName(v)
  1547  	})
  1548  }
  1549  
  1550  // UpdateName sets the "name" field to the value that was provided on create.
  1551  func (u *PostUpsertBulk) UpdateName() *PostUpsertBulk {
  1552  	return u.Update(func(s *PostUpsert) {
  1553  		s.UpdateName()
  1554  	})
  1555  }
  1556  
  1557  // SetSlug sets the "slug" field.
  1558  func (u *PostUpsertBulk) SetSlug(v string) *PostUpsertBulk {
  1559  	return u.Update(func(s *PostUpsert) {
  1560  		s.SetSlug(v)
  1561  	})
  1562  }
  1563  
  1564  // UpdateSlug sets the "slug" field to the value that was provided on create.
  1565  func (u *PostUpsertBulk) UpdateSlug() *PostUpsertBulk {
  1566  	return u.Update(func(s *PostUpsert) {
  1567  		s.UpdateSlug()
  1568  	})
  1569  }
  1570  
  1571  // SetDescription sets the "description" field.
  1572  func (u *PostUpsertBulk) SetDescription(v string) *PostUpsertBulk {
  1573  	return u.Update(func(s *PostUpsert) {
  1574  		s.SetDescription(v)
  1575  	})
  1576  }
  1577  
  1578  // UpdateDescription sets the "description" field to the value that was provided on create.
  1579  func (u *PostUpsertBulk) UpdateDescription() *PostUpsertBulk {
  1580  	return u.Update(func(s *PostUpsert) {
  1581  		s.UpdateDescription()
  1582  	})
  1583  }
  1584  
  1585  // ClearDescription clears the value of the "description" field.
  1586  func (u *PostUpsertBulk) ClearDescription() *PostUpsertBulk {
  1587  	return u.Update(func(s *PostUpsert) {
  1588  		s.ClearDescription()
  1589  	})
  1590  }
  1591  
  1592  // SetContent sets the "content" field.
  1593  func (u *PostUpsertBulk) SetContent(v string) *PostUpsertBulk {
  1594  	return u.Update(func(s *PostUpsert) {
  1595  		s.SetContent(v)
  1596  	})
  1597  }
  1598  
  1599  // UpdateContent sets the "content" field to the value that was provided on create.
  1600  func (u *PostUpsertBulk) UpdateContent() *PostUpsertBulk {
  1601  	return u.Update(func(s *PostUpsert) {
  1602  		s.UpdateContent()
  1603  	})
  1604  }
  1605  
  1606  // SetContentHTML sets the "content_html" field.
  1607  func (u *PostUpsertBulk) SetContentHTML(v string) *PostUpsertBulk {
  1608  	return u.Update(func(s *PostUpsert) {
  1609  		s.SetContentHTML(v)
  1610  	})
  1611  }
  1612  
  1613  // UpdateContentHTML sets the "content_html" field to the value that was provided on create.
  1614  func (u *PostUpsertBulk) UpdateContentHTML() *PostUpsertBulk {
  1615  	return u.Update(func(s *PostUpsert) {
  1616  		s.UpdateContentHTML()
  1617  	})
  1618  }
  1619  
  1620  // SetViewCount sets the "view_count" field.
  1621  func (u *PostUpsertBulk) SetViewCount(v int64) *PostUpsertBulk {
  1622  	return u.Update(func(s *PostUpsert) {
  1623  		s.SetViewCount(v)
  1624  	})
  1625  }
  1626  
  1627  // AddViewCount adds v to the "view_count" field.
  1628  func (u *PostUpsertBulk) AddViewCount(v int64) *PostUpsertBulk {
  1629  	return u.Update(func(s *PostUpsert) {
  1630  		s.AddViewCount(v)
  1631  	})
  1632  }
  1633  
  1634  // UpdateViewCount sets the "view_count" field to the value that was provided on create.
  1635  func (u *PostUpsertBulk) UpdateViewCount() *PostUpsertBulk {
  1636  	return u.Update(func(s *PostUpsert) {
  1637  		s.UpdateViewCount()
  1638  	})
  1639  }
  1640  
  1641  // SetCommentCount sets the "comment_count" field.
  1642  func (u *PostUpsertBulk) SetCommentCount(v int64) *PostUpsertBulk {
  1643  	return u.Update(func(s *PostUpsert) {
  1644  		s.SetCommentCount(v)
  1645  	})
  1646  }
  1647  
  1648  // AddCommentCount adds v to the "comment_count" field.
  1649  func (u *PostUpsertBulk) AddCommentCount(v int64) *PostUpsertBulk {
  1650  	return u.Update(func(s *PostUpsert) {
  1651  		s.AddCommentCount(v)
  1652  	})
  1653  }
  1654  
  1655  // UpdateCommentCount sets the "comment_count" field to the value that was provided on create.
  1656  func (u *PostUpsertBulk) UpdateCommentCount() *PostUpsertBulk {
  1657  	return u.Update(func(s *PostUpsert) {
  1658  		s.UpdateCommentCount()
  1659  	})
  1660  }
  1661  
  1662  // SetRatingCount sets the "rating_count" field.
  1663  func (u *PostUpsertBulk) SetRatingCount(v int64) *PostUpsertBulk {
  1664  	return u.Update(func(s *PostUpsert) {
  1665  		s.SetRatingCount(v)
  1666  	})
  1667  }
  1668  
  1669  // AddRatingCount adds v to the "rating_count" field.
  1670  func (u *PostUpsertBulk) AddRatingCount(v int64) *PostUpsertBulk {
  1671  	return u.Update(func(s *PostUpsert) {
  1672  		s.AddRatingCount(v)
  1673  	})
  1674  }
  1675  
  1676  // UpdateRatingCount sets the "rating_count" field to the value that was provided on create.
  1677  func (u *PostUpsertBulk) UpdateRatingCount() *PostUpsertBulk {
  1678  	return u.Update(func(s *PostUpsert) {
  1679  		s.UpdateRatingCount()
  1680  	})
  1681  }
  1682  
  1683  // ClearRatingCount clears the value of the "rating_count" field.
  1684  func (u *PostUpsertBulk) ClearRatingCount() *PostUpsertBulk {
  1685  	return u.Update(func(s *PostUpsert) {
  1686  		s.ClearRatingCount()
  1687  	})
  1688  }
  1689  
  1690  // SetRatingTotal sets the "rating_total" field.
  1691  func (u *PostUpsertBulk) SetRatingTotal(v int64) *PostUpsertBulk {
  1692  	return u.Update(func(s *PostUpsert) {
  1693  		s.SetRatingTotal(v)
  1694  	})
  1695  }
  1696  
  1697  // AddRatingTotal adds v to the "rating_total" field.
  1698  func (u *PostUpsertBulk) AddRatingTotal(v int64) *PostUpsertBulk {
  1699  	return u.Update(func(s *PostUpsert) {
  1700  		s.AddRatingTotal(v)
  1701  	})
  1702  }
  1703  
  1704  // UpdateRatingTotal sets the "rating_total" field to the value that was provided on create.
  1705  func (u *PostUpsertBulk) UpdateRatingTotal() *PostUpsertBulk {
  1706  	return u.Update(func(s *PostUpsert) {
  1707  		s.UpdateRatingTotal()
  1708  	})
  1709  }
  1710  
  1711  // ClearRatingTotal clears the value of the "rating_total" field.
  1712  func (u *PostUpsertBulk) ClearRatingTotal() *PostUpsertBulk {
  1713  	return u.Update(func(s *PostUpsert) {
  1714  		s.ClearRatingTotal()
  1715  	})
  1716  }
  1717  
  1718  // SetDraft sets the "draft" field.
  1719  func (u *PostUpsertBulk) SetDraft(v bool) *PostUpsertBulk {
  1720  	return u.Update(func(s *PostUpsert) {
  1721  		s.SetDraft(v)
  1722  	})
  1723  }
  1724  
  1725  // UpdateDraft sets the "draft" field to the value that was provided on create.
  1726  func (u *PostUpsertBulk) UpdateDraft() *PostUpsertBulk {
  1727  	return u.Update(func(s *PostUpsert) {
  1728  		s.UpdateDraft()
  1729  	})
  1730  }
  1731  
  1732  // ClearDraft clears the value of the "draft" field.
  1733  func (u *PostUpsertBulk) ClearDraft() *PostUpsertBulk {
  1734  	return u.Update(func(s *PostUpsert) {
  1735  		s.ClearDraft()
  1736  	})
  1737  }
  1738  
  1739  // SetApproved sets the "approved" field.
  1740  func (u *PostUpsertBulk) SetApproved(v bool) *PostUpsertBulk {
  1741  	return u.Update(func(s *PostUpsert) {
  1742  		s.SetApproved(v)
  1743  	})
  1744  }
  1745  
  1746  // UpdateApproved sets the "approved" field to the value that was provided on create.
  1747  func (u *PostUpsertBulk) UpdateApproved() *PostUpsertBulk {
  1748  	return u.Update(func(s *PostUpsert) {
  1749  		s.UpdateApproved()
  1750  	})
  1751  }
  1752  
  1753  // ClearApproved clears the value of the "approved" field.
  1754  func (u *PostUpsertBulk) ClearApproved() *PostUpsertBulk {
  1755  	return u.Update(func(s *PostUpsert) {
  1756  		s.ClearApproved()
  1757  	})
  1758  }
  1759  
  1760  // SetFeaturedImageID sets the "featured_image_id" field.
  1761  func (u *PostUpsertBulk) SetFeaturedImageID(v int) *PostUpsertBulk {
  1762  	return u.Update(func(s *PostUpsert) {
  1763  		s.SetFeaturedImageID(v)
  1764  	})
  1765  }
  1766  
  1767  // UpdateFeaturedImageID sets the "featured_image_id" field to the value that was provided on create.
  1768  func (u *PostUpsertBulk) UpdateFeaturedImageID() *PostUpsertBulk {
  1769  	return u.Update(func(s *PostUpsert) {
  1770  		s.UpdateFeaturedImageID()
  1771  	})
  1772  }
  1773  
  1774  // ClearFeaturedImageID clears the value of the "featured_image_id" field.
  1775  func (u *PostUpsertBulk) ClearFeaturedImageID() *PostUpsertBulk {
  1776  	return u.Update(func(s *PostUpsert) {
  1777  		s.ClearFeaturedImageID()
  1778  	})
  1779  }
  1780  
  1781  // SetUserID sets the "user_id" field.
  1782  func (u *PostUpsertBulk) SetUserID(v int) *PostUpsertBulk {
  1783  	return u.Update(func(s *PostUpsert) {
  1784  		s.SetUserID(v)
  1785  	})
  1786  }
  1787  
  1788  // UpdateUserID sets the "user_id" field to the value that was provided on create.
  1789  func (u *PostUpsertBulk) UpdateUserID() *PostUpsertBulk {
  1790  	return u.Update(func(s *PostUpsert) {
  1791  		s.UpdateUserID()
  1792  	})
  1793  }
  1794  
  1795  // ClearUserID clears the value of the "user_id" field.
  1796  func (u *PostUpsertBulk) ClearUserID() *PostUpsertBulk {
  1797  	return u.Update(func(s *PostUpsert) {
  1798  		s.ClearUserID()
  1799  	})
  1800  }
  1801  
  1802  // Exec executes the query.
  1803  func (u *PostUpsertBulk) Exec(ctx context.Context) error {
  1804  	for i, b := range u.create.builders {
  1805  		if len(b.conflict) != 0 {
  1806  			return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the PostCreateBulk instead", i)
  1807  		}
  1808  	}
  1809  	if len(u.create.conflict) == 0 {
  1810  		return errors.New("ent: missing options for PostCreateBulk.OnConflict")
  1811  	}
  1812  	return u.create.Exec(ctx)
  1813  }
  1814  
  1815  // ExecX is like Exec, but panics if an error occurs.
  1816  func (u *PostUpsertBulk) ExecX(ctx context.Context) {
  1817  	if err := u.create.Exec(ctx); err != nil {
  1818  		panic(err)
  1819  	}
  1820  }