github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/coinbase_update.go (about)

     1  // Code generated by ent, DO NOT EDIT.
     2  
     3  package ent
     4  
     5  import (
     6  	"context"
     7  	"errors"
     8  	"fmt"
     9  
    10  	"entgo.io/ent/dialect/sql"
    11  	"entgo.io/ent/dialect/sql/sqlgraph"
    12  	"entgo.io/ent/schema/field"
    13  	"github.com/NpoolPlatform/chain-middleware/pkg/db/ent/coinbase"
    14  	"github.com/NpoolPlatform/chain-middleware/pkg/db/ent/predicate"
    15  	"github.com/google/uuid"
    16  	"github.com/shopspring/decimal"
    17  )
    18  
    19  // CoinBaseUpdate is the builder for updating CoinBase entities.
    20  type CoinBaseUpdate struct {
    21  	config
    22  	hooks     []Hook
    23  	mutation  *CoinBaseMutation
    24  	modifiers []func(*sql.UpdateBuilder)
    25  }
    26  
    27  // Where appends a list predicates to the CoinBaseUpdate builder.
    28  func (cbu *CoinBaseUpdate) Where(ps ...predicate.CoinBase) *CoinBaseUpdate {
    29  	cbu.mutation.Where(ps...)
    30  	return cbu
    31  }
    32  
    33  // SetCreatedAt sets the "created_at" field.
    34  func (cbu *CoinBaseUpdate) SetCreatedAt(u uint32) *CoinBaseUpdate {
    35  	cbu.mutation.ResetCreatedAt()
    36  	cbu.mutation.SetCreatedAt(u)
    37  	return cbu
    38  }
    39  
    40  // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
    41  func (cbu *CoinBaseUpdate) SetNillableCreatedAt(u *uint32) *CoinBaseUpdate {
    42  	if u != nil {
    43  		cbu.SetCreatedAt(*u)
    44  	}
    45  	return cbu
    46  }
    47  
    48  // AddCreatedAt adds u to the "created_at" field.
    49  func (cbu *CoinBaseUpdate) AddCreatedAt(u int32) *CoinBaseUpdate {
    50  	cbu.mutation.AddCreatedAt(u)
    51  	return cbu
    52  }
    53  
    54  // SetUpdatedAt sets the "updated_at" field.
    55  func (cbu *CoinBaseUpdate) SetUpdatedAt(u uint32) *CoinBaseUpdate {
    56  	cbu.mutation.ResetUpdatedAt()
    57  	cbu.mutation.SetUpdatedAt(u)
    58  	return cbu
    59  }
    60  
    61  // AddUpdatedAt adds u to the "updated_at" field.
    62  func (cbu *CoinBaseUpdate) AddUpdatedAt(u int32) *CoinBaseUpdate {
    63  	cbu.mutation.AddUpdatedAt(u)
    64  	return cbu
    65  }
    66  
    67  // SetDeletedAt sets the "deleted_at" field.
    68  func (cbu *CoinBaseUpdate) SetDeletedAt(u uint32) *CoinBaseUpdate {
    69  	cbu.mutation.ResetDeletedAt()
    70  	cbu.mutation.SetDeletedAt(u)
    71  	return cbu
    72  }
    73  
    74  // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
    75  func (cbu *CoinBaseUpdate) SetNillableDeletedAt(u *uint32) *CoinBaseUpdate {
    76  	if u != nil {
    77  		cbu.SetDeletedAt(*u)
    78  	}
    79  	return cbu
    80  }
    81  
    82  // AddDeletedAt adds u to the "deleted_at" field.
    83  func (cbu *CoinBaseUpdate) AddDeletedAt(u int32) *CoinBaseUpdate {
    84  	cbu.mutation.AddDeletedAt(u)
    85  	return cbu
    86  }
    87  
    88  // SetEntID sets the "ent_id" field.
    89  func (cbu *CoinBaseUpdate) SetEntID(u uuid.UUID) *CoinBaseUpdate {
    90  	cbu.mutation.SetEntID(u)
    91  	return cbu
    92  }
    93  
    94  // SetNillableEntID sets the "ent_id" field if the given value is not nil.
    95  func (cbu *CoinBaseUpdate) SetNillableEntID(u *uuid.UUID) *CoinBaseUpdate {
    96  	if u != nil {
    97  		cbu.SetEntID(*u)
    98  	}
    99  	return cbu
   100  }
   101  
   102  // SetName sets the "name" field.
   103  func (cbu *CoinBaseUpdate) SetName(s string) *CoinBaseUpdate {
   104  	cbu.mutation.SetName(s)
   105  	return cbu
   106  }
   107  
   108  // SetNillableName sets the "name" field if the given value is not nil.
   109  func (cbu *CoinBaseUpdate) SetNillableName(s *string) *CoinBaseUpdate {
   110  	if s != nil {
   111  		cbu.SetName(*s)
   112  	}
   113  	return cbu
   114  }
   115  
   116  // ClearName clears the value of the "name" field.
   117  func (cbu *CoinBaseUpdate) ClearName() *CoinBaseUpdate {
   118  	cbu.mutation.ClearName()
   119  	return cbu
   120  }
   121  
   122  // SetLogo sets the "logo" field.
   123  func (cbu *CoinBaseUpdate) SetLogo(s string) *CoinBaseUpdate {
   124  	cbu.mutation.SetLogo(s)
   125  	return cbu
   126  }
   127  
   128  // SetNillableLogo sets the "logo" field if the given value is not nil.
   129  func (cbu *CoinBaseUpdate) SetNillableLogo(s *string) *CoinBaseUpdate {
   130  	if s != nil {
   131  		cbu.SetLogo(*s)
   132  	}
   133  	return cbu
   134  }
   135  
   136  // ClearLogo clears the value of the "logo" field.
   137  func (cbu *CoinBaseUpdate) ClearLogo() *CoinBaseUpdate {
   138  	cbu.mutation.ClearLogo()
   139  	return cbu
   140  }
   141  
   142  // SetPresale sets the "presale" field.
   143  func (cbu *CoinBaseUpdate) SetPresale(b bool) *CoinBaseUpdate {
   144  	cbu.mutation.SetPresale(b)
   145  	return cbu
   146  }
   147  
   148  // SetNillablePresale sets the "presale" field if the given value is not nil.
   149  func (cbu *CoinBaseUpdate) SetNillablePresale(b *bool) *CoinBaseUpdate {
   150  	if b != nil {
   151  		cbu.SetPresale(*b)
   152  	}
   153  	return cbu
   154  }
   155  
   156  // ClearPresale clears the value of the "presale" field.
   157  func (cbu *CoinBaseUpdate) ClearPresale() *CoinBaseUpdate {
   158  	cbu.mutation.ClearPresale()
   159  	return cbu
   160  }
   161  
   162  // SetUnit sets the "unit" field.
   163  func (cbu *CoinBaseUpdate) SetUnit(s string) *CoinBaseUpdate {
   164  	cbu.mutation.SetUnit(s)
   165  	return cbu
   166  }
   167  
   168  // SetNillableUnit sets the "unit" field if the given value is not nil.
   169  func (cbu *CoinBaseUpdate) SetNillableUnit(s *string) *CoinBaseUpdate {
   170  	if s != nil {
   171  		cbu.SetUnit(*s)
   172  	}
   173  	return cbu
   174  }
   175  
   176  // ClearUnit clears the value of the "unit" field.
   177  func (cbu *CoinBaseUpdate) ClearUnit() *CoinBaseUpdate {
   178  	cbu.mutation.ClearUnit()
   179  	return cbu
   180  }
   181  
   182  // SetEnv sets the "env" field.
   183  func (cbu *CoinBaseUpdate) SetEnv(s string) *CoinBaseUpdate {
   184  	cbu.mutation.SetEnv(s)
   185  	return cbu
   186  }
   187  
   188  // SetNillableEnv sets the "env" field if the given value is not nil.
   189  func (cbu *CoinBaseUpdate) SetNillableEnv(s *string) *CoinBaseUpdate {
   190  	if s != nil {
   191  		cbu.SetEnv(*s)
   192  	}
   193  	return cbu
   194  }
   195  
   196  // ClearEnv clears the value of the "env" field.
   197  func (cbu *CoinBaseUpdate) ClearEnv() *CoinBaseUpdate {
   198  	cbu.mutation.ClearEnv()
   199  	return cbu
   200  }
   201  
   202  // SetReservedAmount sets the "reserved_amount" field.
   203  func (cbu *CoinBaseUpdate) SetReservedAmount(d decimal.Decimal) *CoinBaseUpdate {
   204  	cbu.mutation.SetReservedAmount(d)
   205  	return cbu
   206  }
   207  
   208  // SetNillableReservedAmount sets the "reserved_amount" field if the given value is not nil.
   209  func (cbu *CoinBaseUpdate) SetNillableReservedAmount(d *decimal.Decimal) *CoinBaseUpdate {
   210  	if d != nil {
   211  		cbu.SetReservedAmount(*d)
   212  	}
   213  	return cbu
   214  }
   215  
   216  // ClearReservedAmount clears the value of the "reserved_amount" field.
   217  func (cbu *CoinBaseUpdate) ClearReservedAmount() *CoinBaseUpdate {
   218  	cbu.mutation.ClearReservedAmount()
   219  	return cbu
   220  }
   221  
   222  // SetForPay sets the "for_pay" field.
   223  func (cbu *CoinBaseUpdate) SetForPay(b bool) *CoinBaseUpdate {
   224  	cbu.mutation.SetForPay(b)
   225  	return cbu
   226  }
   227  
   228  // SetNillableForPay sets the "for_pay" field if the given value is not nil.
   229  func (cbu *CoinBaseUpdate) SetNillableForPay(b *bool) *CoinBaseUpdate {
   230  	if b != nil {
   231  		cbu.SetForPay(*b)
   232  	}
   233  	return cbu
   234  }
   235  
   236  // ClearForPay clears the value of the "for_pay" field.
   237  func (cbu *CoinBaseUpdate) ClearForPay() *CoinBaseUpdate {
   238  	cbu.mutation.ClearForPay()
   239  	return cbu
   240  }
   241  
   242  // SetDisabled sets the "disabled" field.
   243  func (cbu *CoinBaseUpdate) SetDisabled(b bool) *CoinBaseUpdate {
   244  	cbu.mutation.SetDisabled(b)
   245  	return cbu
   246  }
   247  
   248  // SetNillableDisabled sets the "disabled" field if the given value is not nil.
   249  func (cbu *CoinBaseUpdate) SetNillableDisabled(b *bool) *CoinBaseUpdate {
   250  	if b != nil {
   251  		cbu.SetDisabled(*b)
   252  	}
   253  	return cbu
   254  }
   255  
   256  // ClearDisabled clears the value of the "disabled" field.
   257  func (cbu *CoinBaseUpdate) ClearDisabled() *CoinBaseUpdate {
   258  	cbu.mutation.ClearDisabled()
   259  	return cbu
   260  }
   261  
   262  // Mutation returns the CoinBaseMutation object of the builder.
   263  func (cbu *CoinBaseUpdate) Mutation() *CoinBaseMutation {
   264  	return cbu.mutation
   265  }
   266  
   267  // Save executes the query and returns the number of nodes affected by the update operation.
   268  func (cbu *CoinBaseUpdate) Save(ctx context.Context) (int, error) {
   269  	var (
   270  		err      error
   271  		affected int
   272  	)
   273  	if err := cbu.defaults(); err != nil {
   274  		return 0, err
   275  	}
   276  	if len(cbu.hooks) == 0 {
   277  		affected, err = cbu.sqlSave(ctx)
   278  	} else {
   279  		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
   280  			mutation, ok := m.(*CoinBaseMutation)
   281  			if !ok {
   282  				return nil, fmt.Errorf("unexpected mutation type %T", m)
   283  			}
   284  			cbu.mutation = mutation
   285  			affected, err = cbu.sqlSave(ctx)
   286  			mutation.done = true
   287  			return affected, err
   288  		})
   289  		for i := len(cbu.hooks) - 1; i >= 0; i-- {
   290  			if cbu.hooks[i] == nil {
   291  				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
   292  			}
   293  			mut = cbu.hooks[i](mut)
   294  		}
   295  		if _, err := mut.Mutate(ctx, cbu.mutation); err != nil {
   296  			return 0, err
   297  		}
   298  	}
   299  	return affected, err
   300  }
   301  
   302  // SaveX is like Save, but panics if an error occurs.
   303  func (cbu *CoinBaseUpdate) SaveX(ctx context.Context) int {
   304  	affected, err := cbu.Save(ctx)
   305  	if err != nil {
   306  		panic(err)
   307  	}
   308  	return affected
   309  }
   310  
   311  // Exec executes the query.
   312  func (cbu *CoinBaseUpdate) Exec(ctx context.Context) error {
   313  	_, err := cbu.Save(ctx)
   314  	return err
   315  }
   316  
   317  // ExecX is like Exec, but panics if an error occurs.
   318  func (cbu *CoinBaseUpdate) ExecX(ctx context.Context) {
   319  	if err := cbu.Exec(ctx); err != nil {
   320  		panic(err)
   321  	}
   322  }
   323  
   324  // defaults sets the default values of the builder before save.
   325  func (cbu *CoinBaseUpdate) defaults() error {
   326  	if _, ok := cbu.mutation.UpdatedAt(); !ok {
   327  		if coinbase.UpdateDefaultUpdatedAt == nil {
   328  			return fmt.Errorf("ent: uninitialized coinbase.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
   329  		}
   330  		v := coinbase.UpdateDefaultUpdatedAt()
   331  		cbu.mutation.SetUpdatedAt(v)
   332  	}
   333  	return nil
   334  }
   335  
   336  // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
   337  func (cbu *CoinBaseUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CoinBaseUpdate {
   338  	cbu.modifiers = append(cbu.modifiers, modifiers...)
   339  	return cbu
   340  }
   341  
   342  func (cbu *CoinBaseUpdate) sqlSave(ctx context.Context) (n int, err error) {
   343  	_spec := &sqlgraph.UpdateSpec{
   344  		Node: &sqlgraph.NodeSpec{
   345  			Table:   coinbase.Table,
   346  			Columns: coinbase.Columns,
   347  			ID: &sqlgraph.FieldSpec{
   348  				Type:   field.TypeUint32,
   349  				Column: coinbase.FieldID,
   350  			},
   351  		},
   352  	}
   353  	if ps := cbu.mutation.predicates; len(ps) > 0 {
   354  		_spec.Predicate = func(selector *sql.Selector) {
   355  			for i := range ps {
   356  				ps[i](selector)
   357  			}
   358  		}
   359  	}
   360  	if value, ok := cbu.mutation.CreatedAt(); ok {
   361  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   362  			Type:   field.TypeUint32,
   363  			Value:  value,
   364  			Column: coinbase.FieldCreatedAt,
   365  		})
   366  	}
   367  	if value, ok := cbu.mutation.AddedCreatedAt(); ok {
   368  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   369  			Type:   field.TypeUint32,
   370  			Value:  value,
   371  			Column: coinbase.FieldCreatedAt,
   372  		})
   373  	}
   374  	if value, ok := cbu.mutation.UpdatedAt(); ok {
   375  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   376  			Type:   field.TypeUint32,
   377  			Value:  value,
   378  			Column: coinbase.FieldUpdatedAt,
   379  		})
   380  	}
   381  	if value, ok := cbu.mutation.AddedUpdatedAt(); ok {
   382  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   383  			Type:   field.TypeUint32,
   384  			Value:  value,
   385  			Column: coinbase.FieldUpdatedAt,
   386  		})
   387  	}
   388  	if value, ok := cbu.mutation.DeletedAt(); ok {
   389  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   390  			Type:   field.TypeUint32,
   391  			Value:  value,
   392  			Column: coinbase.FieldDeletedAt,
   393  		})
   394  	}
   395  	if value, ok := cbu.mutation.AddedDeletedAt(); ok {
   396  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   397  			Type:   field.TypeUint32,
   398  			Value:  value,
   399  			Column: coinbase.FieldDeletedAt,
   400  		})
   401  	}
   402  	if value, ok := cbu.mutation.EntID(); ok {
   403  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   404  			Type:   field.TypeUUID,
   405  			Value:  value,
   406  			Column: coinbase.FieldEntID,
   407  		})
   408  	}
   409  	if value, ok := cbu.mutation.Name(); ok {
   410  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   411  			Type:   field.TypeString,
   412  			Value:  value,
   413  			Column: coinbase.FieldName,
   414  		})
   415  	}
   416  	if cbu.mutation.NameCleared() {
   417  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   418  			Type:   field.TypeString,
   419  			Column: coinbase.FieldName,
   420  		})
   421  	}
   422  	if value, ok := cbu.mutation.Logo(); ok {
   423  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   424  			Type:   field.TypeString,
   425  			Value:  value,
   426  			Column: coinbase.FieldLogo,
   427  		})
   428  	}
   429  	if cbu.mutation.LogoCleared() {
   430  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   431  			Type:   field.TypeString,
   432  			Column: coinbase.FieldLogo,
   433  		})
   434  	}
   435  	if value, ok := cbu.mutation.Presale(); ok {
   436  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   437  			Type:   field.TypeBool,
   438  			Value:  value,
   439  			Column: coinbase.FieldPresale,
   440  		})
   441  	}
   442  	if cbu.mutation.PresaleCleared() {
   443  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   444  			Type:   field.TypeBool,
   445  			Column: coinbase.FieldPresale,
   446  		})
   447  	}
   448  	if value, ok := cbu.mutation.Unit(); ok {
   449  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   450  			Type:   field.TypeString,
   451  			Value:  value,
   452  			Column: coinbase.FieldUnit,
   453  		})
   454  	}
   455  	if cbu.mutation.UnitCleared() {
   456  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   457  			Type:   field.TypeString,
   458  			Column: coinbase.FieldUnit,
   459  		})
   460  	}
   461  	if value, ok := cbu.mutation.Env(); ok {
   462  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   463  			Type:   field.TypeString,
   464  			Value:  value,
   465  			Column: coinbase.FieldEnv,
   466  		})
   467  	}
   468  	if cbu.mutation.EnvCleared() {
   469  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   470  			Type:   field.TypeString,
   471  			Column: coinbase.FieldEnv,
   472  		})
   473  	}
   474  	if value, ok := cbu.mutation.ReservedAmount(); ok {
   475  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   476  			Type:   field.TypeOther,
   477  			Value:  value,
   478  			Column: coinbase.FieldReservedAmount,
   479  		})
   480  	}
   481  	if cbu.mutation.ReservedAmountCleared() {
   482  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   483  			Type:   field.TypeOther,
   484  			Column: coinbase.FieldReservedAmount,
   485  		})
   486  	}
   487  	if value, ok := cbu.mutation.ForPay(); ok {
   488  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   489  			Type:   field.TypeBool,
   490  			Value:  value,
   491  			Column: coinbase.FieldForPay,
   492  		})
   493  	}
   494  	if cbu.mutation.ForPayCleared() {
   495  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   496  			Type:   field.TypeBool,
   497  			Column: coinbase.FieldForPay,
   498  		})
   499  	}
   500  	if value, ok := cbu.mutation.Disabled(); ok {
   501  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   502  			Type:   field.TypeBool,
   503  			Value:  value,
   504  			Column: coinbase.FieldDisabled,
   505  		})
   506  	}
   507  	if cbu.mutation.DisabledCleared() {
   508  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   509  			Type:   field.TypeBool,
   510  			Column: coinbase.FieldDisabled,
   511  		})
   512  	}
   513  	_spec.Modifiers = cbu.modifiers
   514  	if n, err = sqlgraph.UpdateNodes(ctx, cbu.driver, _spec); err != nil {
   515  		if _, ok := err.(*sqlgraph.NotFoundError); ok {
   516  			err = &NotFoundError{coinbase.Label}
   517  		} else if sqlgraph.IsConstraintError(err) {
   518  			err = &ConstraintError{msg: err.Error(), wrap: err}
   519  		}
   520  		return 0, err
   521  	}
   522  	return n, nil
   523  }
   524  
   525  // CoinBaseUpdateOne is the builder for updating a single CoinBase entity.
   526  type CoinBaseUpdateOne struct {
   527  	config
   528  	fields    []string
   529  	hooks     []Hook
   530  	mutation  *CoinBaseMutation
   531  	modifiers []func(*sql.UpdateBuilder)
   532  }
   533  
   534  // SetCreatedAt sets the "created_at" field.
   535  func (cbuo *CoinBaseUpdateOne) SetCreatedAt(u uint32) *CoinBaseUpdateOne {
   536  	cbuo.mutation.ResetCreatedAt()
   537  	cbuo.mutation.SetCreatedAt(u)
   538  	return cbuo
   539  }
   540  
   541  // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
   542  func (cbuo *CoinBaseUpdateOne) SetNillableCreatedAt(u *uint32) *CoinBaseUpdateOne {
   543  	if u != nil {
   544  		cbuo.SetCreatedAt(*u)
   545  	}
   546  	return cbuo
   547  }
   548  
   549  // AddCreatedAt adds u to the "created_at" field.
   550  func (cbuo *CoinBaseUpdateOne) AddCreatedAt(u int32) *CoinBaseUpdateOne {
   551  	cbuo.mutation.AddCreatedAt(u)
   552  	return cbuo
   553  }
   554  
   555  // SetUpdatedAt sets the "updated_at" field.
   556  func (cbuo *CoinBaseUpdateOne) SetUpdatedAt(u uint32) *CoinBaseUpdateOne {
   557  	cbuo.mutation.ResetUpdatedAt()
   558  	cbuo.mutation.SetUpdatedAt(u)
   559  	return cbuo
   560  }
   561  
   562  // AddUpdatedAt adds u to the "updated_at" field.
   563  func (cbuo *CoinBaseUpdateOne) AddUpdatedAt(u int32) *CoinBaseUpdateOne {
   564  	cbuo.mutation.AddUpdatedAt(u)
   565  	return cbuo
   566  }
   567  
   568  // SetDeletedAt sets the "deleted_at" field.
   569  func (cbuo *CoinBaseUpdateOne) SetDeletedAt(u uint32) *CoinBaseUpdateOne {
   570  	cbuo.mutation.ResetDeletedAt()
   571  	cbuo.mutation.SetDeletedAt(u)
   572  	return cbuo
   573  }
   574  
   575  // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
   576  func (cbuo *CoinBaseUpdateOne) SetNillableDeletedAt(u *uint32) *CoinBaseUpdateOne {
   577  	if u != nil {
   578  		cbuo.SetDeletedAt(*u)
   579  	}
   580  	return cbuo
   581  }
   582  
   583  // AddDeletedAt adds u to the "deleted_at" field.
   584  func (cbuo *CoinBaseUpdateOne) AddDeletedAt(u int32) *CoinBaseUpdateOne {
   585  	cbuo.mutation.AddDeletedAt(u)
   586  	return cbuo
   587  }
   588  
   589  // SetEntID sets the "ent_id" field.
   590  func (cbuo *CoinBaseUpdateOne) SetEntID(u uuid.UUID) *CoinBaseUpdateOne {
   591  	cbuo.mutation.SetEntID(u)
   592  	return cbuo
   593  }
   594  
   595  // SetNillableEntID sets the "ent_id" field if the given value is not nil.
   596  func (cbuo *CoinBaseUpdateOne) SetNillableEntID(u *uuid.UUID) *CoinBaseUpdateOne {
   597  	if u != nil {
   598  		cbuo.SetEntID(*u)
   599  	}
   600  	return cbuo
   601  }
   602  
   603  // SetName sets the "name" field.
   604  func (cbuo *CoinBaseUpdateOne) SetName(s string) *CoinBaseUpdateOne {
   605  	cbuo.mutation.SetName(s)
   606  	return cbuo
   607  }
   608  
   609  // SetNillableName sets the "name" field if the given value is not nil.
   610  func (cbuo *CoinBaseUpdateOne) SetNillableName(s *string) *CoinBaseUpdateOne {
   611  	if s != nil {
   612  		cbuo.SetName(*s)
   613  	}
   614  	return cbuo
   615  }
   616  
   617  // ClearName clears the value of the "name" field.
   618  func (cbuo *CoinBaseUpdateOne) ClearName() *CoinBaseUpdateOne {
   619  	cbuo.mutation.ClearName()
   620  	return cbuo
   621  }
   622  
   623  // SetLogo sets the "logo" field.
   624  func (cbuo *CoinBaseUpdateOne) SetLogo(s string) *CoinBaseUpdateOne {
   625  	cbuo.mutation.SetLogo(s)
   626  	return cbuo
   627  }
   628  
   629  // SetNillableLogo sets the "logo" field if the given value is not nil.
   630  func (cbuo *CoinBaseUpdateOne) SetNillableLogo(s *string) *CoinBaseUpdateOne {
   631  	if s != nil {
   632  		cbuo.SetLogo(*s)
   633  	}
   634  	return cbuo
   635  }
   636  
   637  // ClearLogo clears the value of the "logo" field.
   638  func (cbuo *CoinBaseUpdateOne) ClearLogo() *CoinBaseUpdateOne {
   639  	cbuo.mutation.ClearLogo()
   640  	return cbuo
   641  }
   642  
   643  // SetPresale sets the "presale" field.
   644  func (cbuo *CoinBaseUpdateOne) SetPresale(b bool) *CoinBaseUpdateOne {
   645  	cbuo.mutation.SetPresale(b)
   646  	return cbuo
   647  }
   648  
   649  // SetNillablePresale sets the "presale" field if the given value is not nil.
   650  func (cbuo *CoinBaseUpdateOne) SetNillablePresale(b *bool) *CoinBaseUpdateOne {
   651  	if b != nil {
   652  		cbuo.SetPresale(*b)
   653  	}
   654  	return cbuo
   655  }
   656  
   657  // ClearPresale clears the value of the "presale" field.
   658  func (cbuo *CoinBaseUpdateOne) ClearPresale() *CoinBaseUpdateOne {
   659  	cbuo.mutation.ClearPresale()
   660  	return cbuo
   661  }
   662  
   663  // SetUnit sets the "unit" field.
   664  func (cbuo *CoinBaseUpdateOne) SetUnit(s string) *CoinBaseUpdateOne {
   665  	cbuo.mutation.SetUnit(s)
   666  	return cbuo
   667  }
   668  
   669  // SetNillableUnit sets the "unit" field if the given value is not nil.
   670  func (cbuo *CoinBaseUpdateOne) SetNillableUnit(s *string) *CoinBaseUpdateOne {
   671  	if s != nil {
   672  		cbuo.SetUnit(*s)
   673  	}
   674  	return cbuo
   675  }
   676  
   677  // ClearUnit clears the value of the "unit" field.
   678  func (cbuo *CoinBaseUpdateOne) ClearUnit() *CoinBaseUpdateOne {
   679  	cbuo.mutation.ClearUnit()
   680  	return cbuo
   681  }
   682  
   683  // SetEnv sets the "env" field.
   684  func (cbuo *CoinBaseUpdateOne) SetEnv(s string) *CoinBaseUpdateOne {
   685  	cbuo.mutation.SetEnv(s)
   686  	return cbuo
   687  }
   688  
   689  // SetNillableEnv sets the "env" field if the given value is not nil.
   690  func (cbuo *CoinBaseUpdateOne) SetNillableEnv(s *string) *CoinBaseUpdateOne {
   691  	if s != nil {
   692  		cbuo.SetEnv(*s)
   693  	}
   694  	return cbuo
   695  }
   696  
   697  // ClearEnv clears the value of the "env" field.
   698  func (cbuo *CoinBaseUpdateOne) ClearEnv() *CoinBaseUpdateOne {
   699  	cbuo.mutation.ClearEnv()
   700  	return cbuo
   701  }
   702  
   703  // SetReservedAmount sets the "reserved_amount" field.
   704  func (cbuo *CoinBaseUpdateOne) SetReservedAmount(d decimal.Decimal) *CoinBaseUpdateOne {
   705  	cbuo.mutation.SetReservedAmount(d)
   706  	return cbuo
   707  }
   708  
   709  // SetNillableReservedAmount sets the "reserved_amount" field if the given value is not nil.
   710  func (cbuo *CoinBaseUpdateOne) SetNillableReservedAmount(d *decimal.Decimal) *CoinBaseUpdateOne {
   711  	if d != nil {
   712  		cbuo.SetReservedAmount(*d)
   713  	}
   714  	return cbuo
   715  }
   716  
   717  // ClearReservedAmount clears the value of the "reserved_amount" field.
   718  func (cbuo *CoinBaseUpdateOne) ClearReservedAmount() *CoinBaseUpdateOne {
   719  	cbuo.mutation.ClearReservedAmount()
   720  	return cbuo
   721  }
   722  
   723  // SetForPay sets the "for_pay" field.
   724  func (cbuo *CoinBaseUpdateOne) SetForPay(b bool) *CoinBaseUpdateOne {
   725  	cbuo.mutation.SetForPay(b)
   726  	return cbuo
   727  }
   728  
   729  // SetNillableForPay sets the "for_pay" field if the given value is not nil.
   730  func (cbuo *CoinBaseUpdateOne) SetNillableForPay(b *bool) *CoinBaseUpdateOne {
   731  	if b != nil {
   732  		cbuo.SetForPay(*b)
   733  	}
   734  	return cbuo
   735  }
   736  
   737  // ClearForPay clears the value of the "for_pay" field.
   738  func (cbuo *CoinBaseUpdateOne) ClearForPay() *CoinBaseUpdateOne {
   739  	cbuo.mutation.ClearForPay()
   740  	return cbuo
   741  }
   742  
   743  // SetDisabled sets the "disabled" field.
   744  func (cbuo *CoinBaseUpdateOne) SetDisabled(b bool) *CoinBaseUpdateOne {
   745  	cbuo.mutation.SetDisabled(b)
   746  	return cbuo
   747  }
   748  
   749  // SetNillableDisabled sets the "disabled" field if the given value is not nil.
   750  func (cbuo *CoinBaseUpdateOne) SetNillableDisabled(b *bool) *CoinBaseUpdateOne {
   751  	if b != nil {
   752  		cbuo.SetDisabled(*b)
   753  	}
   754  	return cbuo
   755  }
   756  
   757  // ClearDisabled clears the value of the "disabled" field.
   758  func (cbuo *CoinBaseUpdateOne) ClearDisabled() *CoinBaseUpdateOne {
   759  	cbuo.mutation.ClearDisabled()
   760  	return cbuo
   761  }
   762  
   763  // Mutation returns the CoinBaseMutation object of the builder.
   764  func (cbuo *CoinBaseUpdateOne) Mutation() *CoinBaseMutation {
   765  	return cbuo.mutation
   766  }
   767  
   768  // Select allows selecting one or more fields (columns) of the returned entity.
   769  // The default is selecting all fields defined in the entity schema.
   770  func (cbuo *CoinBaseUpdateOne) Select(field string, fields ...string) *CoinBaseUpdateOne {
   771  	cbuo.fields = append([]string{field}, fields...)
   772  	return cbuo
   773  }
   774  
   775  // Save executes the query and returns the updated CoinBase entity.
   776  func (cbuo *CoinBaseUpdateOne) Save(ctx context.Context) (*CoinBase, error) {
   777  	var (
   778  		err  error
   779  		node *CoinBase
   780  	)
   781  	if err := cbuo.defaults(); err != nil {
   782  		return nil, err
   783  	}
   784  	if len(cbuo.hooks) == 0 {
   785  		node, err = cbuo.sqlSave(ctx)
   786  	} else {
   787  		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
   788  			mutation, ok := m.(*CoinBaseMutation)
   789  			if !ok {
   790  				return nil, fmt.Errorf("unexpected mutation type %T", m)
   791  			}
   792  			cbuo.mutation = mutation
   793  			node, err = cbuo.sqlSave(ctx)
   794  			mutation.done = true
   795  			return node, err
   796  		})
   797  		for i := len(cbuo.hooks) - 1; i >= 0; i-- {
   798  			if cbuo.hooks[i] == nil {
   799  				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
   800  			}
   801  			mut = cbuo.hooks[i](mut)
   802  		}
   803  		v, err := mut.Mutate(ctx, cbuo.mutation)
   804  		if err != nil {
   805  			return nil, err
   806  		}
   807  		nv, ok := v.(*CoinBase)
   808  		if !ok {
   809  			return nil, fmt.Errorf("unexpected node type %T returned from CoinBaseMutation", v)
   810  		}
   811  		node = nv
   812  	}
   813  	return node, err
   814  }
   815  
   816  // SaveX is like Save, but panics if an error occurs.
   817  func (cbuo *CoinBaseUpdateOne) SaveX(ctx context.Context) *CoinBase {
   818  	node, err := cbuo.Save(ctx)
   819  	if err != nil {
   820  		panic(err)
   821  	}
   822  	return node
   823  }
   824  
   825  // Exec executes the query on the entity.
   826  func (cbuo *CoinBaseUpdateOne) Exec(ctx context.Context) error {
   827  	_, err := cbuo.Save(ctx)
   828  	return err
   829  }
   830  
   831  // ExecX is like Exec, but panics if an error occurs.
   832  func (cbuo *CoinBaseUpdateOne) ExecX(ctx context.Context) {
   833  	if err := cbuo.Exec(ctx); err != nil {
   834  		panic(err)
   835  	}
   836  }
   837  
   838  // defaults sets the default values of the builder before save.
   839  func (cbuo *CoinBaseUpdateOne) defaults() error {
   840  	if _, ok := cbuo.mutation.UpdatedAt(); !ok {
   841  		if coinbase.UpdateDefaultUpdatedAt == nil {
   842  			return fmt.Errorf("ent: uninitialized coinbase.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
   843  		}
   844  		v := coinbase.UpdateDefaultUpdatedAt()
   845  		cbuo.mutation.SetUpdatedAt(v)
   846  	}
   847  	return nil
   848  }
   849  
   850  // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
   851  func (cbuo *CoinBaseUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CoinBaseUpdateOne {
   852  	cbuo.modifiers = append(cbuo.modifiers, modifiers...)
   853  	return cbuo
   854  }
   855  
   856  func (cbuo *CoinBaseUpdateOne) sqlSave(ctx context.Context) (_node *CoinBase, err error) {
   857  	_spec := &sqlgraph.UpdateSpec{
   858  		Node: &sqlgraph.NodeSpec{
   859  			Table:   coinbase.Table,
   860  			Columns: coinbase.Columns,
   861  			ID: &sqlgraph.FieldSpec{
   862  				Type:   field.TypeUint32,
   863  				Column: coinbase.FieldID,
   864  			},
   865  		},
   866  	}
   867  	id, ok := cbuo.mutation.ID()
   868  	if !ok {
   869  		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CoinBase.id" for update`)}
   870  	}
   871  	_spec.Node.ID.Value = id
   872  	if fields := cbuo.fields; len(fields) > 0 {
   873  		_spec.Node.Columns = make([]string, 0, len(fields))
   874  		_spec.Node.Columns = append(_spec.Node.Columns, coinbase.FieldID)
   875  		for _, f := range fields {
   876  			if !coinbase.ValidColumn(f) {
   877  				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
   878  			}
   879  			if f != coinbase.FieldID {
   880  				_spec.Node.Columns = append(_spec.Node.Columns, f)
   881  			}
   882  		}
   883  	}
   884  	if ps := cbuo.mutation.predicates; len(ps) > 0 {
   885  		_spec.Predicate = func(selector *sql.Selector) {
   886  			for i := range ps {
   887  				ps[i](selector)
   888  			}
   889  		}
   890  	}
   891  	if value, ok := cbuo.mutation.CreatedAt(); ok {
   892  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   893  			Type:   field.TypeUint32,
   894  			Value:  value,
   895  			Column: coinbase.FieldCreatedAt,
   896  		})
   897  	}
   898  	if value, ok := cbuo.mutation.AddedCreatedAt(); ok {
   899  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   900  			Type:   field.TypeUint32,
   901  			Value:  value,
   902  			Column: coinbase.FieldCreatedAt,
   903  		})
   904  	}
   905  	if value, ok := cbuo.mutation.UpdatedAt(); ok {
   906  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   907  			Type:   field.TypeUint32,
   908  			Value:  value,
   909  			Column: coinbase.FieldUpdatedAt,
   910  		})
   911  	}
   912  	if value, ok := cbuo.mutation.AddedUpdatedAt(); ok {
   913  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   914  			Type:   field.TypeUint32,
   915  			Value:  value,
   916  			Column: coinbase.FieldUpdatedAt,
   917  		})
   918  	}
   919  	if value, ok := cbuo.mutation.DeletedAt(); ok {
   920  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   921  			Type:   field.TypeUint32,
   922  			Value:  value,
   923  			Column: coinbase.FieldDeletedAt,
   924  		})
   925  	}
   926  	if value, ok := cbuo.mutation.AddedDeletedAt(); ok {
   927  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   928  			Type:   field.TypeUint32,
   929  			Value:  value,
   930  			Column: coinbase.FieldDeletedAt,
   931  		})
   932  	}
   933  	if value, ok := cbuo.mutation.EntID(); ok {
   934  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   935  			Type:   field.TypeUUID,
   936  			Value:  value,
   937  			Column: coinbase.FieldEntID,
   938  		})
   939  	}
   940  	if value, ok := cbuo.mutation.Name(); ok {
   941  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   942  			Type:   field.TypeString,
   943  			Value:  value,
   944  			Column: coinbase.FieldName,
   945  		})
   946  	}
   947  	if cbuo.mutation.NameCleared() {
   948  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   949  			Type:   field.TypeString,
   950  			Column: coinbase.FieldName,
   951  		})
   952  	}
   953  	if value, ok := cbuo.mutation.Logo(); ok {
   954  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   955  			Type:   field.TypeString,
   956  			Value:  value,
   957  			Column: coinbase.FieldLogo,
   958  		})
   959  	}
   960  	if cbuo.mutation.LogoCleared() {
   961  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   962  			Type:   field.TypeString,
   963  			Column: coinbase.FieldLogo,
   964  		})
   965  	}
   966  	if value, ok := cbuo.mutation.Presale(); ok {
   967  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   968  			Type:   field.TypeBool,
   969  			Value:  value,
   970  			Column: coinbase.FieldPresale,
   971  		})
   972  	}
   973  	if cbuo.mutation.PresaleCleared() {
   974  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   975  			Type:   field.TypeBool,
   976  			Column: coinbase.FieldPresale,
   977  		})
   978  	}
   979  	if value, ok := cbuo.mutation.Unit(); ok {
   980  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   981  			Type:   field.TypeString,
   982  			Value:  value,
   983  			Column: coinbase.FieldUnit,
   984  		})
   985  	}
   986  	if cbuo.mutation.UnitCleared() {
   987  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   988  			Type:   field.TypeString,
   989  			Column: coinbase.FieldUnit,
   990  		})
   991  	}
   992  	if value, ok := cbuo.mutation.Env(); ok {
   993  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   994  			Type:   field.TypeString,
   995  			Value:  value,
   996  			Column: coinbase.FieldEnv,
   997  		})
   998  	}
   999  	if cbuo.mutation.EnvCleared() {
  1000  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
  1001  			Type:   field.TypeString,
  1002  			Column: coinbase.FieldEnv,
  1003  		})
  1004  	}
  1005  	if value, ok := cbuo.mutation.ReservedAmount(); ok {
  1006  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
  1007  			Type:   field.TypeOther,
  1008  			Value:  value,
  1009  			Column: coinbase.FieldReservedAmount,
  1010  		})
  1011  	}
  1012  	if cbuo.mutation.ReservedAmountCleared() {
  1013  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
  1014  			Type:   field.TypeOther,
  1015  			Column: coinbase.FieldReservedAmount,
  1016  		})
  1017  	}
  1018  	if value, ok := cbuo.mutation.ForPay(); ok {
  1019  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
  1020  			Type:   field.TypeBool,
  1021  			Value:  value,
  1022  			Column: coinbase.FieldForPay,
  1023  		})
  1024  	}
  1025  	if cbuo.mutation.ForPayCleared() {
  1026  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
  1027  			Type:   field.TypeBool,
  1028  			Column: coinbase.FieldForPay,
  1029  		})
  1030  	}
  1031  	if value, ok := cbuo.mutation.Disabled(); ok {
  1032  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
  1033  			Type:   field.TypeBool,
  1034  			Value:  value,
  1035  			Column: coinbase.FieldDisabled,
  1036  		})
  1037  	}
  1038  	if cbuo.mutation.DisabledCleared() {
  1039  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
  1040  			Type:   field.TypeBool,
  1041  			Column: coinbase.FieldDisabled,
  1042  		})
  1043  	}
  1044  	_spec.Modifiers = cbuo.modifiers
  1045  	_node = &CoinBase{config: cbuo.config}
  1046  	_spec.Assign = _node.assignValues
  1047  	_spec.ScanValues = _node.scanValues
  1048  	if err = sqlgraph.UpdateNode(ctx, cbuo.driver, _spec); err != nil {
  1049  		if _, ok := err.(*sqlgraph.NotFoundError); ok {
  1050  			err = &NotFoundError{coinbase.Label}
  1051  		} else if sqlgraph.IsConstraintError(err) {
  1052  			err = &ConstraintError{msg: err.Error(), wrap: err}
  1053  		}
  1054  		return nil, err
  1055  	}
  1056  	return _node, nil
  1057  }