github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/coinfiatcurrency_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/coinfiatcurrency"
    14  	"github.com/NpoolPlatform/chain-middleware/pkg/db/ent/predicate"
    15  	"github.com/google/uuid"
    16  	"github.com/shopspring/decimal"
    17  )
    18  
    19  // CoinFiatCurrencyUpdate is the builder for updating CoinFiatCurrency entities.
    20  type CoinFiatCurrencyUpdate struct {
    21  	config
    22  	hooks     []Hook
    23  	mutation  *CoinFiatCurrencyMutation
    24  	modifiers []func(*sql.UpdateBuilder)
    25  }
    26  
    27  // Where appends a list predicates to the CoinFiatCurrencyUpdate builder.
    28  func (cfcu *CoinFiatCurrencyUpdate) Where(ps ...predicate.CoinFiatCurrency) *CoinFiatCurrencyUpdate {
    29  	cfcu.mutation.Where(ps...)
    30  	return cfcu
    31  }
    32  
    33  // SetCreatedAt sets the "created_at" field.
    34  func (cfcu *CoinFiatCurrencyUpdate) SetCreatedAt(u uint32) *CoinFiatCurrencyUpdate {
    35  	cfcu.mutation.ResetCreatedAt()
    36  	cfcu.mutation.SetCreatedAt(u)
    37  	return cfcu
    38  }
    39  
    40  // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
    41  func (cfcu *CoinFiatCurrencyUpdate) SetNillableCreatedAt(u *uint32) *CoinFiatCurrencyUpdate {
    42  	if u != nil {
    43  		cfcu.SetCreatedAt(*u)
    44  	}
    45  	return cfcu
    46  }
    47  
    48  // AddCreatedAt adds u to the "created_at" field.
    49  func (cfcu *CoinFiatCurrencyUpdate) AddCreatedAt(u int32) *CoinFiatCurrencyUpdate {
    50  	cfcu.mutation.AddCreatedAt(u)
    51  	return cfcu
    52  }
    53  
    54  // SetUpdatedAt sets the "updated_at" field.
    55  func (cfcu *CoinFiatCurrencyUpdate) SetUpdatedAt(u uint32) *CoinFiatCurrencyUpdate {
    56  	cfcu.mutation.ResetUpdatedAt()
    57  	cfcu.mutation.SetUpdatedAt(u)
    58  	return cfcu
    59  }
    60  
    61  // AddUpdatedAt adds u to the "updated_at" field.
    62  func (cfcu *CoinFiatCurrencyUpdate) AddUpdatedAt(u int32) *CoinFiatCurrencyUpdate {
    63  	cfcu.mutation.AddUpdatedAt(u)
    64  	return cfcu
    65  }
    66  
    67  // SetDeletedAt sets the "deleted_at" field.
    68  func (cfcu *CoinFiatCurrencyUpdate) SetDeletedAt(u uint32) *CoinFiatCurrencyUpdate {
    69  	cfcu.mutation.ResetDeletedAt()
    70  	cfcu.mutation.SetDeletedAt(u)
    71  	return cfcu
    72  }
    73  
    74  // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
    75  func (cfcu *CoinFiatCurrencyUpdate) SetNillableDeletedAt(u *uint32) *CoinFiatCurrencyUpdate {
    76  	if u != nil {
    77  		cfcu.SetDeletedAt(*u)
    78  	}
    79  	return cfcu
    80  }
    81  
    82  // AddDeletedAt adds u to the "deleted_at" field.
    83  func (cfcu *CoinFiatCurrencyUpdate) AddDeletedAt(u int32) *CoinFiatCurrencyUpdate {
    84  	cfcu.mutation.AddDeletedAt(u)
    85  	return cfcu
    86  }
    87  
    88  // SetEntID sets the "ent_id" field.
    89  func (cfcu *CoinFiatCurrencyUpdate) SetEntID(u uuid.UUID) *CoinFiatCurrencyUpdate {
    90  	cfcu.mutation.SetEntID(u)
    91  	return cfcu
    92  }
    93  
    94  // SetNillableEntID sets the "ent_id" field if the given value is not nil.
    95  func (cfcu *CoinFiatCurrencyUpdate) SetNillableEntID(u *uuid.UUID) *CoinFiatCurrencyUpdate {
    96  	if u != nil {
    97  		cfcu.SetEntID(*u)
    98  	}
    99  	return cfcu
   100  }
   101  
   102  // SetCoinTypeID sets the "coin_type_id" field.
   103  func (cfcu *CoinFiatCurrencyUpdate) SetCoinTypeID(u uuid.UUID) *CoinFiatCurrencyUpdate {
   104  	cfcu.mutation.SetCoinTypeID(u)
   105  	return cfcu
   106  }
   107  
   108  // SetNillableCoinTypeID sets the "coin_type_id" field if the given value is not nil.
   109  func (cfcu *CoinFiatCurrencyUpdate) SetNillableCoinTypeID(u *uuid.UUID) *CoinFiatCurrencyUpdate {
   110  	if u != nil {
   111  		cfcu.SetCoinTypeID(*u)
   112  	}
   113  	return cfcu
   114  }
   115  
   116  // ClearCoinTypeID clears the value of the "coin_type_id" field.
   117  func (cfcu *CoinFiatCurrencyUpdate) ClearCoinTypeID() *CoinFiatCurrencyUpdate {
   118  	cfcu.mutation.ClearCoinTypeID()
   119  	return cfcu
   120  }
   121  
   122  // SetFiatID sets the "fiat_id" field.
   123  func (cfcu *CoinFiatCurrencyUpdate) SetFiatID(u uuid.UUID) *CoinFiatCurrencyUpdate {
   124  	cfcu.mutation.SetFiatID(u)
   125  	return cfcu
   126  }
   127  
   128  // SetNillableFiatID sets the "fiat_id" field if the given value is not nil.
   129  func (cfcu *CoinFiatCurrencyUpdate) SetNillableFiatID(u *uuid.UUID) *CoinFiatCurrencyUpdate {
   130  	if u != nil {
   131  		cfcu.SetFiatID(*u)
   132  	}
   133  	return cfcu
   134  }
   135  
   136  // ClearFiatID clears the value of the "fiat_id" field.
   137  func (cfcu *CoinFiatCurrencyUpdate) ClearFiatID() *CoinFiatCurrencyUpdate {
   138  	cfcu.mutation.ClearFiatID()
   139  	return cfcu
   140  }
   141  
   142  // SetFeedType sets the "feed_type" field.
   143  func (cfcu *CoinFiatCurrencyUpdate) SetFeedType(s string) *CoinFiatCurrencyUpdate {
   144  	cfcu.mutation.SetFeedType(s)
   145  	return cfcu
   146  }
   147  
   148  // SetNillableFeedType sets the "feed_type" field if the given value is not nil.
   149  func (cfcu *CoinFiatCurrencyUpdate) SetNillableFeedType(s *string) *CoinFiatCurrencyUpdate {
   150  	if s != nil {
   151  		cfcu.SetFeedType(*s)
   152  	}
   153  	return cfcu
   154  }
   155  
   156  // ClearFeedType clears the value of the "feed_type" field.
   157  func (cfcu *CoinFiatCurrencyUpdate) ClearFeedType() *CoinFiatCurrencyUpdate {
   158  	cfcu.mutation.ClearFeedType()
   159  	return cfcu
   160  }
   161  
   162  // SetMarketValueLow sets the "market_value_low" field.
   163  func (cfcu *CoinFiatCurrencyUpdate) SetMarketValueLow(d decimal.Decimal) *CoinFiatCurrencyUpdate {
   164  	cfcu.mutation.SetMarketValueLow(d)
   165  	return cfcu
   166  }
   167  
   168  // SetNillableMarketValueLow sets the "market_value_low" field if the given value is not nil.
   169  func (cfcu *CoinFiatCurrencyUpdate) SetNillableMarketValueLow(d *decimal.Decimal) *CoinFiatCurrencyUpdate {
   170  	if d != nil {
   171  		cfcu.SetMarketValueLow(*d)
   172  	}
   173  	return cfcu
   174  }
   175  
   176  // ClearMarketValueLow clears the value of the "market_value_low" field.
   177  func (cfcu *CoinFiatCurrencyUpdate) ClearMarketValueLow() *CoinFiatCurrencyUpdate {
   178  	cfcu.mutation.ClearMarketValueLow()
   179  	return cfcu
   180  }
   181  
   182  // SetMarketValueHigh sets the "market_value_high" field.
   183  func (cfcu *CoinFiatCurrencyUpdate) SetMarketValueHigh(d decimal.Decimal) *CoinFiatCurrencyUpdate {
   184  	cfcu.mutation.SetMarketValueHigh(d)
   185  	return cfcu
   186  }
   187  
   188  // SetNillableMarketValueHigh sets the "market_value_high" field if the given value is not nil.
   189  func (cfcu *CoinFiatCurrencyUpdate) SetNillableMarketValueHigh(d *decimal.Decimal) *CoinFiatCurrencyUpdate {
   190  	if d != nil {
   191  		cfcu.SetMarketValueHigh(*d)
   192  	}
   193  	return cfcu
   194  }
   195  
   196  // ClearMarketValueHigh clears the value of the "market_value_high" field.
   197  func (cfcu *CoinFiatCurrencyUpdate) ClearMarketValueHigh() *CoinFiatCurrencyUpdate {
   198  	cfcu.mutation.ClearMarketValueHigh()
   199  	return cfcu
   200  }
   201  
   202  // Mutation returns the CoinFiatCurrencyMutation object of the builder.
   203  func (cfcu *CoinFiatCurrencyUpdate) Mutation() *CoinFiatCurrencyMutation {
   204  	return cfcu.mutation
   205  }
   206  
   207  // Save executes the query and returns the number of nodes affected by the update operation.
   208  func (cfcu *CoinFiatCurrencyUpdate) Save(ctx context.Context) (int, error) {
   209  	var (
   210  		err      error
   211  		affected int
   212  	)
   213  	if err := cfcu.defaults(); err != nil {
   214  		return 0, err
   215  	}
   216  	if len(cfcu.hooks) == 0 {
   217  		affected, err = cfcu.sqlSave(ctx)
   218  	} else {
   219  		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
   220  			mutation, ok := m.(*CoinFiatCurrencyMutation)
   221  			if !ok {
   222  				return nil, fmt.Errorf("unexpected mutation type %T", m)
   223  			}
   224  			cfcu.mutation = mutation
   225  			affected, err = cfcu.sqlSave(ctx)
   226  			mutation.done = true
   227  			return affected, err
   228  		})
   229  		for i := len(cfcu.hooks) - 1; i >= 0; i-- {
   230  			if cfcu.hooks[i] == nil {
   231  				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
   232  			}
   233  			mut = cfcu.hooks[i](mut)
   234  		}
   235  		if _, err := mut.Mutate(ctx, cfcu.mutation); err != nil {
   236  			return 0, err
   237  		}
   238  	}
   239  	return affected, err
   240  }
   241  
   242  // SaveX is like Save, but panics if an error occurs.
   243  func (cfcu *CoinFiatCurrencyUpdate) SaveX(ctx context.Context) int {
   244  	affected, err := cfcu.Save(ctx)
   245  	if err != nil {
   246  		panic(err)
   247  	}
   248  	return affected
   249  }
   250  
   251  // Exec executes the query.
   252  func (cfcu *CoinFiatCurrencyUpdate) Exec(ctx context.Context) error {
   253  	_, err := cfcu.Save(ctx)
   254  	return err
   255  }
   256  
   257  // ExecX is like Exec, but panics if an error occurs.
   258  func (cfcu *CoinFiatCurrencyUpdate) ExecX(ctx context.Context) {
   259  	if err := cfcu.Exec(ctx); err != nil {
   260  		panic(err)
   261  	}
   262  }
   263  
   264  // defaults sets the default values of the builder before save.
   265  func (cfcu *CoinFiatCurrencyUpdate) defaults() error {
   266  	if _, ok := cfcu.mutation.UpdatedAt(); !ok {
   267  		if coinfiatcurrency.UpdateDefaultUpdatedAt == nil {
   268  			return fmt.Errorf("ent: uninitialized coinfiatcurrency.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
   269  		}
   270  		v := coinfiatcurrency.UpdateDefaultUpdatedAt()
   271  		cfcu.mutation.SetUpdatedAt(v)
   272  	}
   273  	return nil
   274  }
   275  
   276  // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
   277  func (cfcu *CoinFiatCurrencyUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CoinFiatCurrencyUpdate {
   278  	cfcu.modifiers = append(cfcu.modifiers, modifiers...)
   279  	return cfcu
   280  }
   281  
   282  func (cfcu *CoinFiatCurrencyUpdate) sqlSave(ctx context.Context) (n int, err error) {
   283  	_spec := &sqlgraph.UpdateSpec{
   284  		Node: &sqlgraph.NodeSpec{
   285  			Table:   coinfiatcurrency.Table,
   286  			Columns: coinfiatcurrency.Columns,
   287  			ID: &sqlgraph.FieldSpec{
   288  				Type:   field.TypeUint32,
   289  				Column: coinfiatcurrency.FieldID,
   290  			},
   291  		},
   292  	}
   293  	if ps := cfcu.mutation.predicates; len(ps) > 0 {
   294  		_spec.Predicate = func(selector *sql.Selector) {
   295  			for i := range ps {
   296  				ps[i](selector)
   297  			}
   298  		}
   299  	}
   300  	if value, ok := cfcu.mutation.CreatedAt(); ok {
   301  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   302  			Type:   field.TypeUint32,
   303  			Value:  value,
   304  			Column: coinfiatcurrency.FieldCreatedAt,
   305  		})
   306  	}
   307  	if value, ok := cfcu.mutation.AddedCreatedAt(); ok {
   308  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   309  			Type:   field.TypeUint32,
   310  			Value:  value,
   311  			Column: coinfiatcurrency.FieldCreatedAt,
   312  		})
   313  	}
   314  	if value, ok := cfcu.mutation.UpdatedAt(); ok {
   315  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   316  			Type:   field.TypeUint32,
   317  			Value:  value,
   318  			Column: coinfiatcurrency.FieldUpdatedAt,
   319  		})
   320  	}
   321  	if value, ok := cfcu.mutation.AddedUpdatedAt(); ok {
   322  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   323  			Type:   field.TypeUint32,
   324  			Value:  value,
   325  			Column: coinfiatcurrency.FieldUpdatedAt,
   326  		})
   327  	}
   328  	if value, ok := cfcu.mutation.DeletedAt(); ok {
   329  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   330  			Type:   field.TypeUint32,
   331  			Value:  value,
   332  			Column: coinfiatcurrency.FieldDeletedAt,
   333  		})
   334  	}
   335  	if value, ok := cfcu.mutation.AddedDeletedAt(); ok {
   336  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   337  			Type:   field.TypeUint32,
   338  			Value:  value,
   339  			Column: coinfiatcurrency.FieldDeletedAt,
   340  		})
   341  	}
   342  	if value, ok := cfcu.mutation.EntID(); ok {
   343  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   344  			Type:   field.TypeUUID,
   345  			Value:  value,
   346  			Column: coinfiatcurrency.FieldEntID,
   347  		})
   348  	}
   349  	if value, ok := cfcu.mutation.CoinTypeID(); ok {
   350  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   351  			Type:   field.TypeUUID,
   352  			Value:  value,
   353  			Column: coinfiatcurrency.FieldCoinTypeID,
   354  		})
   355  	}
   356  	if cfcu.mutation.CoinTypeIDCleared() {
   357  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   358  			Type:   field.TypeUUID,
   359  			Column: coinfiatcurrency.FieldCoinTypeID,
   360  		})
   361  	}
   362  	if value, ok := cfcu.mutation.FiatID(); ok {
   363  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   364  			Type:   field.TypeUUID,
   365  			Value:  value,
   366  			Column: coinfiatcurrency.FieldFiatID,
   367  		})
   368  	}
   369  	if cfcu.mutation.FiatIDCleared() {
   370  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   371  			Type:   field.TypeUUID,
   372  			Column: coinfiatcurrency.FieldFiatID,
   373  		})
   374  	}
   375  	if value, ok := cfcu.mutation.FeedType(); ok {
   376  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   377  			Type:   field.TypeString,
   378  			Value:  value,
   379  			Column: coinfiatcurrency.FieldFeedType,
   380  		})
   381  	}
   382  	if cfcu.mutation.FeedTypeCleared() {
   383  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   384  			Type:   field.TypeString,
   385  			Column: coinfiatcurrency.FieldFeedType,
   386  		})
   387  	}
   388  	if value, ok := cfcu.mutation.MarketValueLow(); ok {
   389  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   390  			Type:   field.TypeOther,
   391  			Value:  value,
   392  			Column: coinfiatcurrency.FieldMarketValueLow,
   393  		})
   394  	}
   395  	if cfcu.mutation.MarketValueLowCleared() {
   396  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   397  			Type:   field.TypeOther,
   398  			Column: coinfiatcurrency.FieldMarketValueLow,
   399  		})
   400  	}
   401  	if value, ok := cfcu.mutation.MarketValueHigh(); ok {
   402  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   403  			Type:   field.TypeOther,
   404  			Value:  value,
   405  			Column: coinfiatcurrency.FieldMarketValueHigh,
   406  		})
   407  	}
   408  	if cfcu.mutation.MarketValueHighCleared() {
   409  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   410  			Type:   field.TypeOther,
   411  			Column: coinfiatcurrency.FieldMarketValueHigh,
   412  		})
   413  	}
   414  	_spec.Modifiers = cfcu.modifiers
   415  	if n, err = sqlgraph.UpdateNodes(ctx, cfcu.driver, _spec); err != nil {
   416  		if _, ok := err.(*sqlgraph.NotFoundError); ok {
   417  			err = &NotFoundError{coinfiatcurrency.Label}
   418  		} else if sqlgraph.IsConstraintError(err) {
   419  			err = &ConstraintError{msg: err.Error(), wrap: err}
   420  		}
   421  		return 0, err
   422  	}
   423  	return n, nil
   424  }
   425  
   426  // CoinFiatCurrencyUpdateOne is the builder for updating a single CoinFiatCurrency entity.
   427  type CoinFiatCurrencyUpdateOne struct {
   428  	config
   429  	fields    []string
   430  	hooks     []Hook
   431  	mutation  *CoinFiatCurrencyMutation
   432  	modifiers []func(*sql.UpdateBuilder)
   433  }
   434  
   435  // SetCreatedAt sets the "created_at" field.
   436  func (cfcuo *CoinFiatCurrencyUpdateOne) SetCreatedAt(u uint32) *CoinFiatCurrencyUpdateOne {
   437  	cfcuo.mutation.ResetCreatedAt()
   438  	cfcuo.mutation.SetCreatedAt(u)
   439  	return cfcuo
   440  }
   441  
   442  // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
   443  func (cfcuo *CoinFiatCurrencyUpdateOne) SetNillableCreatedAt(u *uint32) *CoinFiatCurrencyUpdateOne {
   444  	if u != nil {
   445  		cfcuo.SetCreatedAt(*u)
   446  	}
   447  	return cfcuo
   448  }
   449  
   450  // AddCreatedAt adds u to the "created_at" field.
   451  func (cfcuo *CoinFiatCurrencyUpdateOne) AddCreatedAt(u int32) *CoinFiatCurrencyUpdateOne {
   452  	cfcuo.mutation.AddCreatedAt(u)
   453  	return cfcuo
   454  }
   455  
   456  // SetUpdatedAt sets the "updated_at" field.
   457  func (cfcuo *CoinFiatCurrencyUpdateOne) SetUpdatedAt(u uint32) *CoinFiatCurrencyUpdateOne {
   458  	cfcuo.mutation.ResetUpdatedAt()
   459  	cfcuo.mutation.SetUpdatedAt(u)
   460  	return cfcuo
   461  }
   462  
   463  // AddUpdatedAt adds u to the "updated_at" field.
   464  func (cfcuo *CoinFiatCurrencyUpdateOne) AddUpdatedAt(u int32) *CoinFiatCurrencyUpdateOne {
   465  	cfcuo.mutation.AddUpdatedAt(u)
   466  	return cfcuo
   467  }
   468  
   469  // SetDeletedAt sets the "deleted_at" field.
   470  func (cfcuo *CoinFiatCurrencyUpdateOne) SetDeletedAt(u uint32) *CoinFiatCurrencyUpdateOne {
   471  	cfcuo.mutation.ResetDeletedAt()
   472  	cfcuo.mutation.SetDeletedAt(u)
   473  	return cfcuo
   474  }
   475  
   476  // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
   477  func (cfcuo *CoinFiatCurrencyUpdateOne) SetNillableDeletedAt(u *uint32) *CoinFiatCurrencyUpdateOne {
   478  	if u != nil {
   479  		cfcuo.SetDeletedAt(*u)
   480  	}
   481  	return cfcuo
   482  }
   483  
   484  // AddDeletedAt adds u to the "deleted_at" field.
   485  func (cfcuo *CoinFiatCurrencyUpdateOne) AddDeletedAt(u int32) *CoinFiatCurrencyUpdateOne {
   486  	cfcuo.mutation.AddDeletedAt(u)
   487  	return cfcuo
   488  }
   489  
   490  // SetEntID sets the "ent_id" field.
   491  func (cfcuo *CoinFiatCurrencyUpdateOne) SetEntID(u uuid.UUID) *CoinFiatCurrencyUpdateOne {
   492  	cfcuo.mutation.SetEntID(u)
   493  	return cfcuo
   494  }
   495  
   496  // SetNillableEntID sets the "ent_id" field if the given value is not nil.
   497  func (cfcuo *CoinFiatCurrencyUpdateOne) SetNillableEntID(u *uuid.UUID) *CoinFiatCurrencyUpdateOne {
   498  	if u != nil {
   499  		cfcuo.SetEntID(*u)
   500  	}
   501  	return cfcuo
   502  }
   503  
   504  // SetCoinTypeID sets the "coin_type_id" field.
   505  func (cfcuo *CoinFiatCurrencyUpdateOne) SetCoinTypeID(u uuid.UUID) *CoinFiatCurrencyUpdateOne {
   506  	cfcuo.mutation.SetCoinTypeID(u)
   507  	return cfcuo
   508  }
   509  
   510  // SetNillableCoinTypeID sets the "coin_type_id" field if the given value is not nil.
   511  func (cfcuo *CoinFiatCurrencyUpdateOne) SetNillableCoinTypeID(u *uuid.UUID) *CoinFiatCurrencyUpdateOne {
   512  	if u != nil {
   513  		cfcuo.SetCoinTypeID(*u)
   514  	}
   515  	return cfcuo
   516  }
   517  
   518  // ClearCoinTypeID clears the value of the "coin_type_id" field.
   519  func (cfcuo *CoinFiatCurrencyUpdateOne) ClearCoinTypeID() *CoinFiatCurrencyUpdateOne {
   520  	cfcuo.mutation.ClearCoinTypeID()
   521  	return cfcuo
   522  }
   523  
   524  // SetFiatID sets the "fiat_id" field.
   525  func (cfcuo *CoinFiatCurrencyUpdateOne) SetFiatID(u uuid.UUID) *CoinFiatCurrencyUpdateOne {
   526  	cfcuo.mutation.SetFiatID(u)
   527  	return cfcuo
   528  }
   529  
   530  // SetNillableFiatID sets the "fiat_id" field if the given value is not nil.
   531  func (cfcuo *CoinFiatCurrencyUpdateOne) SetNillableFiatID(u *uuid.UUID) *CoinFiatCurrencyUpdateOne {
   532  	if u != nil {
   533  		cfcuo.SetFiatID(*u)
   534  	}
   535  	return cfcuo
   536  }
   537  
   538  // ClearFiatID clears the value of the "fiat_id" field.
   539  func (cfcuo *CoinFiatCurrencyUpdateOne) ClearFiatID() *CoinFiatCurrencyUpdateOne {
   540  	cfcuo.mutation.ClearFiatID()
   541  	return cfcuo
   542  }
   543  
   544  // SetFeedType sets the "feed_type" field.
   545  func (cfcuo *CoinFiatCurrencyUpdateOne) SetFeedType(s string) *CoinFiatCurrencyUpdateOne {
   546  	cfcuo.mutation.SetFeedType(s)
   547  	return cfcuo
   548  }
   549  
   550  // SetNillableFeedType sets the "feed_type" field if the given value is not nil.
   551  func (cfcuo *CoinFiatCurrencyUpdateOne) SetNillableFeedType(s *string) *CoinFiatCurrencyUpdateOne {
   552  	if s != nil {
   553  		cfcuo.SetFeedType(*s)
   554  	}
   555  	return cfcuo
   556  }
   557  
   558  // ClearFeedType clears the value of the "feed_type" field.
   559  func (cfcuo *CoinFiatCurrencyUpdateOne) ClearFeedType() *CoinFiatCurrencyUpdateOne {
   560  	cfcuo.mutation.ClearFeedType()
   561  	return cfcuo
   562  }
   563  
   564  // SetMarketValueLow sets the "market_value_low" field.
   565  func (cfcuo *CoinFiatCurrencyUpdateOne) SetMarketValueLow(d decimal.Decimal) *CoinFiatCurrencyUpdateOne {
   566  	cfcuo.mutation.SetMarketValueLow(d)
   567  	return cfcuo
   568  }
   569  
   570  // SetNillableMarketValueLow sets the "market_value_low" field if the given value is not nil.
   571  func (cfcuo *CoinFiatCurrencyUpdateOne) SetNillableMarketValueLow(d *decimal.Decimal) *CoinFiatCurrencyUpdateOne {
   572  	if d != nil {
   573  		cfcuo.SetMarketValueLow(*d)
   574  	}
   575  	return cfcuo
   576  }
   577  
   578  // ClearMarketValueLow clears the value of the "market_value_low" field.
   579  func (cfcuo *CoinFiatCurrencyUpdateOne) ClearMarketValueLow() *CoinFiatCurrencyUpdateOne {
   580  	cfcuo.mutation.ClearMarketValueLow()
   581  	return cfcuo
   582  }
   583  
   584  // SetMarketValueHigh sets the "market_value_high" field.
   585  func (cfcuo *CoinFiatCurrencyUpdateOne) SetMarketValueHigh(d decimal.Decimal) *CoinFiatCurrencyUpdateOne {
   586  	cfcuo.mutation.SetMarketValueHigh(d)
   587  	return cfcuo
   588  }
   589  
   590  // SetNillableMarketValueHigh sets the "market_value_high" field if the given value is not nil.
   591  func (cfcuo *CoinFiatCurrencyUpdateOne) SetNillableMarketValueHigh(d *decimal.Decimal) *CoinFiatCurrencyUpdateOne {
   592  	if d != nil {
   593  		cfcuo.SetMarketValueHigh(*d)
   594  	}
   595  	return cfcuo
   596  }
   597  
   598  // ClearMarketValueHigh clears the value of the "market_value_high" field.
   599  func (cfcuo *CoinFiatCurrencyUpdateOne) ClearMarketValueHigh() *CoinFiatCurrencyUpdateOne {
   600  	cfcuo.mutation.ClearMarketValueHigh()
   601  	return cfcuo
   602  }
   603  
   604  // Mutation returns the CoinFiatCurrencyMutation object of the builder.
   605  func (cfcuo *CoinFiatCurrencyUpdateOne) Mutation() *CoinFiatCurrencyMutation {
   606  	return cfcuo.mutation
   607  }
   608  
   609  // Select allows selecting one or more fields (columns) of the returned entity.
   610  // The default is selecting all fields defined in the entity schema.
   611  func (cfcuo *CoinFiatCurrencyUpdateOne) Select(field string, fields ...string) *CoinFiatCurrencyUpdateOne {
   612  	cfcuo.fields = append([]string{field}, fields...)
   613  	return cfcuo
   614  }
   615  
   616  // Save executes the query and returns the updated CoinFiatCurrency entity.
   617  func (cfcuo *CoinFiatCurrencyUpdateOne) Save(ctx context.Context) (*CoinFiatCurrency, error) {
   618  	var (
   619  		err  error
   620  		node *CoinFiatCurrency
   621  	)
   622  	if err := cfcuo.defaults(); err != nil {
   623  		return nil, err
   624  	}
   625  	if len(cfcuo.hooks) == 0 {
   626  		node, err = cfcuo.sqlSave(ctx)
   627  	} else {
   628  		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
   629  			mutation, ok := m.(*CoinFiatCurrencyMutation)
   630  			if !ok {
   631  				return nil, fmt.Errorf("unexpected mutation type %T", m)
   632  			}
   633  			cfcuo.mutation = mutation
   634  			node, err = cfcuo.sqlSave(ctx)
   635  			mutation.done = true
   636  			return node, err
   637  		})
   638  		for i := len(cfcuo.hooks) - 1; i >= 0; i-- {
   639  			if cfcuo.hooks[i] == nil {
   640  				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
   641  			}
   642  			mut = cfcuo.hooks[i](mut)
   643  		}
   644  		v, err := mut.Mutate(ctx, cfcuo.mutation)
   645  		if err != nil {
   646  			return nil, err
   647  		}
   648  		nv, ok := v.(*CoinFiatCurrency)
   649  		if !ok {
   650  			return nil, fmt.Errorf("unexpected node type %T returned from CoinFiatCurrencyMutation", v)
   651  		}
   652  		node = nv
   653  	}
   654  	return node, err
   655  }
   656  
   657  // SaveX is like Save, but panics if an error occurs.
   658  func (cfcuo *CoinFiatCurrencyUpdateOne) SaveX(ctx context.Context) *CoinFiatCurrency {
   659  	node, err := cfcuo.Save(ctx)
   660  	if err != nil {
   661  		panic(err)
   662  	}
   663  	return node
   664  }
   665  
   666  // Exec executes the query on the entity.
   667  func (cfcuo *CoinFiatCurrencyUpdateOne) Exec(ctx context.Context) error {
   668  	_, err := cfcuo.Save(ctx)
   669  	return err
   670  }
   671  
   672  // ExecX is like Exec, but panics if an error occurs.
   673  func (cfcuo *CoinFiatCurrencyUpdateOne) ExecX(ctx context.Context) {
   674  	if err := cfcuo.Exec(ctx); err != nil {
   675  		panic(err)
   676  	}
   677  }
   678  
   679  // defaults sets the default values of the builder before save.
   680  func (cfcuo *CoinFiatCurrencyUpdateOne) defaults() error {
   681  	if _, ok := cfcuo.mutation.UpdatedAt(); !ok {
   682  		if coinfiatcurrency.UpdateDefaultUpdatedAt == nil {
   683  			return fmt.Errorf("ent: uninitialized coinfiatcurrency.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
   684  		}
   685  		v := coinfiatcurrency.UpdateDefaultUpdatedAt()
   686  		cfcuo.mutation.SetUpdatedAt(v)
   687  	}
   688  	return nil
   689  }
   690  
   691  // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
   692  func (cfcuo *CoinFiatCurrencyUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CoinFiatCurrencyUpdateOne {
   693  	cfcuo.modifiers = append(cfcuo.modifiers, modifiers...)
   694  	return cfcuo
   695  }
   696  
   697  func (cfcuo *CoinFiatCurrencyUpdateOne) sqlSave(ctx context.Context) (_node *CoinFiatCurrency, err error) {
   698  	_spec := &sqlgraph.UpdateSpec{
   699  		Node: &sqlgraph.NodeSpec{
   700  			Table:   coinfiatcurrency.Table,
   701  			Columns: coinfiatcurrency.Columns,
   702  			ID: &sqlgraph.FieldSpec{
   703  				Type:   field.TypeUint32,
   704  				Column: coinfiatcurrency.FieldID,
   705  			},
   706  		},
   707  	}
   708  	id, ok := cfcuo.mutation.ID()
   709  	if !ok {
   710  		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CoinFiatCurrency.id" for update`)}
   711  	}
   712  	_spec.Node.ID.Value = id
   713  	if fields := cfcuo.fields; len(fields) > 0 {
   714  		_spec.Node.Columns = make([]string, 0, len(fields))
   715  		_spec.Node.Columns = append(_spec.Node.Columns, coinfiatcurrency.FieldID)
   716  		for _, f := range fields {
   717  			if !coinfiatcurrency.ValidColumn(f) {
   718  				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
   719  			}
   720  			if f != coinfiatcurrency.FieldID {
   721  				_spec.Node.Columns = append(_spec.Node.Columns, f)
   722  			}
   723  		}
   724  	}
   725  	if ps := cfcuo.mutation.predicates; len(ps) > 0 {
   726  		_spec.Predicate = func(selector *sql.Selector) {
   727  			for i := range ps {
   728  				ps[i](selector)
   729  			}
   730  		}
   731  	}
   732  	if value, ok := cfcuo.mutation.CreatedAt(); ok {
   733  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   734  			Type:   field.TypeUint32,
   735  			Value:  value,
   736  			Column: coinfiatcurrency.FieldCreatedAt,
   737  		})
   738  	}
   739  	if value, ok := cfcuo.mutation.AddedCreatedAt(); ok {
   740  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   741  			Type:   field.TypeUint32,
   742  			Value:  value,
   743  			Column: coinfiatcurrency.FieldCreatedAt,
   744  		})
   745  	}
   746  	if value, ok := cfcuo.mutation.UpdatedAt(); ok {
   747  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   748  			Type:   field.TypeUint32,
   749  			Value:  value,
   750  			Column: coinfiatcurrency.FieldUpdatedAt,
   751  		})
   752  	}
   753  	if value, ok := cfcuo.mutation.AddedUpdatedAt(); ok {
   754  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   755  			Type:   field.TypeUint32,
   756  			Value:  value,
   757  			Column: coinfiatcurrency.FieldUpdatedAt,
   758  		})
   759  	}
   760  	if value, ok := cfcuo.mutation.DeletedAt(); ok {
   761  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   762  			Type:   field.TypeUint32,
   763  			Value:  value,
   764  			Column: coinfiatcurrency.FieldDeletedAt,
   765  		})
   766  	}
   767  	if value, ok := cfcuo.mutation.AddedDeletedAt(); ok {
   768  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   769  			Type:   field.TypeUint32,
   770  			Value:  value,
   771  			Column: coinfiatcurrency.FieldDeletedAt,
   772  		})
   773  	}
   774  	if value, ok := cfcuo.mutation.EntID(); ok {
   775  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   776  			Type:   field.TypeUUID,
   777  			Value:  value,
   778  			Column: coinfiatcurrency.FieldEntID,
   779  		})
   780  	}
   781  	if value, ok := cfcuo.mutation.CoinTypeID(); ok {
   782  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   783  			Type:   field.TypeUUID,
   784  			Value:  value,
   785  			Column: coinfiatcurrency.FieldCoinTypeID,
   786  		})
   787  	}
   788  	if cfcuo.mutation.CoinTypeIDCleared() {
   789  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   790  			Type:   field.TypeUUID,
   791  			Column: coinfiatcurrency.FieldCoinTypeID,
   792  		})
   793  	}
   794  	if value, ok := cfcuo.mutation.FiatID(); ok {
   795  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   796  			Type:   field.TypeUUID,
   797  			Value:  value,
   798  			Column: coinfiatcurrency.FieldFiatID,
   799  		})
   800  	}
   801  	if cfcuo.mutation.FiatIDCleared() {
   802  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   803  			Type:   field.TypeUUID,
   804  			Column: coinfiatcurrency.FieldFiatID,
   805  		})
   806  	}
   807  	if value, ok := cfcuo.mutation.FeedType(); ok {
   808  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   809  			Type:   field.TypeString,
   810  			Value:  value,
   811  			Column: coinfiatcurrency.FieldFeedType,
   812  		})
   813  	}
   814  	if cfcuo.mutation.FeedTypeCleared() {
   815  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   816  			Type:   field.TypeString,
   817  			Column: coinfiatcurrency.FieldFeedType,
   818  		})
   819  	}
   820  	if value, ok := cfcuo.mutation.MarketValueLow(); ok {
   821  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   822  			Type:   field.TypeOther,
   823  			Value:  value,
   824  			Column: coinfiatcurrency.FieldMarketValueLow,
   825  		})
   826  	}
   827  	if cfcuo.mutation.MarketValueLowCleared() {
   828  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   829  			Type:   field.TypeOther,
   830  			Column: coinfiatcurrency.FieldMarketValueLow,
   831  		})
   832  	}
   833  	if value, ok := cfcuo.mutation.MarketValueHigh(); ok {
   834  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   835  			Type:   field.TypeOther,
   836  			Value:  value,
   837  			Column: coinfiatcurrency.FieldMarketValueHigh,
   838  		})
   839  	}
   840  	if cfcuo.mutation.MarketValueHighCleared() {
   841  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   842  			Type:   field.TypeOther,
   843  			Column: coinfiatcurrency.FieldMarketValueHigh,
   844  		})
   845  	}
   846  	_spec.Modifiers = cfcuo.modifiers
   847  	_node = &CoinFiatCurrency{config: cfcuo.config}
   848  	_spec.Assign = _node.assignValues
   849  	_spec.ScanValues = _node.scanValues
   850  	if err = sqlgraph.UpdateNode(ctx, cfcuo.driver, _spec); err != nil {
   851  		if _, ok := err.(*sqlgraph.NotFoundError); ok {
   852  			err = &NotFoundError{coinfiatcurrency.Label}
   853  		} else if sqlgraph.IsConstraintError(err) {
   854  			err = &ConstraintError{msg: err.Error(), wrap: err}
   855  		}
   856  		return nil, err
   857  	}
   858  	return _node, nil
   859  }