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