// Code generated by ent, DO NOT EDIT. package ent import ( "bj_power_wms/ent/attachment" "context" "errors" "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // AttachmentCreate is the builder for creating a Attachment entity. type AttachmentCreate struct { config mutation *AttachmentMutation hooks []Hook conflict []sql.ConflictOption } // SetBizType sets the "biz_type" field. func (_c *AttachmentCreate) SetBizType(v string) *AttachmentCreate { _c.mutation.SetBizType(v) return _c } // SetBizID sets the "biz_id" field. func (_c *AttachmentCreate) SetBizID(v string) *AttachmentCreate { _c.mutation.SetBizID(v) return _c } // SetFileName sets the "file_name" field. func (_c *AttachmentCreate) SetFileName(v string) *AttachmentCreate { _c.mutation.SetFileName(v) return _c } // SetFilePath sets the "file_path" field. func (_c *AttachmentCreate) SetFilePath(v string) *AttachmentCreate { _c.mutation.SetFilePath(v) return _c } // SetFileType sets the "file_type" field. func (_c *AttachmentCreate) SetFileType(v string) *AttachmentCreate { _c.mutation.SetFileType(v) return _c } // SetNillableFileType sets the "file_type" field if the given value is not nil. func (_c *AttachmentCreate) SetNillableFileType(v *string) *AttachmentCreate { if v != nil { _c.SetFileType(*v) } return _c } // SetFileExt sets the "file_ext" field. func (_c *AttachmentCreate) SetFileExt(v string) *AttachmentCreate { _c.mutation.SetFileExt(v) return _c } // SetNillableFileExt sets the "file_ext" field if the given value is not nil. func (_c *AttachmentCreate) SetNillableFileExt(v *string) *AttachmentCreate { if v != nil { _c.SetFileExt(*v) } return _c } // SetFileMd5 sets the "file_md5" field. func (_c *AttachmentCreate) SetFileMd5(v string) *AttachmentCreate { _c.mutation.SetFileMd5(v) return _c } // SetNillableFileMd5 sets the "file_md5" field if the given value is not nil. func (_c *AttachmentCreate) SetNillableFileMd5(v *string) *AttachmentCreate { if v != nil { _c.SetFileMd5(*v) } return _c } // SetFileSize sets the "file_size" field. func (_c *AttachmentCreate) SetFileSize(v int64) *AttachmentCreate { _c.mutation.SetFileSize(v) return _c } // SetNillableFileSize sets the "file_size" field if the given value is not nil. func (_c *AttachmentCreate) SetNillableFileSize(v *int64) *AttachmentCreate { if v != nil { _c.SetFileSize(*v) } return _c } // SetMimeType sets the "mime_type" field. func (_c *AttachmentCreate) SetMimeType(v string) *AttachmentCreate { _c.mutation.SetMimeType(v) return _c } // SetNillableMimeType sets the "mime_type" field if the given value is not nil. func (_c *AttachmentCreate) SetNillableMimeType(v *string) *AttachmentCreate { if v != nil { _c.SetMimeType(*v) } return _c } // SetUploadedBy sets the "uploaded_by" field. func (_c *AttachmentCreate) SetUploadedBy(v string) *AttachmentCreate { _c.mutation.SetUploadedBy(v) return _c } // SetNillableUploadedBy sets the "uploaded_by" field if the given value is not nil. func (_c *AttachmentCreate) SetNillableUploadedBy(v *string) *AttachmentCreate { if v != nil { _c.SetUploadedBy(*v) } return _c } // SetArchived sets the "archived" field. func (_c *AttachmentCreate) SetArchived(v bool) *AttachmentCreate { _c.mutation.SetArchived(v) return _c } // SetNillableArchived sets the "archived" field if the given value is not nil. func (_c *AttachmentCreate) SetNillableArchived(v *bool) *AttachmentCreate { if v != nil { _c.SetArchived(*v) } return _c } // SetArchivedAt sets the "archived_at" field. func (_c *AttachmentCreate) SetArchivedAt(v int64) *AttachmentCreate { _c.mutation.SetArchivedAt(v) return _c } // SetNillableArchivedAt sets the "archived_at" field if the given value is not nil. func (_c *AttachmentCreate) SetNillableArchivedAt(v *int64) *AttachmentCreate { if v != nil { _c.SetArchivedAt(*v) } return _c } // SetDeleted sets the "deleted" field. func (_c *AttachmentCreate) SetDeleted(v bool) *AttachmentCreate { _c.mutation.SetDeleted(v) return _c } // SetNillableDeleted sets the "deleted" field if the given value is not nil. func (_c *AttachmentCreate) SetNillableDeleted(v *bool) *AttachmentCreate { if v != nil { _c.SetDeleted(*v) } return _c } // SetDeletedAt sets the "deleted_at" field. func (_c *AttachmentCreate) SetDeletedAt(v int64) *AttachmentCreate { _c.mutation.SetDeletedAt(v) return _c } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (_c *AttachmentCreate) SetNillableDeletedAt(v *int64) *AttachmentCreate { if v != nil { _c.SetDeletedAt(*v) } return _c } // SetDeletedBy sets the "deleted_by" field. func (_c *AttachmentCreate) SetDeletedBy(v string) *AttachmentCreate { _c.mutation.SetDeletedBy(v) return _c } // SetNillableDeletedBy sets the "deleted_by" field if the given value is not nil. func (_c *AttachmentCreate) SetNillableDeletedBy(v *string) *AttachmentCreate { if v != nil { _c.SetDeletedBy(*v) } return _c } // SetCreatedAt sets the "created_at" field. func (_c *AttachmentCreate) SetCreatedAt(v int64) *AttachmentCreate { _c.mutation.SetCreatedAt(v) return _c } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (_c *AttachmentCreate) SetNillableCreatedAt(v *int64) *AttachmentCreate { if v != nil { _c.SetCreatedAt(*v) } return _c } // Mutation returns the AttachmentMutation object of the builder. func (_c *AttachmentCreate) Mutation() *AttachmentMutation { return _c.mutation } // Save creates the Attachment in the database. func (_c *AttachmentCreate) Save(ctx context.Context) (*Attachment, error) { _c.defaults() return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. func (_c *AttachmentCreate) SaveX(ctx context.Context) *Attachment { v, err := _c.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (_c *AttachmentCreate) Exec(ctx context.Context) error { _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_c *AttachmentCreate) 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 *AttachmentCreate) defaults() { if _, ok := _c.mutation.FileSize(); !ok { v := attachment.DefaultFileSize _c.mutation.SetFileSize(v) } if _, ok := _c.mutation.Archived(); !ok { v := attachment.DefaultArchived _c.mutation.SetArchived(v) } if _, ok := _c.mutation.Deleted(); !ok { v := attachment.DefaultDeleted _c.mutation.SetDeleted(v) } if _, ok := _c.mutation.CreatedAt(); !ok { v := attachment.DefaultCreatedAt() _c.mutation.SetCreatedAt(v) } } // check runs all checks and user-defined validators on the builder. func (_c *AttachmentCreate) check() error { if _, ok := _c.mutation.BizType(); !ok { return &ValidationError{Name: "biz_type", err: errors.New(`ent: missing required field "Attachment.biz_type"`)} } if _, ok := _c.mutation.BizID(); !ok { return &ValidationError{Name: "biz_id", err: errors.New(`ent: missing required field "Attachment.biz_id"`)} } if _, ok := _c.mutation.FileName(); !ok { return &ValidationError{Name: "file_name", err: errors.New(`ent: missing required field "Attachment.file_name"`)} } if _, ok := _c.mutation.FilePath(); !ok { return &ValidationError{Name: "file_path", err: errors.New(`ent: missing required field "Attachment.file_path"`)} } if _, ok := _c.mutation.FileSize(); !ok { return &ValidationError{Name: "file_size", err: errors.New(`ent: missing required field "Attachment.file_size"`)} } if _, ok := _c.mutation.Archived(); !ok { return &ValidationError{Name: "archived", err: errors.New(`ent: missing required field "Attachment.archived"`)} } if _, ok := _c.mutation.Deleted(); !ok { return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "Attachment.deleted"`)} } if _, ok := _c.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Attachment.created_at"`)} } return nil } func (_c *AttachmentCreate) sqlSave(ctx context.Context) (*Attachment, 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 } id := _spec.ID.Value.(int64) _node.ID = int(id) _c.mutation.id = &_node.ID _c.mutation.done = true return _node, nil } func (_c *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) { var ( _node = &Attachment{config: _c.config} _spec = sqlgraph.NewCreateSpec(attachment.Table, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeInt)) ) _spec.OnConflict = _c.conflict if value, ok := _c.mutation.BizType(); ok { _spec.SetField(attachment.FieldBizType, field.TypeString, value) _node.BizType = value } if value, ok := _c.mutation.BizID(); ok { _spec.SetField(attachment.FieldBizID, field.TypeString, value) _node.BizID = value } if value, ok := _c.mutation.FileName(); ok { _spec.SetField(attachment.FieldFileName, field.TypeString, value) _node.FileName = value } if value, ok := _c.mutation.FilePath(); ok { _spec.SetField(attachment.FieldFilePath, field.TypeString, value) _node.FilePath = value } if value, ok := _c.mutation.FileType(); ok { _spec.SetField(attachment.FieldFileType, field.TypeString, value) _node.FileType = value } if value, ok := _c.mutation.FileExt(); ok { _spec.SetField(attachment.FieldFileExt, field.TypeString, value) _node.FileExt = value } if value, ok := _c.mutation.FileMd5(); ok { _spec.SetField(attachment.FieldFileMd5, field.TypeString, value) _node.FileMd5 = value } if value, ok := _c.mutation.FileSize(); ok { _spec.SetField(attachment.FieldFileSize, field.TypeInt64, value) _node.FileSize = value } if value, ok := _c.mutation.MimeType(); ok { _spec.SetField(attachment.FieldMimeType, field.TypeString, value) _node.MimeType = value } if value, ok := _c.mutation.UploadedBy(); ok { _spec.SetField(attachment.FieldUploadedBy, field.TypeString, value) _node.UploadedBy = value } if value, ok := _c.mutation.Archived(); ok { _spec.SetField(attachment.FieldArchived, field.TypeBool, value) _node.Archived = value } if value, ok := _c.mutation.ArchivedAt(); ok { _spec.SetField(attachment.FieldArchivedAt, field.TypeInt64, value) _node.ArchivedAt = value } if value, ok := _c.mutation.Deleted(); ok { _spec.SetField(attachment.FieldDeleted, field.TypeBool, value) _node.Deleted = value } if value, ok := _c.mutation.DeletedAt(); ok { _spec.SetField(attachment.FieldDeletedAt, field.TypeInt64, value) _node.DeletedAt = value } if value, ok := _c.mutation.DeletedBy(); ok { _spec.SetField(attachment.FieldDeletedBy, field.TypeString, value) _node.DeletedBy = value } if value, ok := _c.mutation.CreatedAt(); ok { _spec.SetField(attachment.FieldCreatedAt, field.TypeInt64, value) _node.CreatedAt = value } return _node, _spec } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.Attachment.Create(). // SetBizType(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.AttachmentUpsert) { // SetBizType(v+v). // }). // Exec(ctx) func (_c *AttachmentCreate) OnConflict(opts ...sql.ConflictOption) *AttachmentUpsertOne { _c.conflict = opts return &AttachmentUpsertOne{ create: _c, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.Attachment.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (_c *AttachmentCreate) OnConflictColumns(columns ...string) *AttachmentUpsertOne { _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) return &AttachmentUpsertOne{ create: _c, } } type ( // AttachmentUpsertOne is the builder for "upsert"-ing // one Attachment node. AttachmentUpsertOne struct { create *AttachmentCreate } // AttachmentUpsert is the "OnConflict" setter. AttachmentUpsert struct { *sql.UpdateSet } ) // SetBizType sets the "biz_type" field. func (u *AttachmentUpsert) SetBizType(v string) *AttachmentUpsert { u.Set(attachment.FieldBizType, v) return u } // UpdateBizType sets the "biz_type" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateBizType() *AttachmentUpsert { u.SetExcluded(attachment.FieldBizType) return u } // SetBizID sets the "biz_id" field. func (u *AttachmentUpsert) SetBizID(v string) *AttachmentUpsert { u.Set(attachment.FieldBizID, v) return u } // UpdateBizID sets the "biz_id" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateBizID() *AttachmentUpsert { u.SetExcluded(attachment.FieldBizID) return u } // SetFileName sets the "file_name" field. func (u *AttachmentUpsert) SetFileName(v string) *AttachmentUpsert { u.Set(attachment.FieldFileName, v) return u } // UpdateFileName sets the "file_name" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateFileName() *AttachmentUpsert { u.SetExcluded(attachment.FieldFileName) return u } // SetFilePath sets the "file_path" field. func (u *AttachmentUpsert) SetFilePath(v string) *AttachmentUpsert { u.Set(attachment.FieldFilePath, v) return u } // UpdateFilePath sets the "file_path" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateFilePath() *AttachmentUpsert { u.SetExcluded(attachment.FieldFilePath) return u } // SetFileType sets the "file_type" field. func (u *AttachmentUpsert) SetFileType(v string) *AttachmentUpsert { u.Set(attachment.FieldFileType, v) return u } // UpdateFileType sets the "file_type" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateFileType() *AttachmentUpsert { u.SetExcluded(attachment.FieldFileType) return u } // ClearFileType clears the value of the "file_type" field. func (u *AttachmentUpsert) ClearFileType() *AttachmentUpsert { u.SetNull(attachment.FieldFileType) return u } // SetFileExt sets the "file_ext" field. func (u *AttachmentUpsert) SetFileExt(v string) *AttachmentUpsert { u.Set(attachment.FieldFileExt, v) return u } // UpdateFileExt sets the "file_ext" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateFileExt() *AttachmentUpsert { u.SetExcluded(attachment.FieldFileExt) return u } // ClearFileExt clears the value of the "file_ext" field. func (u *AttachmentUpsert) ClearFileExt() *AttachmentUpsert { u.SetNull(attachment.FieldFileExt) return u } // SetFileMd5 sets the "file_md5" field. func (u *AttachmentUpsert) SetFileMd5(v string) *AttachmentUpsert { u.Set(attachment.FieldFileMd5, v) return u } // UpdateFileMd5 sets the "file_md5" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateFileMd5() *AttachmentUpsert { u.SetExcluded(attachment.FieldFileMd5) return u } // ClearFileMd5 clears the value of the "file_md5" field. func (u *AttachmentUpsert) ClearFileMd5() *AttachmentUpsert { u.SetNull(attachment.FieldFileMd5) return u } // SetFileSize sets the "file_size" field. func (u *AttachmentUpsert) SetFileSize(v int64) *AttachmentUpsert { u.Set(attachment.FieldFileSize, v) return u } // UpdateFileSize sets the "file_size" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateFileSize() *AttachmentUpsert { u.SetExcluded(attachment.FieldFileSize) return u } // AddFileSize adds v to the "file_size" field. func (u *AttachmentUpsert) AddFileSize(v int64) *AttachmentUpsert { u.Add(attachment.FieldFileSize, v) return u } // SetMimeType sets the "mime_type" field. func (u *AttachmentUpsert) SetMimeType(v string) *AttachmentUpsert { u.Set(attachment.FieldMimeType, v) return u } // UpdateMimeType sets the "mime_type" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateMimeType() *AttachmentUpsert { u.SetExcluded(attachment.FieldMimeType) return u } // ClearMimeType clears the value of the "mime_type" field. func (u *AttachmentUpsert) ClearMimeType() *AttachmentUpsert { u.SetNull(attachment.FieldMimeType) return u } // SetUploadedBy sets the "uploaded_by" field. func (u *AttachmentUpsert) SetUploadedBy(v string) *AttachmentUpsert { u.Set(attachment.FieldUploadedBy, v) return u } // UpdateUploadedBy sets the "uploaded_by" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateUploadedBy() *AttachmentUpsert { u.SetExcluded(attachment.FieldUploadedBy) return u } // ClearUploadedBy clears the value of the "uploaded_by" field. func (u *AttachmentUpsert) ClearUploadedBy() *AttachmentUpsert { u.SetNull(attachment.FieldUploadedBy) return u } // SetArchived sets the "archived" field. func (u *AttachmentUpsert) SetArchived(v bool) *AttachmentUpsert { u.Set(attachment.FieldArchived, v) return u } // UpdateArchived sets the "archived" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateArchived() *AttachmentUpsert { u.SetExcluded(attachment.FieldArchived) return u } // SetArchivedAt sets the "archived_at" field. func (u *AttachmentUpsert) SetArchivedAt(v int64) *AttachmentUpsert { u.Set(attachment.FieldArchivedAt, v) return u } // UpdateArchivedAt sets the "archived_at" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateArchivedAt() *AttachmentUpsert { u.SetExcluded(attachment.FieldArchivedAt) return u } // AddArchivedAt adds v to the "archived_at" field. func (u *AttachmentUpsert) AddArchivedAt(v int64) *AttachmentUpsert { u.Add(attachment.FieldArchivedAt, v) return u } // ClearArchivedAt clears the value of the "archived_at" field. func (u *AttachmentUpsert) ClearArchivedAt() *AttachmentUpsert { u.SetNull(attachment.FieldArchivedAt) return u } // SetDeleted sets the "deleted" field. func (u *AttachmentUpsert) SetDeleted(v bool) *AttachmentUpsert { u.Set(attachment.FieldDeleted, v) return u } // UpdateDeleted sets the "deleted" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateDeleted() *AttachmentUpsert { u.SetExcluded(attachment.FieldDeleted) return u } // SetDeletedAt sets the "deleted_at" field. func (u *AttachmentUpsert) SetDeletedAt(v int64) *AttachmentUpsert { u.Set(attachment.FieldDeletedAt, v) return u } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateDeletedAt() *AttachmentUpsert { u.SetExcluded(attachment.FieldDeletedAt) return u } // AddDeletedAt adds v to the "deleted_at" field. func (u *AttachmentUpsert) AddDeletedAt(v int64) *AttachmentUpsert { u.Add(attachment.FieldDeletedAt, v) return u } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *AttachmentUpsert) ClearDeletedAt() *AttachmentUpsert { u.SetNull(attachment.FieldDeletedAt) return u } // SetDeletedBy sets the "deleted_by" field. func (u *AttachmentUpsert) SetDeletedBy(v string) *AttachmentUpsert { u.Set(attachment.FieldDeletedBy, v) return u } // UpdateDeletedBy sets the "deleted_by" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateDeletedBy() *AttachmentUpsert { u.SetExcluded(attachment.FieldDeletedBy) return u } // ClearDeletedBy clears the value of the "deleted_by" field. func (u *AttachmentUpsert) ClearDeletedBy() *AttachmentUpsert { u.SetNull(attachment.FieldDeletedBy) return u } // SetCreatedAt sets the "created_at" field. func (u *AttachmentUpsert) SetCreatedAt(v int64) *AttachmentUpsert { u.Set(attachment.FieldCreatedAt, v) return u } // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. func (u *AttachmentUpsert) UpdateCreatedAt() *AttachmentUpsert { u.SetExcluded(attachment.FieldCreatedAt) return u } // AddCreatedAt adds v to the "created_at" field. func (u *AttachmentUpsert) AddCreatedAt(v int64) *AttachmentUpsert { u.Add(attachment.FieldCreatedAt, v) return u } // UpdateNewValues updates the mutable fields using the new values that were set on create. // Using this option is equivalent to using: // // client.Attachment.Create(). // OnConflict( // sql.ResolveWithNewValues(), // ). // Exec(ctx) func (u *AttachmentUpsertOne) UpdateNewValues() *AttachmentUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.Attachment.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *AttachmentUpsertOne) Ignore() *AttachmentUpsertOne { 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 *AttachmentUpsertOne) DoNothing() *AttachmentUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the AttachmentCreate.OnConflict // documentation for more info. func (u *AttachmentUpsertOne) Update(set func(*AttachmentUpsert)) *AttachmentUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&AttachmentUpsert{UpdateSet: update}) })) return u } // SetBizType sets the "biz_type" field. func (u *AttachmentUpsertOne) SetBizType(v string) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetBizType(v) }) } // UpdateBizType sets the "biz_type" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateBizType() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateBizType() }) } // SetBizID sets the "biz_id" field. func (u *AttachmentUpsertOne) SetBizID(v string) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetBizID(v) }) } // UpdateBizID sets the "biz_id" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateBizID() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateBizID() }) } // SetFileName sets the "file_name" field. func (u *AttachmentUpsertOne) SetFileName(v string) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetFileName(v) }) } // UpdateFileName sets the "file_name" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateFileName() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateFileName() }) } // SetFilePath sets the "file_path" field. func (u *AttachmentUpsertOne) SetFilePath(v string) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetFilePath(v) }) } // UpdateFilePath sets the "file_path" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateFilePath() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateFilePath() }) } // SetFileType sets the "file_type" field. func (u *AttachmentUpsertOne) SetFileType(v string) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetFileType(v) }) } // UpdateFileType sets the "file_type" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateFileType() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateFileType() }) } // ClearFileType clears the value of the "file_type" field. func (u *AttachmentUpsertOne) ClearFileType() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.ClearFileType() }) } // SetFileExt sets the "file_ext" field. func (u *AttachmentUpsertOne) SetFileExt(v string) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetFileExt(v) }) } // UpdateFileExt sets the "file_ext" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateFileExt() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateFileExt() }) } // ClearFileExt clears the value of the "file_ext" field. func (u *AttachmentUpsertOne) ClearFileExt() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.ClearFileExt() }) } // SetFileMd5 sets the "file_md5" field. func (u *AttachmentUpsertOne) SetFileMd5(v string) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetFileMd5(v) }) } // UpdateFileMd5 sets the "file_md5" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateFileMd5() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateFileMd5() }) } // ClearFileMd5 clears the value of the "file_md5" field. func (u *AttachmentUpsertOne) ClearFileMd5() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.ClearFileMd5() }) } // SetFileSize sets the "file_size" field. func (u *AttachmentUpsertOne) SetFileSize(v int64) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetFileSize(v) }) } // AddFileSize adds v to the "file_size" field. func (u *AttachmentUpsertOne) AddFileSize(v int64) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.AddFileSize(v) }) } // UpdateFileSize sets the "file_size" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateFileSize() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateFileSize() }) } // SetMimeType sets the "mime_type" field. func (u *AttachmentUpsertOne) SetMimeType(v string) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetMimeType(v) }) } // UpdateMimeType sets the "mime_type" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateMimeType() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateMimeType() }) } // ClearMimeType clears the value of the "mime_type" field. func (u *AttachmentUpsertOne) ClearMimeType() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.ClearMimeType() }) } // SetUploadedBy sets the "uploaded_by" field. func (u *AttachmentUpsertOne) SetUploadedBy(v string) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetUploadedBy(v) }) } // UpdateUploadedBy sets the "uploaded_by" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateUploadedBy() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateUploadedBy() }) } // ClearUploadedBy clears the value of the "uploaded_by" field. func (u *AttachmentUpsertOne) ClearUploadedBy() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.ClearUploadedBy() }) } // SetArchived sets the "archived" field. func (u *AttachmentUpsertOne) SetArchived(v bool) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetArchived(v) }) } // UpdateArchived sets the "archived" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateArchived() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateArchived() }) } // SetArchivedAt sets the "archived_at" field. func (u *AttachmentUpsertOne) SetArchivedAt(v int64) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetArchivedAt(v) }) } // AddArchivedAt adds v to the "archived_at" field. func (u *AttachmentUpsertOne) AddArchivedAt(v int64) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.AddArchivedAt(v) }) } // UpdateArchivedAt sets the "archived_at" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateArchivedAt() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateArchivedAt() }) } // ClearArchivedAt clears the value of the "archived_at" field. func (u *AttachmentUpsertOne) ClearArchivedAt() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.ClearArchivedAt() }) } // SetDeleted sets the "deleted" field. func (u *AttachmentUpsertOne) SetDeleted(v bool) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetDeleted(v) }) } // UpdateDeleted sets the "deleted" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateDeleted() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateDeleted() }) } // SetDeletedAt sets the "deleted_at" field. func (u *AttachmentUpsertOne) SetDeletedAt(v int64) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetDeletedAt(v) }) } // AddDeletedAt adds v to the "deleted_at" field. func (u *AttachmentUpsertOne) AddDeletedAt(v int64) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.AddDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateDeletedAt() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *AttachmentUpsertOne) ClearDeletedAt() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.ClearDeletedAt() }) } // SetDeletedBy sets the "deleted_by" field. func (u *AttachmentUpsertOne) SetDeletedBy(v string) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetDeletedBy(v) }) } // UpdateDeletedBy sets the "deleted_by" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateDeletedBy() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateDeletedBy() }) } // ClearDeletedBy clears the value of the "deleted_by" field. func (u *AttachmentUpsertOne) ClearDeletedBy() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.ClearDeletedBy() }) } // SetCreatedAt sets the "created_at" field. func (u *AttachmentUpsertOne) SetCreatedAt(v int64) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.SetCreatedAt(v) }) } // AddCreatedAt adds v to the "created_at" field. func (u *AttachmentUpsertOne) AddCreatedAt(v int64) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.AddCreatedAt(v) }) } // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. func (u *AttachmentUpsertOne) UpdateCreatedAt() *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { s.UpdateCreatedAt() }) } // Exec executes the query. func (u *AttachmentUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { return errors.New("ent: missing options for AttachmentCreate.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *AttachmentUpsertOne) 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 *AttachmentUpsertOne) ID(ctx context.Context) (id int, 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 *AttachmentUpsertOne) IDX(ctx context.Context) int { id, err := u.ID(ctx) if err != nil { panic(err) } return id } // AttachmentCreateBulk is the builder for creating many Attachment entities in bulk. type AttachmentCreateBulk struct { config err error builders []*AttachmentCreate conflict []sql.ConflictOption } // Save creates the Attachment entities in the database. func (_c *AttachmentCreateBulk) Save(ctx context.Context) ([]*Attachment, error) { if _c.err != nil { return nil, _c.err } specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) nodes := make([]*Attachment, 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.(*AttachmentMutation) 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 { id := specs[i].ID.Value.(int64) nodes[i].ID = int(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 *AttachmentCreateBulk) SaveX(ctx context.Context) []*Attachment { v, err := _c.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (_c *AttachmentCreateBulk) Exec(ctx context.Context) error { _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_c *AttachmentCreateBulk) 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.Attachment.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.AttachmentUpsert) { // SetBizType(v+v). // }). // Exec(ctx) func (_c *AttachmentCreateBulk) OnConflict(opts ...sql.ConflictOption) *AttachmentUpsertBulk { _c.conflict = opts return &AttachmentUpsertBulk{ create: _c, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.Attachment.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (_c *AttachmentCreateBulk) OnConflictColumns(columns ...string) *AttachmentUpsertBulk { _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) return &AttachmentUpsertBulk{ create: _c, } } // AttachmentUpsertBulk is the builder for "upsert"-ing // a bulk of Attachment nodes. type AttachmentUpsertBulk struct { create *AttachmentCreateBulk } // UpdateNewValues updates the mutable fields using the new values that // were set on create. Using this option is equivalent to using: // // client.Attachment.Create(). // OnConflict( // sql.ResolveWithNewValues(), // ). // Exec(ctx) func (u *AttachmentUpsertBulk) UpdateNewValues() *AttachmentUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.Attachment.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *AttachmentUpsertBulk) Ignore() *AttachmentUpsertBulk { 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 *AttachmentUpsertBulk) DoNothing() *AttachmentUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the AttachmentCreateBulk.OnConflict // documentation for more info. func (u *AttachmentUpsertBulk) Update(set func(*AttachmentUpsert)) *AttachmentUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&AttachmentUpsert{UpdateSet: update}) })) return u } // SetBizType sets the "biz_type" field. func (u *AttachmentUpsertBulk) SetBizType(v string) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetBizType(v) }) } // UpdateBizType sets the "biz_type" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateBizType() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateBizType() }) } // SetBizID sets the "biz_id" field. func (u *AttachmentUpsertBulk) SetBizID(v string) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetBizID(v) }) } // UpdateBizID sets the "biz_id" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateBizID() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateBizID() }) } // SetFileName sets the "file_name" field. func (u *AttachmentUpsertBulk) SetFileName(v string) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetFileName(v) }) } // UpdateFileName sets the "file_name" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateFileName() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateFileName() }) } // SetFilePath sets the "file_path" field. func (u *AttachmentUpsertBulk) SetFilePath(v string) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetFilePath(v) }) } // UpdateFilePath sets the "file_path" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateFilePath() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateFilePath() }) } // SetFileType sets the "file_type" field. func (u *AttachmentUpsertBulk) SetFileType(v string) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetFileType(v) }) } // UpdateFileType sets the "file_type" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateFileType() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateFileType() }) } // ClearFileType clears the value of the "file_type" field. func (u *AttachmentUpsertBulk) ClearFileType() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.ClearFileType() }) } // SetFileExt sets the "file_ext" field. func (u *AttachmentUpsertBulk) SetFileExt(v string) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetFileExt(v) }) } // UpdateFileExt sets the "file_ext" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateFileExt() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateFileExt() }) } // ClearFileExt clears the value of the "file_ext" field. func (u *AttachmentUpsertBulk) ClearFileExt() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.ClearFileExt() }) } // SetFileMd5 sets the "file_md5" field. func (u *AttachmentUpsertBulk) SetFileMd5(v string) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetFileMd5(v) }) } // UpdateFileMd5 sets the "file_md5" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateFileMd5() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateFileMd5() }) } // ClearFileMd5 clears the value of the "file_md5" field. func (u *AttachmentUpsertBulk) ClearFileMd5() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.ClearFileMd5() }) } // SetFileSize sets the "file_size" field. func (u *AttachmentUpsertBulk) SetFileSize(v int64) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetFileSize(v) }) } // AddFileSize adds v to the "file_size" field. func (u *AttachmentUpsertBulk) AddFileSize(v int64) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.AddFileSize(v) }) } // UpdateFileSize sets the "file_size" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateFileSize() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateFileSize() }) } // SetMimeType sets the "mime_type" field. func (u *AttachmentUpsertBulk) SetMimeType(v string) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetMimeType(v) }) } // UpdateMimeType sets the "mime_type" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateMimeType() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateMimeType() }) } // ClearMimeType clears the value of the "mime_type" field. func (u *AttachmentUpsertBulk) ClearMimeType() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.ClearMimeType() }) } // SetUploadedBy sets the "uploaded_by" field. func (u *AttachmentUpsertBulk) SetUploadedBy(v string) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetUploadedBy(v) }) } // UpdateUploadedBy sets the "uploaded_by" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateUploadedBy() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateUploadedBy() }) } // ClearUploadedBy clears the value of the "uploaded_by" field. func (u *AttachmentUpsertBulk) ClearUploadedBy() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.ClearUploadedBy() }) } // SetArchived sets the "archived" field. func (u *AttachmentUpsertBulk) SetArchived(v bool) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetArchived(v) }) } // UpdateArchived sets the "archived" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateArchived() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateArchived() }) } // SetArchivedAt sets the "archived_at" field. func (u *AttachmentUpsertBulk) SetArchivedAt(v int64) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetArchivedAt(v) }) } // AddArchivedAt adds v to the "archived_at" field. func (u *AttachmentUpsertBulk) AddArchivedAt(v int64) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.AddArchivedAt(v) }) } // UpdateArchivedAt sets the "archived_at" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateArchivedAt() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateArchivedAt() }) } // ClearArchivedAt clears the value of the "archived_at" field. func (u *AttachmentUpsertBulk) ClearArchivedAt() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.ClearArchivedAt() }) } // SetDeleted sets the "deleted" field. func (u *AttachmentUpsertBulk) SetDeleted(v bool) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetDeleted(v) }) } // UpdateDeleted sets the "deleted" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateDeleted() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateDeleted() }) } // SetDeletedAt sets the "deleted_at" field. func (u *AttachmentUpsertBulk) SetDeletedAt(v int64) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetDeletedAt(v) }) } // AddDeletedAt adds v to the "deleted_at" field. func (u *AttachmentUpsertBulk) AddDeletedAt(v int64) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.AddDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateDeletedAt() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *AttachmentUpsertBulk) ClearDeletedAt() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.ClearDeletedAt() }) } // SetDeletedBy sets the "deleted_by" field. func (u *AttachmentUpsertBulk) SetDeletedBy(v string) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetDeletedBy(v) }) } // UpdateDeletedBy sets the "deleted_by" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateDeletedBy() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateDeletedBy() }) } // ClearDeletedBy clears the value of the "deleted_by" field. func (u *AttachmentUpsertBulk) ClearDeletedBy() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.ClearDeletedBy() }) } // SetCreatedAt sets the "created_at" field. func (u *AttachmentUpsertBulk) SetCreatedAt(v int64) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.SetCreatedAt(v) }) } // AddCreatedAt adds v to the "created_at" field. func (u *AttachmentUpsertBulk) AddCreatedAt(v int64) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.AddCreatedAt(v) }) } // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. func (u *AttachmentUpsertBulk) UpdateCreatedAt() *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { s.UpdateCreatedAt() }) } // Exec executes the query. func (u *AttachmentUpsertBulk) 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 AttachmentCreateBulk instead", i) } } if len(u.create.conflict) == 0 { return errors.New("ent: missing options for AttachmentCreateBulk.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *AttachmentUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } }