// Code generated by ent, DO NOT EDIT. package ent import ( "bj_power_wms/ent/attachment" "bj_power_wms/ent/predicate" "context" "errors" "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // AttachmentUpdate is the builder for updating Attachment entities. type AttachmentUpdate struct { config hooks []Hook mutation *AttachmentMutation } // Where appends a list predicates to the AttachmentUpdate builder. func (_u *AttachmentUpdate) Where(ps ...predicate.Attachment) *AttachmentUpdate { _u.mutation.Where(ps...) return _u } // SetBizType sets the "biz_type" field. func (_u *AttachmentUpdate) SetBizType(v string) *AttachmentUpdate { _u.mutation.SetBizType(v) return _u } // SetNillableBizType sets the "biz_type" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableBizType(v *string) *AttachmentUpdate { if v != nil { _u.SetBizType(*v) } return _u } // SetBizID sets the "biz_id" field. func (_u *AttachmentUpdate) SetBizID(v string) *AttachmentUpdate { _u.mutation.SetBizID(v) return _u } // SetNillableBizID sets the "biz_id" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableBizID(v *string) *AttachmentUpdate { if v != nil { _u.SetBizID(*v) } return _u } // SetFileName sets the "file_name" field. func (_u *AttachmentUpdate) SetFileName(v string) *AttachmentUpdate { _u.mutation.SetFileName(v) return _u } // SetNillableFileName sets the "file_name" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableFileName(v *string) *AttachmentUpdate { if v != nil { _u.SetFileName(*v) } return _u } // SetFilePath sets the "file_path" field. func (_u *AttachmentUpdate) SetFilePath(v string) *AttachmentUpdate { _u.mutation.SetFilePath(v) return _u } // SetNillableFilePath sets the "file_path" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableFilePath(v *string) *AttachmentUpdate { if v != nil { _u.SetFilePath(*v) } return _u } // SetFileType sets the "file_type" field. func (_u *AttachmentUpdate) SetFileType(v string) *AttachmentUpdate { _u.mutation.SetFileType(v) return _u } // SetNillableFileType sets the "file_type" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableFileType(v *string) *AttachmentUpdate { if v != nil { _u.SetFileType(*v) } return _u } // ClearFileType clears the value of the "file_type" field. func (_u *AttachmentUpdate) ClearFileType() *AttachmentUpdate { _u.mutation.ClearFileType() return _u } // SetFileExt sets the "file_ext" field. func (_u *AttachmentUpdate) SetFileExt(v string) *AttachmentUpdate { _u.mutation.SetFileExt(v) return _u } // SetNillableFileExt sets the "file_ext" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableFileExt(v *string) *AttachmentUpdate { if v != nil { _u.SetFileExt(*v) } return _u } // ClearFileExt clears the value of the "file_ext" field. func (_u *AttachmentUpdate) ClearFileExt() *AttachmentUpdate { _u.mutation.ClearFileExt() return _u } // SetFileMd5 sets the "file_md5" field. func (_u *AttachmentUpdate) SetFileMd5(v string) *AttachmentUpdate { _u.mutation.SetFileMd5(v) return _u } // SetNillableFileMd5 sets the "file_md5" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableFileMd5(v *string) *AttachmentUpdate { if v != nil { _u.SetFileMd5(*v) } return _u } // ClearFileMd5 clears the value of the "file_md5" field. func (_u *AttachmentUpdate) ClearFileMd5() *AttachmentUpdate { _u.mutation.ClearFileMd5() return _u } // SetFileSize sets the "file_size" field. func (_u *AttachmentUpdate) SetFileSize(v int64) *AttachmentUpdate { _u.mutation.ResetFileSize() _u.mutation.SetFileSize(v) return _u } // SetNillableFileSize sets the "file_size" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableFileSize(v *int64) *AttachmentUpdate { if v != nil { _u.SetFileSize(*v) } return _u } // AddFileSize adds value to the "file_size" field. func (_u *AttachmentUpdate) AddFileSize(v int64) *AttachmentUpdate { _u.mutation.AddFileSize(v) return _u } // SetMimeType sets the "mime_type" field. func (_u *AttachmentUpdate) SetMimeType(v string) *AttachmentUpdate { _u.mutation.SetMimeType(v) return _u } // SetNillableMimeType sets the "mime_type" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableMimeType(v *string) *AttachmentUpdate { if v != nil { _u.SetMimeType(*v) } return _u } // ClearMimeType clears the value of the "mime_type" field. func (_u *AttachmentUpdate) ClearMimeType() *AttachmentUpdate { _u.mutation.ClearMimeType() return _u } // SetUploadedBy sets the "uploaded_by" field. func (_u *AttachmentUpdate) SetUploadedBy(v string) *AttachmentUpdate { _u.mutation.SetUploadedBy(v) return _u } // SetNillableUploadedBy sets the "uploaded_by" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableUploadedBy(v *string) *AttachmentUpdate { if v != nil { _u.SetUploadedBy(*v) } return _u } // ClearUploadedBy clears the value of the "uploaded_by" field. func (_u *AttachmentUpdate) ClearUploadedBy() *AttachmentUpdate { _u.mutation.ClearUploadedBy() return _u } // SetArchived sets the "archived" field. func (_u *AttachmentUpdate) SetArchived(v bool) *AttachmentUpdate { _u.mutation.SetArchived(v) return _u } // SetNillableArchived sets the "archived" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableArchived(v *bool) *AttachmentUpdate { if v != nil { _u.SetArchived(*v) } return _u } // SetArchivedAt sets the "archived_at" field. func (_u *AttachmentUpdate) SetArchivedAt(v int64) *AttachmentUpdate { _u.mutation.ResetArchivedAt() _u.mutation.SetArchivedAt(v) return _u } // SetNillableArchivedAt sets the "archived_at" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableArchivedAt(v *int64) *AttachmentUpdate { if v != nil { _u.SetArchivedAt(*v) } return _u } // AddArchivedAt adds value to the "archived_at" field. func (_u *AttachmentUpdate) AddArchivedAt(v int64) *AttachmentUpdate { _u.mutation.AddArchivedAt(v) return _u } // ClearArchivedAt clears the value of the "archived_at" field. func (_u *AttachmentUpdate) ClearArchivedAt() *AttachmentUpdate { _u.mutation.ClearArchivedAt() return _u } // SetDeleted sets the "deleted" field. func (_u *AttachmentUpdate) SetDeleted(v bool) *AttachmentUpdate { _u.mutation.SetDeleted(v) return _u } // SetNillableDeleted sets the "deleted" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableDeleted(v *bool) *AttachmentUpdate { if v != nil { _u.SetDeleted(*v) } return _u } // SetDeletedAt sets the "deleted_at" field. func (_u *AttachmentUpdate) SetDeletedAt(v int64) *AttachmentUpdate { _u.mutation.ResetDeletedAt() _u.mutation.SetDeletedAt(v) return _u } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableDeletedAt(v *int64) *AttachmentUpdate { if v != nil { _u.SetDeletedAt(*v) } return _u } // AddDeletedAt adds value to the "deleted_at" field. func (_u *AttachmentUpdate) AddDeletedAt(v int64) *AttachmentUpdate { _u.mutation.AddDeletedAt(v) return _u } // ClearDeletedAt clears the value of the "deleted_at" field. func (_u *AttachmentUpdate) ClearDeletedAt() *AttachmentUpdate { _u.mutation.ClearDeletedAt() return _u } // SetDeletedBy sets the "deleted_by" field. func (_u *AttachmentUpdate) SetDeletedBy(v string) *AttachmentUpdate { _u.mutation.SetDeletedBy(v) return _u } // SetNillableDeletedBy sets the "deleted_by" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableDeletedBy(v *string) *AttachmentUpdate { if v != nil { _u.SetDeletedBy(*v) } return _u } // ClearDeletedBy clears the value of the "deleted_by" field. func (_u *AttachmentUpdate) ClearDeletedBy() *AttachmentUpdate { _u.mutation.ClearDeletedBy() return _u } // SetCreatedAt sets the "created_at" field. func (_u *AttachmentUpdate) SetCreatedAt(v int64) *AttachmentUpdate { _u.mutation.ResetCreatedAt() _u.mutation.SetCreatedAt(v) return _u } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (_u *AttachmentUpdate) SetNillableCreatedAt(v *int64) *AttachmentUpdate { if v != nil { _u.SetCreatedAt(*v) } return _u } // AddCreatedAt adds value to the "created_at" field. func (_u *AttachmentUpdate) AddCreatedAt(v int64) *AttachmentUpdate { _u.mutation.AddCreatedAt(v) return _u } // Mutation returns the AttachmentMutation object of the builder. func (_u *AttachmentUpdate) Mutation() *AttachmentMutation { return _u.mutation } // Save executes the query and returns the number of nodes affected by the update operation. func (_u *AttachmentUpdate) Save(ctx context.Context) (int, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *AttachmentUpdate) SaveX(ctx context.Context) int { affected, err := _u.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (_u *AttachmentUpdate) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *AttachmentUpdate) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } func (_u *AttachmentUpdate) sqlSave(ctx context.Context) (_node int, err error) { _spec := sqlgraph.NewUpdateSpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeInt)) if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := _u.mutation.BizType(); ok { _spec.SetField(attachment.FieldBizType, field.TypeString, value) } if value, ok := _u.mutation.BizID(); ok { _spec.SetField(attachment.FieldBizID, field.TypeString, value) } if value, ok := _u.mutation.FileName(); ok { _spec.SetField(attachment.FieldFileName, field.TypeString, value) } if value, ok := _u.mutation.FilePath(); ok { _spec.SetField(attachment.FieldFilePath, field.TypeString, value) } if value, ok := _u.mutation.FileType(); ok { _spec.SetField(attachment.FieldFileType, field.TypeString, value) } if _u.mutation.FileTypeCleared() { _spec.ClearField(attachment.FieldFileType, field.TypeString) } if value, ok := _u.mutation.FileExt(); ok { _spec.SetField(attachment.FieldFileExt, field.TypeString, value) } if _u.mutation.FileExtCleared() { _spec.ClearField(attachment.FieldFileExt, field.TypeString) } if value, ok := _u.mutation.FileMd5(); ok { _spec.SetField(attachment.FieldFileMd5, field.TypeString, value) } if _u.mutation.FileMd5Cleared() { _spec.ClearField(attachment.FieldFileMd5, field.TypeString) } if value, ok := _u.mutation.FileSize(); ok { _spec.SetField(attachment.FieldFileSize, field.TypeInt64, value) } if value, ok := _u.mutation.AddedFileSize(); ok { _spec.AddField(attachment.FieldFileSize, field.TypeInt64, value) } if value, ok := _u.mutation.MimeType(); ok { _spec.SetField(attachment.FieldMimeType, field.TypeString, value) } if _u.mutation.MimeTypeCleared() { _spec.ClearField(attachment.FieldMimeType, field.TypeString) } if value, ok := _u.mutation.UploadedBy(); ok { _spec.SetField(attachment.FieldUploadedBy, field.TypeString, value) } if _u.mutation.UploadedByCleared() { _spec.ClearField(attachment.FieldUploadedBy, field.TypeString) } if value, ok := _u.mutation.Archived(); ok { _spec.SetField(attachment.FieldArchived, field.TypeBool, value) } if value, ok := _u.mutation.ArchivedAt(); ok { _spec.SetField(attachment.FieldArchivedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedArchivedAt(); ok { _spec.AddField(attachment.FieldArchivedAt, field.TypeInt64, value) } if _u.mutation.ArchivedAtCleared() { _spec.ClearField(attachment.FieldArchivedAt, field.TypeInt64) } if value, ok := _u.mutation.Deleted(); ok { _spec.SetField(attachment.FieldDeleted, field.TypeBool, value) } if value, ok := _u.mutation.DeletedAt(); ok { _spec.SetField(attachment.FieldDeletedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedDeletedAt(); ok { _spec.AddField(attachment.FieldDeletedAt, field.TypeInt64, value) } if _u.mutation.DeletedAtCleared() { _spec.ClearField(attachment.FieldDeletedAt, field.TypeInt64) } if value, ok := _u.mutation.DeletedBy(); ok { _spec.SetField(attachment.FieldDeletedBy, field.TypeString, value) } if _u.mutation.DeletedByCleared() { _spec.ClearField(attachment.FieldDeletedBy, field.TypeString) } if value, ok := _u.mutation.CreatedAt(); ok { _spec.SetField(attachment.FieldCreatedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedCreatedAt(); ok { _spec.AddField(attachment.FieldCreatedAt, field.TypeInt64, value) } if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{attachment.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } _u.mutation.done = true return _node, nil } // AttachmentUpdateOne is the builder for updating a single Attachment entity. type AttachmentUpdateOne struct { config fields []string hooks []Hook mutation *AttachmentMutation } // SetBizType sets the "biz_type" field. func (_u *AttachmentUpdateOne) SetBizType(v string) *AttachmentUpdateOne { _u.mutation.SetBizType(v) return _u } // SetNillableBizType sets the "biz_type" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableBizType(v *string) *AttachmentUpdateOne { if v != nil { _u.SetBizType(*v) } return _u } // SetBizID sets the "biz_id" field. func (_u *AttachmentUpdateOne) SetBizID(v string) *AttachmentUpdateOne { _u.mutation.SetBizID(v) return _u } // SetNillableBizID sets the "biz_id" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableBizID(v *string) *AttachmentUpdateOne { if v != nil { _u.SetBizID(*v) } return _u } // SetFileName sets the "file_name" field. func (_u *AttachmentUpdateOne) SetFileName(v string) *AttachmentUpdateOne { _u.mutation.SetFileName(v) return _u } // SetNillableFileName sets the "file_name" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableFileName(v *string) *AttachmentUpdateOne { if v != nil { _u.SetFileName(*v) } return _u } // SetFilePath sets the "file_path" field. func (_u *AttachmentUpdateOne) SetFilePath(v string) *AttachmentUpdateOne { _u.mutation.SetFilePath(v) return _u } // SetNillableFilePath sets the "file_path" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableFilePath(v *string) *AttachmentUpdateOne { if v != nil { _u.SetFilePath(*v) } return _u } // SetFileType sets the "file_type" field. func (_u *AttachmentUpdateOne) SetFileType(v string) *AttachmentUpdateOne { _u.mutation.SetFileType(v) return _u } // SetNillableFileType sets the "file_type" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableFileType(v *string) *AttachmentUpdateOne { if v != nil { _u.SetFileType(*v) } return _u } // ClearFileType clears the value of the "file_type" field. func (_u *AttachmentUpdateOne) ClearFileType() *AttachmentUpdateOne { _u.mutation.ClearFileType() return _u } // SetFileExt sets the "file_ext" field. func (_u *AttachmentUpdateOne) SetFileExt(v string) *AttachmentUpdateOne { _u.mutation.SetFileExt(v) return _u } // SetNillableFileExt sets the "file_ext" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableFileExt(v *string) *AttachmentUpdateOne { if v != nil { _u.SetFileExt(*v) } return _u } // ClearFileExt clears the value of the "file_ext" field. func (_u *AttachmentUpdateOne) ClearFileExt() *AttachmentUpdateOne { _u.mutation.ClearFileExt() return _u } // SetFileMd5 sets the "file_md5" field. func (_u *AttachmentUpdateOne) SetFileMd5(v string) *AttachmentUpdateOne { _u.mutation.SetFileMd5(v) return _u } // SetNillableFileMd5 sets the "file_md5" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableFileMd5(v *string) *AttachmentUpdateOne { if v != nil { _u.SetFileMd5(*v) } return _u } // ClearFileMd5 clears the value of the "file_md5" field. func (_u *AttachmentUpdateOne) ClearFileMd5() *AttachmentUpdateOne { _u.mutation.ClearFileMd5() return _u } // SetFileSize sets the "file_size" field. func (_u *AttachmentUpdateOne) SetFileSize(v int64) *AttachmentUpdateOne { _u.mutation.ResetFileSize() _u.mutation.SetFileSize(v) return _u } // SetNillableFileSize sets the "file_size" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableFileSize(v *int64) *AttachmentUpdateOne { if v != nil { _u.SetFileSize(*v) } return _u } // AddFileSize adds value to the "file_size" field. func (_u *AttachmentUpdateOne) AddFileSize(v int64) *AttachmentUpdateOne { _u.mutation.AddFileSize(v) return _u } // SetMimeType sets the "mime_type" field. func (_u *AttachmentUpdateOne) SetMimeType(v string) *AttachmentUpdateOne { _u.mutation.SetMimeType(v) return _u } // SetNillableMimeType sets the "mime_type" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableMimeType(v *string) *AttachmentUpdateOne { if v != nil { _u.SetMimeType(*v) } return _u } // ClearMimeType clears the value of the "mime_type" field. func (_u *AttachmentUpdateOne) ClearMimeType() *AttachmentUpdateOne { _u.mutation.ClearMimeType() return _u } // SetUploadedBy sets the "uploaded_by" field. func (_u *AttachmentUpdateOne) SetUploadedBy(v string) *AttachmentUpdateOne { _u.mutation.SetUploadedBy(v) return _u } // SetNillableUploadedBy sets the "uploaded_by" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableUploadedBy(v *string) *AttachmentUpdateOne { if v != nil { _u.SetUploadedBy(*v) } return _u } // ClearUploadedBy clears the value of the "uploaded_by" field. func (_u *AttachmentUpdateOne) ClearUploadedBy() *AttachmentUpdateOne { _u.mutation.ClearUploadedBy() return _u } // SetArchived sets the "archived" field. func (_u *AttachmentUpdateOne) SetArchived(v bool) *AttachmentUpdateOne { _u.mutation.SetArchived(v) return _u } // SetNillableArchived sets the "archived" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableArchived(v *bool) *AttachmentUpdateOne { if v != nil { _u.SetArchived(*v) } return _u } // SetArchivedAt sets the "archived_at" field. func (_u *AttachmentUpdateOne) SetArchivedAt(v int64) *AttachmentUpdateOne { _u.mutation.ResetArchivedAt() _u.mutation.SetArchivedAt(v) return _u } // SetNillableArchivedAt sets the "archived_at" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableArchivedAt(v *int64) *AttachmentUpdateOne { if v != nil { _u.SetArchivedAt(*v) } return _u } // AddArchivedAt adds value to the "archived_at" field. func (_u *AttachmentUpdateOne) AddArchivedAt(v int64) *AttachmentUpdateOne { _u.mutation.AddArchivedAt(v) return _u } // ClearArchivedAt clears the value of the "archived_at" field. func (_u *AttachmentUpdateOne) ClearArchivedAt() *AttachmentUpdateOne { _u.mutation.ClearArchivedAt() return _u } // SetDeleted sets the "deleted" field. func (_u *AttachmentUpdateOne) SetDeleted(v bool) *AttachmentUpdateOne { _u.mutation.SetDeleted(v) return _u } // SetNillableDeleted sets the "deleted" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableDeleted(v *bool) *AttachmentUpdateOne { if v != nil { _u.SetDeleted(*v) } return _u } // SetDeletedAt sets the "deleted_at" field. func (_u *AttachmentUpdateOne) SetDeletedAt(v int64) *AttachmentUpdateOne { _u.mutation.ResetDeletedAt() _u.mutation.SetDeletedAt(v) return _u } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableDeletedAt(v *int64) *AttachmentUpdateOne { if v != nil { _u.SetDeletedAt(*v) } return _u } // AddDeletedAt adds value to the "deleted_at" field. func (_u *AttachmentUpdateOne) AddDeletedAt(v int64) *AttachmentUpdateOne { _u.mutation.AddDeletedAt(v) return _u } // ClearDeletedAt clears the value of the "deleted_at" field. func (_u *AttachmentUpdateOne) ClearDeletedAt() *AttachmentUpdateOne { _u.mutation.ClearDeletedAt() return _u } // SetDeletedBy sets the "deleted_by" field. func (_u *AttachmentUpdateOne) SetDeletedBy(v string) *AttachmentUpdateOne { _u.mutation.SetDeletedBy(v) return _u } // SetNillableDeletedBy sets the "deleted_by" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableDeletedBy(v *string) *AttachmentUpdateOne { if v != nil { _u.SetDeletedBy(*v) } return _u } // ClearDeletedBy clears the value of the "deleted_by" field. func (_u *AttachmentUpdateOne) ClearDeletedBy() *AttachmentUpdateOne { _u.mutation.ClearDeletedBy() return _u } // SetCreatedAt sets the "created_at" field. func (_u *AttachmentUpdateOne) SetCreatedAt(v int64) *AttachmentUpdateOne { _u.mutation.ResetCreatedAt() _u.mutation.SetCreatedAt(v) return _u } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (_u *AttachmentUpdateOne) SetNillableCreatedAt(v *int64) *AttachmentUpdateOne { if v != nil { _u.SetCreatedAt(*v) } return _u } // AddCreatedAt adds value to the "created_at" field. func (_u *AttachmentUpdateOne) AddCreatedAt(v int64) *AttachmentUpdateOne { _u.mutation.AddCreatedAt(v) return _u } // Mutation returns the AttachmentMutation object of the builder. func (_u *AttachmentUpdateOne) Mutation() *AttachmentMutation { return _u.mutation } // Where appends a list predicates to the AttachmentUpdate builder. func (_u *AttachmentUpdateOne) Where(ps ...predicate.Attachment) *AttachmentUpdateOne { _u.mutation.Where(ps...) return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (_u *AttachmentUpdateOne) Select(field string, fields ...string) *AttachmentUpdateOne { _u.fields = append([]string{field}, fields...) return _u } // Save executes the query and returns the updated Attachment entity. func (_u *AttachmentUpdateOne) Save(ctx context.Context) (*Attachment, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *AttachmentUpdateOne) SaveX(ctx context.Context) *Attachment { node, err := _u.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (_u *AttachmentUpdateOne) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *AttachmentUpdateOne) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } func (_u *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment, err error) { _spec := sqlgraph.NewUpdateSpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeInt)) id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Attachment.id" for update`)} } _spec.Node.ID.Value = id if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, attachment.FieldID) for _, f := range fields { if !attachment.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } if f != attachment.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, f) } } } if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := _u.mutation.BizType(); ok { _spec.SetField(attachment.FieldBizType, field.TypeString, value) } if value, ok := _u.mutation.BizID(); ok { _spec.SetField(attachment.FieldBizID, field.TypeString, value) } if value, ok := _u.mutation.FileName(); ok { _spec.SetField(attachment.FieldFileName, field.TypeString, value) } if value, ok := _u.mutation.FilePath(); ok { _spec.SetField(attachment.FieldFilePath, field.TypeString, value) } if value, ok := _u.mutation.FileType(); ok { _spec.SetField(attachment.FieldFileType, field.TypeString, value) } if _u.mutation.FileTypeCleared() { _spec.ClearField(attachment.FieldFileType, field.TypeString) } if value, ok := _u.mutation.FileExt(); ok { _spec.SetField(attachment.FieldFileExt, field.TypeString, value) } if _u.mutation.FileExtCleared() { _spec.ClearField(attachment.FieldFileExt, field.TypeString) } if value, ok := _u.mutation.FileMd5(); ok { _spec.SetField(attachment.FieldFileMd5, field.TypeString, value) } if _u.mutation.FileMd5Cleared() { _spec.ClearField(attachment.FieldFileMd5, field.TypeString) } if value, ok := _u.mutation.FileSize(); ok { _spec.SetField(attachment.FieldFileSize, field.TypeInt64, value) } if value, ok := _u.mutation.AddedFileSize(); ok { _spec.AddField(attachment.FieldFileSize, field.TypeInt64, value) } if value, ok := _u.mutation.MimeType(); ok { _spec.SetField(attachment.FieldMimeType, field.TypeString, value) } if _u.mutation.MimeTypeCleared() { _spec.ClearField(attachment.FieldMimeType, field.TypeString) } if value, ok := _u.mutation.UploadedBy(); ok { _spec.SetField(attachment.FieldUploadedBy, field.TypeString, value) } if _u.mutation.UploadedByCleared() { _spec.ClearField(attachment.FieldUploadedBy, field.TypeString) } if value, ok := _u.mutation.Archived(); ok { _spec.SetField(attachment.FieldArchived, field.TypeBool, value) } if value, ok := _u.mutation.ArchivedAt(); ok { _spec.SetField(attachment.FieldArchivedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedArchivedAt(); ok { _spec.AddField(attachment.FieldArchivedAt, field.TypeInt64, value) } if _u.mutation.ArchivedAtCleared() { _spec.ClearField(attachment.FieldArchivedAt, field.TypeInt64) } if value, ok := _u.mutation.Deleted(); ok { _spec.SetField(attachment.FieldDeleted, field.TypeBool, value) } if value, ok := _u.mutation.DeletedAt(); ok { _spec.SetField(attachment.FieldDeletedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedDeletedAt(); ok { _spec.AddField(attachment.FieldDeletedAt, field.TypeInt64, value) } if _u.mutation.DeletedAtCleared() { _spec.ClearField(attachment.FieldDeletedAt, field.TypeInt64) } if value, ok := _u.mutation.DeletedBy(); ok { _spec.SetField(attachment.FieldDeletedBy, field.TypeString, value) } if _u.mutation.DeletedByCleared() { _spec.ClearField(attachment.FieldDeletedBy, field.TypeString) } if value, ok := _u.mutation.CreatedAt(); ok { _spec.SetField(attachment.FieldCreatedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedCreatedAt(); ok { _spec.AddField(attachment.FieldCreatedAt, field.TypeInt64, value) } _node = &Attachment{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{attachment.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } _u.mutation.done = true return _node, nil }