github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/currencyhistory_create.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/currencyhistory"
    14  	"github.com/google/uuid"
    15  	"github.com/shopspring/decimal"
    16  )
    17  
    18  // CurrencyHistoryCreate is the builder for creating a CurrencyHistory entity.
    19  type CurrencyHistoryCreate struct {
    20  	config
    21  	mutation *CurrencyHistoryMutation
    22  	hooks    []Hook
    23  	conflict []sql.ConflictOption
    24  }
    25  
    26  // SetCreatedAt sets the "created_at" field.
    27  func (chc *CurrencyHistoryCreate) SetCreatedAt(u uint32) *CurrencyHistoryCreate {
    28  	chc.mutation.SetCreatedAt(u)
    29  	return chc
    30  }
    31  
    32  // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
    33  func (chc *CurrencyHistoryCreate) SetNillableCreatedAt(u *uint32) *CurrencyHistoryCreate {
    34  	if u != nil {
    35  		chc.SetCreatedAt(*u)
    36  	}
    37  	return chc
    38  }
    39  
    40  // SetUpdatedAt sets the "updated_at" field.
    41  func (chc *CurrencyHistoryCreate) SetUpdatedAt(u uint32) *CurrencyHistoryCreate {
    42  	chc.mutation.SetUpdatedAt(u)
    43  	return chc
    44  }
    45  
    46  // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
    47  func (chc *CurrencyHistoryCreate) SetNillableUpdatedAt(u *uint32) *CurrencyHistoryCreate {
    48  	if u != nil {
    49  		chc.SetUpdatedAt(*u)
    50  	}
    51  	return chc
    52  }
    53  
    54  // SetDeletedAt sets the "deleted_at" field.
    55  func (chc *CurrencyHistoryCreate) SetDeletedAt(u uint32) *CurrencyHistoryCreate {
    56  	chc.mutation.SetDeletedAt(u)
    57  	return chc
    58  }
    59  
    60  // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
    61  func (chc *CurrencyHistoryCreate) SetNillableDeletedAt(u *uint32) *CurrencyHistoryCreate {
    62  	if u != nil {
    63  		chc.SetDeletedAt(*u)
    64  	}
    65  	return chc
    66  }
    67  
    68  // SetEntID sets the "ent_id" field.
    69  func (chc *CurrencyHistoryCreate) SetEntID(u uuid.UUID) *CurrencyHistoryCreate {
    70  	chc.mutation.SetEntID(u)
    71  	return chc
    72  }
    73  
    74  // SetNillableEntID sets the "ent_id" field if the given value is not nil.
    75  func (chc *CurrencyHistoryCreate) SetNillableEntID(u *uuid.UUID) *CurrencyHistoryCreate {
    76  	if u != nil {
    77  		chc.SetEntID(*u)
    78  	}
    79  	return chc
    80  }
    81  
    82  // SetCoinTypeID sets the "coin_type_id" field.
    83  func (chc *CurrencyHistoryCreate) SetCoinTypeID(u uuid.UUID) *CurrencyHistoryCreate {
    84  	chc.mutation.SetCoinTypeID(u)
    85  	return chc
    86  }
    87  
    88  // SetNillableCoinTypeID sets the "coin_type_id" field if the given value is not nil.
    89  func (chc *CurrencyHistoryCreate) SetNillableCoinTypeID(u *uuid.UUID) *CurrencyHistoryCreate {
    90  	if u != nil {
    91  		chc.SetCoinTypeID(*u)
    92  	}
    93  	return chc
    94  }
    95  
    96  // SetFeedType sets the "feed_type" field.
    97  func (chc *CurrencyHistoryCreate) SetFeedType(s string) *CurrencyHistoryCreate {
    98  	chc.mutation.SetFeedType(s)
    99  	return chc
   100  }
   101  
   102  // SetNillableFeedType sets the "feed_type" field if the given value is not nil.
   103  func (chc *CurrencyHistoryCreate) SetNillableFeedType(s *string) *CurrencyHistoryCreate {
   104  	if s != nil {
   105  		chc.SetFeedType(*s)
   106  	}
   107  	return chc
   108  }
   109  
   110  // SetMarketValueHigh sets the "market_value_high" field.
   111  func (chc *CurrencyHistoryCreate) SetMarketValueHigh(d decimal.Decimal) *CurrencyHistoryCreate {
   112  	chc.mutation.SetMarketValueHigh(d)
   113  	return chc
   114  }
   115  
   116  // SetNillableMarketValueHigh sets the "market_value_high" field if the given value is not nil.
   117  func (chc *CurrencyHistoryCreate) SetNillableMarketValueHigh(d *decimal.Decimal) *CurrencyHistoryCreate {
   118  	if d != nil {
   119  		chc.SetMarketValueHigh(*d)
   120  	}
   121  	return chc
   122  }
   123  
   124  // SetMarketValueLow sets the "market_value_low" field.
   125  func (chc *CurrencyHistoryCreate) SetMarketValueLow(d decimal.Decimal) *CurrencyHistoryCreate {
   126  	chc.mutation.SetMarketValueLow(d)
   127  	return chc
   128  }
   129  
   130  // SetNillableMarketValueLow sets the "market_value_low" field if the given value is not nil.
   131  func (chc *CurrencyHistoryCreate) SetNillableMarketValueLow(d *decimal.Decimal) *CurrencyHistoryCreate {
   132  	if d != nil {
   133  		chc.SetMarketValueLow(*d)
   134  	}
   135  	return chc
   136  }
   137  
   138  // SetID sets the "id" field.
   139  func (chc *CurrencyHistoryCreate) SetID(u uint32) *CurrencyHistoryCreate {
   140  	chc.mutation.SetID(u)
   141  	return chc
   142  }
   143  
   144  // Mutation returns the CurrencyHistoryMutation object of the builder.
   145  func (chc *CurrencyHistoryCreate) Mutation() *CurrencyHistoryMutation {
   146  	return chc.mutation
   147  }
   148  
   149  // Save creates the CurrencyHistory in the database.
   150  func (chc *CurrencyHistoryCreate) Save(ctx context.Context) (*CurrencyHistory, error) {
   151  	var (
   152  		err  error
   153  		node *CurrencyHistory
   154  	)
   155  	if err := chc.defaults(); err != nil {
   156  		return nil, err
   157  	}
   158  	if len(chc.hooks) == 0 {
   159  		if err = chc.check(); err != nil {
   160  			return nil, err
   161  		}
   162  		node, err = chc.sqlSave(ctx)
   163  	} else {
   164  		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
   165  			mutation, ok := m.(*CurrencyHistoryMutation)
   166  			if !ok {
   167  				return nil, fmt.Errorf("unexpected mutation type %T", m)
   168  			}
   169  			if err = chc.check(); err != nil {
   170  				return nil, err
   171  			}
   172  			chc.mutation = mutation
   173  			if node, err = chc.sqlSave(ctx); err != nil {
   174  				return nil, err
   175  			}
   176  			mutation.id = &node.ID
   177  			mutation.done = true
   178  			return node, err
   179  		})
   180  		for i := len(chc.hooks) - 1; i >= 0; i-- {
   181  			if chc.hooks[i] == nil {
   182  				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
   183  			}
   184  			mut = chc.hooks[i](mut)
   185  		}
   186  		v, err := mut.Mutate(ctx, chc.mutation)
   187  		if err != nil {
   188  			return nil, err
   189  		}
   190  		nv, ok := v.(*CurrencyHistory)
   191  		if !ok {
   192  			return nil, fmt.Errorf("unexpected node type %T returned from CurrencyHistoryMutation", v)
   193  		}
   194  		node = nv
   195  	}
   196  	return node, err
   197  }
   198  
   199  // SaveX calls Save and panics if Save returns an error.
   200  func (chc *CurrencyHistoryCreate) SaveX(ctx context.Context) *CurrencyHistory {
   201  	v, err := chc.Save(ctx)
   202  	if err != nil {
   203  		panic(err)
   204  	}
   205  	return v
   206  }
   207  
   208  // Exec executes the query.
   209  func (chc *CurrencyHistoryCreate) Exec(ctx context.Context) error {
   210  	_, err := chc.Save(ctx)
   211  	return err
   212  }
   213  
   214  // ExecX is like Exec, but panics if an error occurs.
   215  func (chc *CurrencyHistoryCreate) ExecX(ctx context.Context) {
   216  	if err := chc.Exec(ctx); err != nil {
   217  		panic(err)
   218  	}
   219  }
   220  
   221  // defaults sets the default values of the builder before save.
   222  func (chc *CurrencyHistoryCreate) defaults() error {
   223  	if _, ok := chc.mutation.CreatedAt(); !ok {
   224  		if currencyhistory.DefaultCreatedAt == nil {
   225  			return fmt.Errorf("ent: uninitialized currencyhistory.DefaultCreatedAt (forgotten import ent/runtime?)")
   226  		}
   227  		v := currencyhistory.DefaultCreatedAt()
   228  		chc.mutation.SetCreatedAt(v)
   229  	}
   230  	if _, ok := chc.mutation.UpdatedAt(); !ok {
   231  		if currencyhistory.DefaultUpdatedAt == nil {
   232  			return fmt.Errorf("ent: uninitialized currencyhistory.DefaultUpdatedAt (forgotten import ent/runtime?)")
   233  		}
   234  		v := currencyhistory.DefaultUpdatedAt()
   235  		chc.mutation.SetUpdatedAt(v)
   236  	}
   237  	if _, ok := chc.mutation.DeletedAt(); !ok {
   238  		if currencyhistory.DefaultDeletedAt == nil {
   239  			return fmt.Errorf("ent: uninitialized currencyhistory.DefaultDeletedAt (forgotten import ent/runtime?)")
   240  		}
   241  		v := currencyhistory.DefaultDeletedAt()
   242  		chc.mutation.SetDeletedAt(v)
   243  	}
   244  	if _, ok := chc.mutation.EntID(); !ok {
   245  		if currencyhistory.DefaultEntID == nil {
   246  			return fmt.Errorf("ent: uninitialized currencyhistory.DefaultEntID (forgotten import ent/runtime?)")
   247  		}
   248  		v := currencyhistory.DefaultEntID()
   249  		chc.mutation.SetEntID(v)
   250  	}
   251  	if _, ok := chc.mutation.CoinTypeID(); !ok {
   252  		if currencyhistory.DefaultCoinTypeID == nil {
   253  			return fmt.Errorf("ent: uninitialized currencyhistory.DefaultCoinTypeID (forgotten import ent/runtime?)")
   254  		}
   255  		v := currencyhistory.DefaultCoinTypeID()
   256  		chc.mutation.SetCoinTypeID(v)
   257  	}
   258  	if _, ok := chc.mutation.FeedType(); !ok {
   259  		v := currencyhistory.DefaultFeedType
   260  		chc.mutation.SetFeedType(v)
   261  	}
   262  	if _, ok := chc.mutation.MarketValueHigh(); !ok {
   263  		v := currencyhistory.DefaultMarketValueHigh
   264  		chc.mutation.SetMarketValueHigh(v)
   265  	}
   266  	if _, ok := chc.mutation.MarketValueLow(); !ok {
   267  		v := currencyhistory.DefaultMarketValueLow
   268  		chc.mutation.SetMarketValueLow(v)
   269  	}
   270  	return nil
   271  }
   272  
   273  // check runs all checks and user-defined validators on the builder.
   274  func (chc *CurrencyHistoryCreate) check() error {
   275  	if _, ok := chc.mutation.CreatedAt(); !ok {
   276  		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "CurrencyHistory.created_at"`)}
   277  	}
   278  	if _, ok := chc.mutation.UpdatedAt(); !ok {
   279  		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "CurrencyHistory.updated_at"`)}
   280  	}
   281  	if _, ok := chc.mutation.DeletedAt(); !ok {
   282  		return &ValidationError{Name: "deleted_at", err: errors.New(`ent: missing required field "CurrencyHistory.deleted_at"`)}
   283  	}
   284  	if _, ok := chc.mutation.EntID(); !ok {
   285  		return &ValidationError{Name: "ent_id", err: errors.New(`ent: missing required field "CurrencyHistory.ent_id"`)}
   286  	}
   287  	return nil
   288  }
   289  
   290  func (chc *CurrencyHistoryCreate) sqlSave(ctx context.Context) (*CurrencyHistory, error) {
   291  	_node, _spec := chc.createSpec()
   292  	if err := sqlgraph.CreateNode(ctx, chc.driver, _spec); err != nil {
   293  		if sqlgraph.IsConstraintError(err) {
   294  			err = &ConstraintError{msg: err.Error(), wrap: err}
   295  		}
   296  		return nil, err
   297  	}
   298  	if _spec.ID.Value != _node.ID {
   299  		id := _spec.ID.Value.(int64)
   300  		_node.ID = uint32(id)
   301  	}
   302  	return _node, nil
   303  }
   304  
   305  func (chc *CurrencyHistoryCreate) createSpec() (*CurrencyHistory, *sqlgraph.CreateSpec) {
   306  	var (
   307  		_node = &CurrencyHistory{config: chc.config}
   308  		_spec = &sqlgraph.CreateSpec{
   309  			Table: currencyhistory.Table,
   310  			ID: &sqlgraph.FieldSpec{
   311  				Type:   field.TypeUint32,
   312  				Column: currencyhistory.FieldID,
   313  			},
   314  		}
   315  	)
   316  	_spec.OnConflict = chc.conflict
   317  	if id, ok := chc.mutation.ID(); ok {
   318  		_node.ID = id
   319  		_spec.ID.Value = id
   320  	}
   321  	if value, ok := chc.mutation.CreatedAt(); ok {
   322  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   323  			Type:   field.TypeUint32,
   324  			Value:  value,
   325  			Column: currencyhistory.FieldCreatedAt,
   326  		})
   327  		_node.CreatedAt = value
   328  	}
   329  	if value, ok := chc.mutation.UpdatedAt(); ok {
   330  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   331  			Type:   field.TypeUint32,
   332  			Value:  value,
   333  			Column: currencyhistory.FieldUpdatedAt,
   334  		})
   335  		_node.UpdatedAt = value
   336  	}
   337  	if value, ok := chc.mutation.DeletedAt(); ok {
   338  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   339  			Type:   field.TypeUint32,
   340  			Value:  value,
   341  			Column: currencyhistory.FieldDeletedAt,
   342  		})
   343  		_node.DeletedAt = value
   344  	}
   345  	if value, ok := chc.mutation.EntID(); ok {
   346  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   347  			Type:   field.TypeUUID,
   348  			Value:  value,
   349  			Column: currencyhistory.FieldEntID,
   350  		})
   351  		_node.EntID = value
   352  	}
   353  	if value, ok := chc.mutation.CoinTypeID(); ok {
   354  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   355  			Type:   field.TypeUUID,
   356  			Value:  value,
   357  			Column: currencyhistory.FieldCoinTypeID,
   358  		})
   359  		_node.CoinTypeID = value
   360  	}
   361  	if value, ok := chc.mutation.FeedType(); ok {
   362  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   363  			Type:   field.TypeString,
   364  			Value:  value,
   365  			Column: currencyhistory.FieldFeedType,
   366  		})
   367  		_node.FeedType = value
   368  	}
   369  	if value, ok := chc.mutation.MarketValueHigh(); ok {
   370  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   371  			Type:   field.TypeOther,
   372  			Value:  value,
   373  			Column: currencyhistory.FieldMarketValueHigh,
   374  		})
   375  		_node.MarketValueHigh = value
   376  	}
   377  	if value, ok := chc.mutation.MarketValueLow(); ok {
   378  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   379  			Type:   field.TypeOther,
   380  			Value:  value,
   381  			Column: currencyhistory.FieldMarketValueLow,
   382  		})
   383  		_node.MarketValueLow = value
   384  	}
   385  	return _node, _spec
   386  }
   387  
   388  // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
   389  // of the `INSERT` statement. For example:
   390  //
   391  //	client.CurrencyHistory.Create().
   392  //		SetCreatedAt(v).
   393  //		OnConflict(
   394  //			// Update the row with the new values
   395  //			// the was proposed for insertion.
   396  //			sql.ResolveWithNewValues(),
   397  //		).
   398  //		// Override some of the fields with custom
   399  //		// update values.
   400  //		Update(func(u *ent.CurrencyHistoryUpsert) {
   401  //			SetCreatedAt(v+v).
   402  //		}).
   403  //		Exec(ctx)
   404  //
   405  func (chc *CurrencyHistoryCreate) OnConflict(opts ...sql.ConflictOption) *CurrencyHistoryUpsertOne {
   406  	chc.conflict = opts
   407  	return &CurrencyHistoryUpsertOne{
   408  		create: chc,
   409  	}
   410  }
   411  
   412  // OnConflictColumns calls `OnConflict` and configures the columns
   413  // as conflict target. Using this option is equivalent to using:
   414  //
   415  //	client.CurrencyHistory.Create().
   416  //		OnConflict(sql.ConflictColumns(columns...)).
   417  //		Exec(ctx)
   418  //
   419  func (chc *CurrencyHistoryCreate) OnConflictColumns(columns ...string) *CurrencyHistoryUpsertOne {
   420  	chc.conflict = append(chc.conflict, sql.ConflictColumns(columns...))
   421  	return &CurrencyHistoryUpsertOne{
   422  		create: chc,
   423  	}
   424  }
   425  
   426  type (
   427  	// CurrencyHistoryUpsertOne is the builder for "upsert"-ing
   428  	//  one CurrencyHistory node.
   429  	CurrencyHistoryUpsertOne struct {
   430  		create *CurrencyHistoryCreate
   431  	}
   432  
   433  	// CurrencyHistoryUpsert is the "OnConflict" setter.
   434  	CurrencyHistoryUpsert struct {
   435  		*sql.UpdateSet
   436  	}
   437  )
   438  
   439  // SetCreatedAt sets the "created_at" field.
   440  func (u *CurrencyHistoryUpsert) SetCreatedAt(v uint32) *CurrencyHistoryUpsert {
   441  	u.Set(currencyhistory.FieldCreatedAt, v)
   442  	return u
   443  }
   444  
   445  // UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
   446  func (u *CurrencyHistoryUpsert) UpdateCreatedAt() *CurrencyHistoryUpsert {
   447  	u.SetExcluded(currencyhistory.FieldCreatedAt)
   448  	return u
   449  }
   450  
   451  // AddCreatedAt adds v to the "created_at" field.
   452  func (u *CurrencyHistoryUpsert) AddCreatedAt(v uint32) *CurrencyHistoryUpsert {
   453  	u.Add(currencyhistory.FieldCreatedAt, v)
   454  	return u
   455  }
   456  
   457  // SetUpdatedAt sets the "updated_at" field.
   458  func (u *CurrencyHistoryUpsert) SetUpdatedAt(v uint32) *CurrencyHistoryUpsert {
   459  	u.Set(currencyhistory.FieldUpdatedAt, v)
   460  	return u
   461  }
   462  
   463  // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
   464  func (u *CurrencyHistoryUpsert) UpdateUpdatedAt() *CurrencyHistoryUpsert {
   465  	u.SetExcluded(currencyhistory.FieldUpdatedAt)
   466  	return u
   467  }
   468  
   469  // AddUpdatedAt adds v to the "updated_at" field.
   470  func (u *CurrencyHistoryUpsert) AddUpdatedAt(v uint32) *CurrencyHistoryUpsert {
   471  	u.Add(currencyhistory.FieldUpdatedAt, v)
   472  	return u
   473  }
   474  
   475  // SetDeletedAt sets the "deleted_at" field.
   476  func (u *CurrencyHistoryUpsert) SetDeletedAt(v uint32) *CurrencyHistoryUpsert {
   477  	u.Set(currencyhistory.FieldDeletedAt, v)
   478  	return u
   479  }
   480  
   481  // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
   482  func (u *CurrencyHistoryUpsert) UpdateDeletedAt() *CurrencyHistoryUpsert {
   483  	u.SetExcluded(currencyhistory.FieldDeletedAt)
   484  	return u
   485  }
   486  
   487  // AddDeletedAt adds v to the "deleted_at" field.
   488  func (u *CurrencyHistoryUpsert) AddDeletedAt(v uint32) *CurrencyHistoryUpsert {
   489  	u.Add(currencyhistory.FieldDeletedAt, v)
   490  	return u
   491  }
   492  
   493  // SetEntID sets the "ent_id" field.
   494  func (u *CurrencyHistoryUpsert) SetEntID(v uuid.UUID) *CurrencyHistoryUpsert {
   495  	u.Set(currencyhistory.FieldEntID, v)
   496  	return u
   497  }
   498  
   499  // UpdateEntID sets the "ent_id" field to the value that was provided on create.
   500  func (u *CurrencyHistoryUpsert) UpdateEntID() *CurrencyHistoryUpsert {
   501  	u.SetExcluded(currencyhistory.FieldEntID)
   502  	return u
   503  }
   504  
   505  // SetCoinTypeID sets the "coin_type_id" field.
   506  func (u *CurrencyHistoryUpsert) SetCoinTypeID(v uuid.UUID) *CurrencyHistoryUpsert {
   507  	u.Set(currencyhistory.FieldCoinTypeID, v)
   508  	return u
   509  }
   510  
   511  // UpdateCoinTypeID sets the "coin_type_id" field to the value that was provided on create.
   512  func (u *CurrencyHistoryUpsert) UpdateCoinTypeID() *CurrencyHistoryUpsert {
   513  	u.SetExcluded(currencyhistory.FieldCoinTypeID)
   514  	return u
   515  }
   516  
   517  // ClearCoinTypeID clears the value of the "coin_type_id" field.
   518  func (u *CurrencyHistoryUpsert) ClearCoinTypeID() *CurrencyHistoryUpsert {
   519  	u.SetNull(currencyhistory.FieldCoinTypeID)
   520  	return u
   521  }
   522  
   523  // SetFeedType sets the "feed_type" field.
   524  func (u *CurrencyHistoryUpsert) SetFeedType(v string) *CurrencyHistoryUpsert {
   525  	u.Set(currencyhistory.FieldFeedType, v)
   526  	return u
   527  }
   528  
   529  // UpdateFeedType sets the "feed_type" field to the value that was provided on create.
   530  func (u *CurrencyHistoryUpsert) UpdateFeedType() *CurrencyHistoryUpsert {
   531  	u.SetExcluded(currencyhistory.FieldFeedType)
   532  	return u
   533  }
   534  
   535  // ClearFeedType clears the value of the "feed_type" field.
   536  func (u *CurrencyHistoryUpsert) ClearFeedType() *CurrencyHistoryUpsert {
   537  	u.SetNull(currencyhistory.FieldFeedType)
   538  	return u
   539  }
   540  
   541  // SetMarketValueHigh sets the "market_value_high" field.
   542  func (u *CurrencyHistoryUpsert) SetMarketValueHigh(v decimal.Decimal) *CurrencyHistoryUpsert {
   543  	u.Set(currencyhistory.FieldMarketValueHigh, v)
   544  	return u
   545  }
   546  
   547  // UpdateMarketValueHigh sets the "market_value_high" field to the value that was provided on create.
   548  func (u *CurrencyHistoryUpsert) UpdateMarketValueHigh() *CurrencyHistoryUpsert {
   549  	u.SetExcluded(currencyhistory.FieldMarketValueHigh)
   550  	return u
   551  }
   552  
   553  // ClearMarketValueHigh clears the value of the "market_value_high" field.
   554  func (u *CurrencyHistoryUpsert) ClearMarketValueHigh() *CurrencyHistoryUpsert {
   555  	u.SetNull(currencyhistory.FieldMarketValueHigh)
   556  	return u
   557  }
   558  
   559  // SetMarketValueLow sets the "market_value_low" field.
   560  func (u *CurrencyHistoryUpsert) SetMarketValueLow(v decimal.Decimal) *CurrencyHistoryUpsert {
   561  	u.Set(currencyhistory.FieldMarketValueLow, v)
   562  	return u
   563  }
   564  
   565  // UpdateMarketValueLow sets the "market_value_low" field to the value that was provided on create.
   566  func (u *CurrencyHistoryUpsert) UpdateMarketValueLow() *CurrencyHistoryUpsert {
   567  	u.SetExcluded(currencyhistory.FieldMarketValueLow)
   568  	return u
   569  }
   570  
   571  // ClearMarketValueLow clears the value of the "market_value_low" field.
   572  func (u *CurrencyHistoryUpsert) ClearMarketValueLow() *CurrencyHistoryUpsert {
   573  	u.SetNull(currencyhistory.FieldMarketValueLow)
   574  	return u
   575  }
   576  
   577  // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
   578  // Using this option is equivalent to using:
   579  //
   580  //	client.CurrencyHistory.Create().
   581  //		OnConflict(
   582  //			sql.ResolveWithNewValues(),
   583  //			sql.ResolveWith(func(u *sql.UpdateSet) {
   584  //				u.SetIgnore(currencyhistory.FieldID)
   585  //			}),
   586  //		).
   587  //		Exec(ctx)
   588  //
   589  func (u *CurrencyHistoryUpsertOne) UpdateNewValues() *CurrencyHistoryUpsertOne {
   590  	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
   591  	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
   592  		if _, exists := u.create.mutation.ID(); exists {
   593  			s.SetIgnore(currencyhistory.FieldID)
   594  		}
   595  	}))
   596  	return u
   597  }
   598  
   599  // Ignore sets each column to itself in case of conflict.
   600  // Using this option is equivalent to using:
   601  //
   602  //  client.CurrencyHistory.Create().
   603  //      OnConflict(sql.ResolveWithIgnore()).
   604  //      Exec(ctx)
   605  //
   606  func (u *CurrencyHistoryUpsertOne) Ignore() *CurrencyHistoryUpsertOne {
   607  	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
   608  	return u
   609  }
   610  
   611  // DoNothing configures the conflict_action to `DO NOTHING`.
   612  // Supported only by SQLite and PostgreSQL.
   613  func (u *CurrencyHistoryUpsertOne) DoNothing() *CurrencyHistoryUpsertOne {
   614  	u.create.conflict = append(u.create.conflict, sql.DoNothing())
   615  	return u
   616  }
   617  
   618  // Update allows overriding fields `UPDATE` values. See the CurrencyHistoryCreate.OnConflict
   619  // documentation for more info.
   620  func (u *CurrencyHistoryUpsertOne) Update(set func(*CurrencyHistoryUpsert)) *CurrencyHistoryUpsertOne {
   621  	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
   622  		set(&CurrencyHistoryUpsert{UpdateSet: update})
   623  	}))
   624  	return u
   625  }
   626  
   627  // SetCreatedAt sets the "created_at" field.
   628  func (u *CurrencyHistoryUpsertOne) SetCreatedAt(v uint32) *CurrencyHistoryUpsertOne {
   629  	return u.Update(func(s *CurrencyHistoryUpsert) {
   630  		s.SetCreatedAt(v)
   631  	})
   632  }
   633  
   634  // AddCreatedAt adds v to the "created_at" field.
   635  func (u *CurrencyHistoryUpsertOne) AddCreatedAt(v uint32) *CurrencyHistoryUpsertOne {
   636  	return u.Update(func(s *CurrencyHistoryUpsert) {
   637  		s.AddCreatedAt(v)
   638  	})
   639  }
   640  
   641  // UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
   642  func (u *CurrencyHistoryUpsertOne) UpdateCreatedAt() *CurrencyHistoryUpsertOne {
   643  	return u.Update(func(s *CurrencyHistoryUpsert) {
   644  		s.UpdateCreatedAt()
   645  	})
   646  }
   647  
   648  // SetUpdatedAt sets the "updated_at" field.
   649  func (u *CurrencyHistoryUpsertOne) SetUpdatedAt(v uint32) *CurrencyHistoryUpsertOne {
   650  	return u.Update(func(s *CurrencyHistoryUpsert) {
   651  		s.SetUpdatedAt(v)
   652  	})
   653  }
   654  
   655  // AddUpdatedAt adds v to the "updated_at" field.
   656  func (u *CurrencyHistoryUpsertOne) AddUpdatedAt(v uint32) *CurrencyHistoryUpsertOne {
   657  	return u.Update(func(s *CurrencyHistoryUpsert) {
   658  		s.AddUpdatedAt(v)
   659  	})
   660  }
   661  
   662  // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
   663  func (u *CurrencyHistoryUpsertOne) UpdateUpdatedAt() *CurrencyHistoryUpsertOne {
   664  	return u.Update(func(s *CurrencyHistoryUpsert) {
   665  		s.UpdateUpdatedAt()
   666  	})
   667  }
   668  
   669  // SetDeletedAt sets the "deleted_at" field.
   670  func (u *CurrencyHistoryUpsertOne) SetDeletedAt(v uint32) *CurrencyHistoryUpsertOne {
   671  	return u.Update(func(s *CurrencyHistoryUpsert) {
   672  		s.SetDeletedAt(v)
   673  	})
   674  }
   675  
   676  // AddDeletedAt adds v to the "deleted_at" field.
   677  func (u *CurrencyHistoryUpsertOne) AddDeletedAt(v uint32) *CurrencyHistoryUpsertOne {
   678  	return u.Update(func(s *CurrencyHistoryUpsert) {
   679  		s.AddDeletedAt(v)
   680  	})
   681  }
   682  
   683  // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
   684  func (u *CurrencyHistoryUpsertOne) UpdateDeletedAt() *CurrencyHistoryUpsertOne {
   685  	return u.Update(func(s *CurrencyHistoryUpsert) {
   686  		s.UpdateDeletedAt()
   687  	})
   688  }
   689  
   690  // SetEntID sets the "ent_id" field.
   691  func (u *CurrencyHistoryUpsertOne) SetEntID(v uuid.UUID) *CurrencyHistoryUpsertOne {
   692  	return u.Update(func(s *CurrencyHistoryUpsert) {
   693  		s.SetEntID(v)
   694  	})
   695  }
   696  
   697  // UpdateEntID sets the "ent_id" field to the value that was provided on create.
   698  func (u *CurrencyHistoryUpsertOne) UpdateEntID() *CurrencyHistoryUpsertOne {
   699  	return u.Update(func(s *CurrencyHistoryUpsert) {
   700  		s.UpdateEntID()
   701  	})
   702  }
   703  
   704  // SetCoinTypeID sets the "coin_type_id" field.
   705  func (u *CurrencyHistoryUpsertOne) SetCoinTypeID(v uuid.UUID) *CurrencyHistoryUpsertOne {
   706  	return u.Update(func(s *CurrencyHistoryUpsert) {
   707  		s.SetCoinTypeID(v)
   708  	})
   709  }
   710  
   711  // UpdateCoinTypeID sets the "coin_type_id" field to the value that was provided on create.
   712  func (u *CurrencyHistoryUpsertOne) UpdateCoinTypeID() *CurrencyHistoryUpsertOne {
   713  	return u.Update(func(s *CurrencyHistoryUpsert) {
   714  		s.UpdateCoinTypeID()
   715  	})
   716  }
   717  
   718  // ClearCoinTypeID clears the value of the "coin_type_id" field.
   719  func (u *CurrencyHistoryUpsertOne) ClearCoinTypeID() *CurrencyHistoryUpsertOne {
   720  	return u.Update(func(s *CurrencyHistoryUpsert) {
   721  		s.ClearCoinTypeID()
   722  	})
   723  }
   724  
   725  // SetFeedType sets the "feed_type" field.
   726  func (u *CurrencyHistoryUpsertOne) SetFeedType(v string) *CurrencyHistoryUpsertOne {
   727  	return u.Update(func(s *CurrencyHistoryUpsert) {
   728  		s.SetFeedType(v)
   729  	})
   730  }
   731  
   732  // UpdateFeedType sets the "feed_type" field to the value that was provided on create.
   733  func (u *CurrencyHistoryUpsertOne) UpdateFeedType() *CurrencyHistoryUpsertOne {
   734  	return u.Update(func(s *CurrencyHistoryUpsert) {
   735  		s.UpdateFeedType()
   736  	})
   737  }
   738  
   739  // ClearFeedType clears the value of the "feed_type" field.
   740  func (u *CurrencyHistoryUpsertOne) ClearFeedType() *CurrencyHistoryUpsertOne {
   741  	return u.Update(func(s *CurrencyHistoryUpsert) {
   742  		s.ClearFeedType()
   743  	})
   744  }
   745  
   746  // SetMarketValueHigh sets the "market_value_high" field.
   747  func (u *CurrencyHistoryUpsertOne) SetMarketValueHigh(v decimal.Decimal) *CurrencyHistoryUpsertOne {
   748  	return u.Update(func(s *CurrencyHistoryUpsert) {
   749  		s.SetMarketValueHigh(v)
   750  	})
   751  }
   752  
   753  // UpdateMarketValueHigh sets the "market_value_high" field to the value that was provided on create.
   754  func (u *CurrencyHistoryUpsertOne) UpdateMarketValueHigh() *CurrencyHistoryUpsertOne {
   755  	return u.Update(func(s *CurrencyHistoryUpsert) {
   756  		s.UpdateMarketValueHigh()
   757  	})
   758  }
   759  
   760  // ClearMarketValueHigh clears the value of the "market_value_high" field.
   761  func (u *CurrencyHistoryUpsertOne) ClearMarketValueHigh() *CurrencyHistoryUpsertOne {
   762  	return u.Update(func(s *CurrencyHistoryUpsert) {
   763  		s.ClearMarketValueHigh()
   764  	})
   765  }
   766  
   767  // SetMarketValueLow sets the "market_value_low" field.
   768  func (u *CurrencyHistoryUpsertOne) SetMarketValueLow(v decimal.Decimal) *CurrencyHistoryUpsertOne {
   769  	return u.Update(func(s *CurrencyHistoryUpsert) {
   770  		s.SetMarketValueLow(v)
   771  	})
   772  }
   773  
   774  // UpdateMarketValueLow sets the "market_value_low" field to the value that was provided on create.
   775  func (u *CurrencyHistoryUpsertOne) UpdateMarketValueLow() *CurrencyHistoryUpsertOne {
   776  	return u.Update(func(s *CurrencyHistoryUpsert) {
   777  		s.UpdateMarketValueLow()
   778  	})
   779  }
   780  
   781  // ClearMarketValueLow clears the value of the "market_value_low" field.
   782  func (u *CurrencyHistoryUpsertOne) ClearMarketValueLow() *CurrencyHistoryUpsertOne {
   783  	return u.Update(func(s *CurrencyHistoryUpsert) {
   784  		s.ClearMarketValueLow()
   785  	})
   786  }
   787  
   788  // Exec executes the query.
   789  func (u *CurrencyHistoryUpsertOne) Exec(ctx context.Context) error {
   790  	if len(u.create.conflict) == 0 {
   791  		return errors.New("ent: missing options for CurrencyHistoryCreate.OnConflict")
   792  	}
   793  	return u.create.Exec(ctx)
   794  }
   795  
   796  // ExecX is like Exec, but panics if an error occurs.
   797  func (u *CurrencyHistoryUpsertOne) ExecX(ctx context.Context) {
   798  	if err := u.create.Exec(ctx); err != nil {
   799  		panic(err)
   800  	}
   801  }
   802  
   803  // Exec executes the UPSERT query and returns the inserted/updated ID.
   804  func (u *CurrencyHistoryUpsertOne) ID(ctx context.Context) (id uint32, err error) {
   805  	node, err := u.create.Save(ctx)
   806  	if err != nil {
   807  		return id, err
   808  	}
   809  	return node.ID, nil
   810  }
   811  
   812  // IDX is like ID, but panics if an error occurs.
   813  func (u *CurrencyHistoryUpsertOne) IDX(ctx context.Context) uint32 {
   814  	id, err := u.ID(ctx)
   815  	if err != nil {
   816  		panic(err)
   817  	}
   818  	return id
   819  }
   820  
   821  // CurrencyHistoryCreateBulk is the builder for creating many CurrencyHistory entities in bulk.
   822  type CurrencyHistoryCreateBulk struct {
   823  	config
   824  	builders []*CurrencyHistoryCreate
   825  	conflict []sql.ConflictOption
   826  }
   827  
   828  // Save creates the CurrencyHistory entities in the database.
   829  func (chcb *CurrencyHistoryCreateBulk) Save(ctx context.Context) ([]*CurrencyHistory, error) {
   830  	specs := make([]*sqlgraph.CreateSpec, len(chcb.builders))
   831  	nodes := make([]*CurrencyHistory, len(chcb.builders))
   832  	mutators := make([]Mutator, len(chcb.builders))
   833  	for i := range chcb.builders {
   834  		func(i int, root context.Context) {
   835  			builder := chcb.builders[i]
   836  			builder.defaults()
   837  			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
   838  				mutation, ok := m.(*CurrencyHistoryMutation)
   839  				if !ok {
   840  					return nil, fmt.Errorf("unexpected mutation type %T", m)
   841  				}
   842  				if err := builder.check(); err != nil {
   843  					return nil, err
   844  				}
   845  				builder.mutation = mutation
   846  				nodes[i], specs[i] = builder.createSpec()
   847  				var err error
   848  				if i < len(mutators)-1 {
   849  					_, err = mutators[i+1].Mutate(root, chcb.builders[i+1].mutation)
   850  				} else {
   851  					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
   852  					spec.OnConflict = chcb.conflict
   853  					// Invoke the actual operation on the latest mutation in the chain.
   854  					if err = sqlgraph.BatchCreate(ctx, chcb.driver, spec); err != nil {
   855  						if sqlgraph.IsConstraintError(err) {
   856  							err = &ConstraintError{msg: err.Error(), wrap: err}
   857  						}
   858  					}
   859  				}
   860  				if err != nil {
   861  					return nil, err
   862  				}
   863  				mutation.id = &nodes[i].ID
   864  				if specs[i].ID.Value != nil && nodes[i].ID == 0 {
   865  					id := specs[i].ID.Value.(int64)
   866  					nodes[i].ID = uint32(id)
   867  				}
   868  				mutation.done = true
   869  				return nodes[i], nil
   870  			})
   871  			for i := len(builder.hooks) - 1; i >= 0; i-- {
   872  				mut = builder.hooks[i](mut)
   873  			}
   874  			mutators[i] = mut
   875  		}(i, ctx)
   876  	}
   877  	if len(mutators) > 0 {
   878  		if _, err := mutators[0].Mutate(ctx, chcb.builders[0].mutation); err != nil {
   879  			return nil, err
   880  		}
   881  	}
   882  	return nodes, nil
   883  }
   884  
   885  // SaveX is like Save, but panics if an error occurs.
   886  func (chcb *CurrencyHistoryCreateBulk) SaveX(ctx context.Context) []*CurrencyHistory {
   887  	v, err := chcb.Save(ctx)
   888  	if err != nil {
   889  		panic(err)
   890  	}
   891  	return v
   892  }
   893  
   894  // Exec executes the query.
   895  func (chcb *CurrencyHistoryCreateBulk) Exec(ctx context.Context) error {
   896  	_, err := chcb.Save(ctx)
   897  	return err
   898  }
   899  
   900  // ExecX is like Exec, but panics if an error occurs.
   901  func (chcb *CurrencyHistoryCreateBulk) ExecX(ctx context.Context) {
   902  	if err := chcb.Exec(ctx); err != nil {
   903  		panic(err)
   904  	}
   905  }
   906  
   907  // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
   908  // of the `INSERT` statement. For example:
   909  //
   910  //	client.CurrencyHistory.CreateBulk(builders...).
   911  //		OnConflict(
   912  //			// Update the row with the new values
   913  //			// the was proposed for insertion.
   914  //			sql.ResolveWithNewValues(),
   915  //		).
   916  //		// Override some of the fields with custom
   917  //		// update values.
   918  //		Update(func(u *ent.CurrencyHistoryUpsert) {
   919  //			SetCreatedAt(v+v).
   920  //		}).
   921  //		Exec(ctx)
   922  //
   923  func (chcb *CurrencyHistoryCreateBulk) OnConflict(opts ...sql.ConflictOption) *CurrencyHistoryUpsertBulk {
   924  	chcb.conflict = opts
   925  	return &CurrencyHistoryUpsertBulk{
   926  		create: chcb,
   927  	}
   928  }
   929  
   930  // OnConflictColumns calls `OnConflict` and configures the columns
   931  // as conflict target. Using this option is equivalent to using:
   932  //
   933  //	client.CurrencyHistory.Create().
   934  //		OnConflict(sql.ConflictColumns(columns...)).
   935  //		Exec(ctx)
   936  //
   937  func (chcb *CurrencyHistoryCreateBulk) OnConflictColumns(columns ...string) *CurrencyHistoryUpsertBulk {
   938  	chcb.conflict = append(chcb.conflict, sql.ConflictColumns(columns...))
   939  	return &CurrencyHistoryUpsertBulk{
   940  		create: chcb,
   941  	}
   942  }
   943  
   944  // CurrencyHistoryUpsertBulk is the builder for "upsert"-ing
   945  // a bulk of CurrencyHistory nodes.
   946  type CurrencyHistoryUpsertBulk struct {
   947  	create *CurrencyHistoryCreateBulk
   948  }
   949  
   950  // UpdateNewValues updates the mutable fields using the new values that
   951  // were set on create. Using this option is equivalent to using:
   952  //
   953  //	client.CurrencyHistory.Create().
   954  //		OnConflict(
   955  //			sql.ResolveWithNewValues(),
   956  //			sql.ResolveWith(func(u *sql.UpdateSet) {
   957  //				u.SetIgnore(currencyhistory.FieldID)
   958  //			}),
   959  //		).
   960  //		Exec(ctx)
   961  //
   962  func (u *CurrencyHistoryUpsertBulk) UpdateNewValues() *CurrencyHistoryUpsertBulk {
   963  	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
   964  	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
   965  		for _, b := range u.create.builders {
   966  			if _, exists := b.mutation.ID(); exists {
   967  				s.SetIgnore(currencyhistory.FieldID)
   968  				return
   969  			}
   970  		}
   971  	}))
   972  	return u
   973  }
   974  
   975  // Ignore sets each column to itself in case of conflict.
   976  // Using this option is equivalent to using:
   977  //
   978  //	client.CurrencyHistory.Create().
   979  //		OnConflict(sql.ResolveWithIgnore()).
   980  //		Exec(ctx)
   981  //
   982  func (u *CurrencyHistoryUpsertBulk) Ignore() *CurrencyHistoryUpsertBulk {
   983  	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
   984  	return u
   985  }
   986  
   987  // DoNothing configures the conflict_action to `DO NOTHING`.
   988  // Supported only by SQLite and PostgreSQL.
   989  func (u *CurrencyHistoryUpsertBulk) DoNothing() *CurrencyHistoryUpsertBulk {
   990  	u.create.conflict = append(u.create.conflict, sql.DoNothing())
   991  	return u
   992  }
   993  
   994  // Update allows overriding fields `UPDATE` values. See the CurrencyHistoryCreateBulk.OnConflict
   995  // documentation for more info.
   996  func (u *CurrencyHistoryUpsertBulk) Update(set func(*CurrencyHistoryUpsert)) *CurrencyHistoryUpsertBulk {
   997  	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
   998  		set(&CurrencyHistoryUpsert{UpdateSet: update})
   999  	}))
  1000  	return u
  1001  }
  1002  
  1003  // SetCreatedAt sets the "created_at" field.
  1004  func (u *CurrencyHistoryUpsertBulk) SetCreatedAt(v uint32) *CurrencyHistoryUpsertBulk {
  1005  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1006  		s.SetCreatedAt(v)
  1007  	})
  1008  }
  1009  
  1010  // AddCreatedAt adds v to the "created_at" field.
  1011  func (u *CurrencyHistoryUpsertBulk) AddCreatedAt(v uint32) *CurrencyHistoryUpsertBulk {
  1012  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1013  		s.AddCreatedAt(v)
  1014  	})
  1015  }
  1016  
  1017  // UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
  1018  func (u *CurrencyHistoryUpsertBulk) UpdateCreatedAt() *CurrencyHistoryUpsertBulk {
  1019  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1020  		s.UpdateCreatedAt()
  1021  	})
  1022  }
  1023  
  1024  // SetUpdatedAt sets the "updated_at" field.
  1025  func (u *CurrencyHistoryUpsertBulk) SetUpdatedAt(v uint32) *CurrencyHistoryUpsertBulk {
  1026  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1027  		s.SetUpdatedAt(v)
  1028  	})
  1029  }
  1030  
  1031  // AddUpdatedAt adds v to the "updated_at" field.
  1032  func (u *CurrencyHistoryUpsertBulk) AddUpdatedAt(v uint32) *CurrencyHistoryUpsertBulk {
  1033  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1034  		s.AddUpdatedAt(v)
  1035  	})
  1036  }
  1037  
  1038  // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1039  func (u *CurrencyHistoryUpsertBulk) UpdateUpdatedAt() *CurrencyHistoryUpsertBulk {
  1040  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1041  		s.UpdateUpdatedAt()
  1042  	})
  1043  }
  1044  
  1045  // SetDeletedAt sets the "deleted_at" field.
  1046  func (u *CurrencyHistoryUpsertBulk) SetDeletedAt(v uint32) *CurrencyHistoryUpsertBulk {
  1047  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1048  		s.SetDeletedAt(v)
  1049  	})
  1050  }
  1051  
  1052  // AddDeletedAt adds v to the "deleted_at" field.
  1053  func (u *CurrencyHistoryUpsertBulk) AddDeletedAt(v uint32) *CurrencyHistoryUpsertBulk {
  1054  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1055  		s.AddDeletedAt(v)
  1056  	})
  1057  }
  1058  
  1059  // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1060  func (u *CurrencyHistoryUpsertBulk) UpdateDeletedAt() *CurrencyHistoryUpsertBulk {
  1061  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1062  		s.UpdateDeletedAt()
  1063  	})
  1064  }
  1065  
  1066  // SetEntID sets the "ent_id" field.
  1067  func (u *CurrencyHistoryUpsertBulk) SetEntID(v uuid.UUID) *CurrencyHistoryUpsertBulk {
  1068  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1069  		s.SetEntID(v)
  1070  	})
  1071  }
  1072  
  1073  // UpdateEntID sets the "ent_id" field to the value that was provided on create.
  1074  func (u *CurrencyHistoryUpsertBulk) UpdateEntID() *CurrencyHistoryUpsertBulk {
  1075  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1076  		s.UpdateEntID()
  1077  	})
  1078  }
  1079  
  1080  // SetCoinTypeID sets the "coin_type_id" field.
  1081  func (u *CurrencyHistoryUpsertBulk) SetCoinTypeID(v uuid.UUID) *CurrencyHistoryUpsertBulk {
  1082  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1083  		s.SetCoinTypeID(v)
  1084  	})
  1085  }
  1086  
  1087  // UpdateCoinTypeID sets the "coin_type_id" field to the value that was provided on create.
  1088  func (u *CurrencyHistoryUpsertBulk) UpdateCoinTypeID() *CurrencyHistoryUpsertBulk {
  1089  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1090  		s.UpdateCoinTypeID()
  1091  	})
  1092  }
  1093  
  1094  // ClearCoinTypeID clears the value of the "coin_type_id" field.
  1095  func (u *CurrencyHistoryUpsertBulk) ClearCoinTypeID() *CurrencyHistoryUpsertBulk {
  1096  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1097  		s.ClearCoinTypeID()
  1098  	})
  1099  }
  1100  
  1101  // SetFeedType sets the "feed_type" field.
  1102  func (u *CurrencyHistoryUpsertBulk) SetFeedType(v string) *CurrencyHistoryUpsertBulk {
  1103  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1104  		s.SetFeedType(v)
  1105  	})
  1106  }
  1107  
  1108  // UpdateFeedType sets the "feed_type" field to the value that was provided on create.
  1109  func (u *CurrencyHistoryUpsertBulk) UpdateFeedType() *CurrencyHistoryUpsertBulk {
  1110  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1111  		s.UpdateFeedType()
  1112  	})
  1113  }
  1114  
  1115  // ClearFeedType clears the value of the "feed_type" field.
  1116  func (u *CurrencyHistoryUpsertBulk) ClearFeedType() *CurrencyHistoryUpsertBulk {
  1117  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1118  		s.ClearFeedType()
  1119  	})
  1120  }
  1121  
  1122  // SetMarketValueHigh sets the "market_value_high" field.
  1123  func (u *CurrencyHistoryUpsertBulk) SetMarketValueHigh(v decimal.Decimal) *CurrencyHistoryUpsertBulk {
  1124  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1125  		s.SetMarketValueHigh(v)
  1126  	})
  1127  }
  1128  
  1129  // UpdateMarketValueHigh sets the "market_value_high" field to the value that was provided on create.
  1130  func (u *CurrencyHistoryUpsertBulk) UpdateMarketValueHigh() *CurrencyHistoryUpsertBulk {
  1131  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1132  		s.UpdateMarketValueHigh()
  1133  	})
  1134  }
  1135  
  1136  // ClearMarketValueHigh clears the value of the "market_value_high" field.
  1137  func (u *CurrencyHistoryUpsertBulk) ClearMarketValueHigh() *CurrencyHistoryUpsertBulk {
  1138  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1139  		s.ClearMarketValueHigh()
  1140  	})
  1141  }
  1142  
  1143  // SetMarketValueLow sets the "market_value_low" field.
  1144  func (u *CurrencyHistoryUpsertBulk) SetMarketValueLow(v decimal.Decimal) *CurrencyHistoryUpsertBulk {
  1145  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1146  		s.SetMarketValueLow(v)
  1147  	})
  1148  }
  1149  
  1150  // UpdateMarketValueLow sets the "market_value_low" field to the value that was provided on create.
  1151  func (u *CurrencyHistoryUpsertBulk) UpdateMarketValueLow() *CurrencyHistoryUpsertBulk {
  1152  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1153  		s.UpdateMarketValueLow()
  1154  	})
  1155  }
  1156  
  1157  // ClearMarketValueLow clears the value of the "market_value_low" field.
  1158  func (u *CurrencyHistoryUpsertBulk) ClearMarketValueLow() *CurrencyHistoryUpsertBulk {
  1159  	return u.Update(func(s *CurrencyHistoryUpsert) {
  1160  		s.ClearMarketValueLow()
  1161  	})
  1162  }
  1163  
  1164  // Exec executes the query.
  1165  func (u *CurrencyHistoryUpsertBulk) Exec(ctx context.Context) error {
  1166  	for i, b := range u.create.builders {
  1167  		if len(b.conflict) != 0 {
  1168  			return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the CurrencyHistoryCreateBulk instead", i)
  1169  		}
  1170  	}
  1171  	if len(u.create.conflict) == 0 {
  1172  		return errors.New("ent: missing options for CurrencyHistoryCreateBulk.OnConflict")
  1173  	}
  1174  	return u.create.Exec(ctx)
  1175  }
  1176  
  1177  // ExecX is like Exec, but panics if an error occurs.
  1178  func (u *CurrencyHistoryUpsertBulk) ExecX(ctx context.Context) {
  1179  	if err := u.create.Exec(ctx); err != nil {
  1180  		panic(err)
  1181  	}
  1182  }