github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/currency_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/currency"
    14  	"github.com/google/uuid"
    15  	"github.com/shopspring/decimal"
    16  )
    17  
    18  // CurrencyCreate is the builder for creating a Currency entity.
    19  type CurrencyCreate struct {
    20  	config
    21  	mutation *CurrencyMutation
    22  	hooks    []Hook
    23  	conflict []sql.ConflictOption
    24  }
    25  
    26  // SetCreatedAt sets the "created_at" field.
    27  func (cc *CurrencyCreate) SetCreatedAt(u uint32) *CurrencyCreate {
    28  	cc.mutation.SetCreatedAt(u)
    29  	return cc
    30  }
    31  
    32  // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
    33  func (cc *CurrencyCreate) SetNillableCreatedAt(u *uint32) *CurrencyCreate {
    34  	if u != nil {
    35  		cc.SetCreatedAt(*u)
    36  	}
    37  	return cc
    38  }
    39  
    40  // SetUpdatedAt sets the "updated_at" field.
    41  func (cc *CurrencyCreate) SetUpdatedAt(u uint32) *CurrencyCreate {
    42  	cc.mutation.SetUpdatedAt(u)
    43  	return cc
    44  }
    45  
    46  // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
    47  func (cc *CurrencyCreate) SetNillableUpdatedAt(u *uint32) *CurrencyCreate {
    48  	if u != nil {
    49  		cc.SetUpdatedAt(*u)
    50  	}
    51  	return cc
    52  }
    53  
    54  // SetDeletedAt sets the "deleted_at" field.
    55  func (cc *CurrencyCreate) SetDeletedAt(u uint32) *CurrencyCreate {
    56  	cc.mutation.SetDeletedAt(u)
    57  	return cc
    58  }
    59  
    60  // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
    61  func (cc *CurrencyCreate) SetNillableDeletedAt(u *uint32) *CurrencyCreate {
    62  	if u != nil {
    63  		cc.SetDeletedAt(*u)
    64  	}
    65  	return cc
    66  }
    67  
    68  // SetEntID sets the "ent_id" field.
    69  func (cc *CurrencyCreate) SetEntID(u uuid.UUID) *CurrencyCreate {
    70  	cc.mutation.SetEntID(u)
    71  	return cc
    72  }
    73  
    74  // SetNillableEntID sets the "ent_id" field if the given value is not nil.
    75  func (cc *CurrencyCreate) SetNillableEntID(u *uuid.UUID) *CurrencyCreate {
    76  	if u != nil {
    77  		cc.SetEntID(*u)
    78  	}
    79  	return cc
    80  }
    81  
    82  // SetCoinTypeID sets the "coin_type_id" field.
    83  func (cc *CurrencyCreate) SetCoinTypeID(u uuid.UUID) *CurrencyCreate {
    84  	cc.mutation.SetCoinTypeID(u)
    85  	return cc
    86  }
    87  
    88  // SetNillableCoinTypeID sets the "coin_type_id" field if the given value is not nil.
    89  func (cc *CurrencyCreate) SetNillableCoinTypeID(u *uuid.UUID) *CurrencyCreate {
    90  	if u != nil {
    91  		cc.SetCoinTypeID(*u)
    92  	}
    93  	return cc
    94  }
    95  
    96  // SetFeedType sets the "feed_type" field.
    97  func (cc *CurrencyCreate) SetFeedType(s string) *CurrencyCreate {
    98  	cc.mutation.SetFeedType(s)
    99  	return cc
   100  }
   101  
   102  // SetNillableFeedType sets the "feed_type" field if the given value is not nil.
   103  func (cc *CurrencyCreate) SetNillableFeedType(s *string) *CurrencyCreate {
   104  	if s != nil {
   105  		cc.SetFeedType(*s)
   106  	}
   107  	return cc
   108  }
   109  
   110  // SetMarketValueHigh sets the "market_value_high" field.
   111  func (cc *CurrencyCreate) SetMarketValueHigh(d decimal.Decimal) *CurrencyCreate {
   112  	cc.mutation.SetMarketValueHigh(d)
   113  	return cc
   114  }
   115  
   116  // SetNillableMarketValueHigh sets the "market_value_high" field if the given value is not nil.
   117  func (cc *CurrencyCreate) SetNillableMarketValueHigh(d *decimal.Decimal) *CurrencyCreate {
   118  	if d != nil {
   119  		cc.SetMarketValueHigh(*d)
   120  	}
   121  	return cc
   122  }
   123  
   124  // SetMarketValueLow sets the "market_value_low" field.
   125  func (cc *CurrencyCreate) SetMarketValueLow(d decimal.Decimal) *CurrencyCreate {
   126  	cc.mutation.SetMarketValueLow(d)
   127  	return cc
   128  }
   129  
   130  // SetNillableMarketValueLow sets the "market_value_low" field if the given value is not nil.
   131  func (cc *CurrencyCreate) SetNillableMarketValueLow(d *decimal.Decimal) *CurrencyCreate {
   132  	if d != nil {
   133  		cc.SetMarketValueLow(*d)
   134  	}
   135  	return cc
   136  }
   137  
   138  // SetID sets the "id" field.
   139  func (cc *CurrencyCreate) SetID(u uint32) *CurrencyCreate {
   140  	cc.mutation.SetID(u)
   141  	return cc
   142  }
   143  
   144  // Mutation returns the CurrencyMutation object of the builder.
   145  func (cc *CurrencyCreate) Mutation() *CurrencyMutation {
   146  	return cc.mutation
   147  }
   148  
   149  // Save creates the Currency in the database.
   150  func (cc *CurrencyCreate) Save(ctx context.Context) (*Currency, error) {
   151  	var (
   152  		err  error
   153  		node *Currency
   154  	)
   155  	if err := cc.defaults(); err != nil {
   156  		return nil, err
   157  	}
   158  	if len(cc.hooks) == 0 {
   159  		if err = cc.check(); err != nil {
   160  			return nil, err
   161  		}
   162  		node, err = cc.sqlSave(ctx)
   163  	} else {
   164  		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
   165  			mutation, ok := m.(*CurrencyMutation)
   166  			if !ok {
   167  				return nil, fmt.Errorf("unexpected mutation type %T", m)
   168  			}
   169  			if err = cc.check(); err != nil {
   170  				return nil, err
   171  			}
   172  			cc.mutation = mutation
   173  			if node, err = cc.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(cc.hooks) - 1; i >= 0; i-- {
   181  			if cc.hooks[i] == nil {
   182  				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
   183  			}
   184  			mut = cc.hooks[i](mut)
   185  		}
   186  		v, err := mut.Mutate(ctx, cc.mutation)
   187  		if err != nil {
   188  			return nil, err
   189  		}
   190  		nv, ok := v.(*Currency)
   191  		if !ok {
   192  			return nil, fmt.Errorf("unexpected node type %T returned from CurrencyMutation", 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 (cc *CurrencyCreate) SaveX(ctx context.Context) *Currency {
   201  	v, err := cc.Save(ctx)
   202  	if err != nil {
   203  		panic(err)
   204  	}
   205  	return v
   206  }
   207  
   208  // Exec executes the query.
   209  func (cc *CurrencyCreate) Exec(ctx context.Context) error {
   210  	_, err := cc.Save(ctx)
   211  	return err
   212  }
   213  
   214  // ExecX is like Exec, but panics if an error occurs.
   215  func (cc *CurrencyCreate) ExecX(ctx context.Context) {
   216  	if err := cc.Exec(ctx); err != nil {
   217  		panic(err)
   218  	}
   219  }
   220  
   221  // defaults sets the default values of the builder before save.
   222  func (cc *CurrencyCreate) defaults() error {
   223  	if _, ok := cc.mutation.CreatedAt(); !ok {
   224  		if currency.DefaultCreatedAt == nil {
   225  			return fmt.Errorf("ent: uninitialized currency.DefaultCreatedAt (forgotten import ent/runtime?)")
   226  		}
   227  		v := currency.DefaultCreatedAt()
   228  		cc.mutation.SetCreatedAt(v)
   229  	}
   230  	if _, ok := cc.mutation.UpdatedAt(); !ok {
   231  		if currency.DefaultUpdatedAt == nil {
   232  			return fmt.Errorf("ent: uninitialized currency.DefaultUpdatedAt (forgotten import ent/runtime?)")
   233  		}
   234  		v := currency.DefaultUpdatedAt()
   235  		cc.mutation.SetUpdatedAt(v)
   236  	}
   237  	if _, ok := cc.mutation.DeletedAt(); !ok {
   238  		if currency.DefaultDeletedAt == nil {
   239  			return fmt.Errorf("ent: uninitialized currency.DefaultDeletedAt (forgotten import ent/runtime?)")
   240  		}
   241  		v := currency.DefaultDeletedAt()
   242  		cc.mutation.SetDeletedAt(v)
   243  	}
   244  	if _, ok := cc.mutation.EntID(); !ok {
   245  		if currency.DefaultEntID == nil {
   246  			return fmt.Errorf("ent: uninitialized currency.DefaultEntID (forgotten import ent/runtime?)")
   247  		}
   248  		v := currency.DefaultEntID()
   249  		cc.mutation.SetEntID(v)
   250  	}
   251  	if _, ok := cc.mutation.CoinTypeID(); !ok {
   252  		if currency.DefaultCoinTypeID == nil {
   253  			return fmt.Errorf("ent: uninitialized currency.DefaultCoinTypeID (forgotten import ent/runtime?)")
   254  		}
   255  		v := currency.DefaultCoinTypeID()
   256  		cc.mutation.SetCoinTypeID(v)
   257  	}
   258  	if _, ok := cc.mutation.FeedType(); !ok {
   259  		v := currency.DefaultFeedType
   260  		cc.mutation.SetFeedType(v)
   261  	}
   262  	if _, ok := cc.mutation.MarketValueHigh(); !ok {
   263  		v := currency.DefaultMarketValueHigh
   264  		cc.mutation.SetMarketValueHigh(v)
   265  	}
   266  	if _, ok := cc.mutation.MarketValueLow(); !ok {
   267  		v := currency.DefaultMarketValueLow
   268  		cc.mutation.SetMarketValueLow(v)
   269  	}
   270  	return nil
   271  }
   272  
   273  // check runs all checks and user-defined validators on the builder.
   274  func (cc *CurrencyCreate) check() error {
   275  	if _, ok := cc.mutation.CreatedAt(); !ok {
   276  		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Currency.created_at"`)}
   277  	}
   278  	if _, ok := cc.mutation.UpdatedAt(); !ok {
   279  		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Currency.updated_at"`)}
   280  	}
   281  	if _, ok := cc.mutation.DeletedAt(); !ok {
   282  		return &ValidationError{Name: "deleted_at", err: errors.New(`ent: missing required field "Currency.deleted_at"`)}
   283  	}
   284  	if _, ok := cc.mutation.EntID(); !ok {
   285  		return &ValidationError{Name: "ent_id", err: errors.New(`ent: missing required field "Currency.ent_id"`)}
   286  	}
   287  	return nil
   288  }
   289  
   290  func (cc *CurrencyCreate) sqlSave(ctx context.Context) (*Currency, error) {
   291  	_node, _spec := cc.createSpec()
   292  	if err := sqlgraph.CreateNode(ctx, cc.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 (cc *CurrencyCreate) createSpec() (*Currency, *sqlgraph.CreateSpec) {
   306  	var (
   307  		_node = &Currency{config: cc.config}
   308  		_spec = &sqlgraph.CreateSpec{
   309  			Table: currency.Table,
   310  			ID: &sqlgraph.FieldSpec{
   311  				Type:   field.TypeUint32,
   312  				Column: currency.FieldID,
   313  			},
   314  		}
   315  	)
   316  	_spec.OnConflict = cc.conflict
   317  	if id, ok := cc.mutation.ID(); ok {
   318  		_node.ID = id
   319  		_spec.ID.Value = id
   320  	}
   321  	if value, ok := cc.mutation.CreatedAt(); ok {
   322  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   323  			Type:   field.TypeUint32,
   324  			Value:  value,
   325  			Column: currency.FieldCreatedAt,
   326  		})
   327  		_node.CreatedAt = value
   328  	}
   329  	if value, ok := cc.mutation.UpdatedAt(); ok {
   330  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   331  			Type:   field.TypeUint32,
   332  			Value:  value,
   333  			Column: currency.FieldUpdatedAt,
   334  		})
   335  		_node.UpdatedAt = value
   336  	}
   337  	if value, ok := cc.mutation.DeletedAt(); ok {
   338  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   339  			Type:   field.TypeUint32,
   340  			Value:  value,
   341  			Column: currency.FieldDeletedAt,
   342  		})
   343  		_node.DeletedAt = value
   344  	}
   345  	if value, ok := cc.mutation.EntID(); ok {
   346  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   347  			Type:   field.TypeUUID,
   348  			Value:  value,
   349  			Column: currency.FieldEntID,
   350  		})
   351  		_node.EntID = value
   352  	}
   353  	if value, ok := cc.mutation.CoinTypeID(); ok {
   354  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   355  			Type:   field.TypeUUID,
   356  			Value:  value,
   357  			Column: currency.FieldCoinTypeID,
   358  		})
   359  		_node.CoinTypeID = value
   360  	}
   361  	if value, ok := cc.mutation.FeedType(); ok {
   362  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   363  			Type:   field.TypeString,
   364  			Value:  value,
   365  			Column: currency.FieldFeedType,
   366  		})
   367  		_node.FeedType = value
   368  	}
   369  	if value, ok := cc.mutation.MarketValueHigh(); ok {
   370  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   371  			Type:   field.TypeOther,
   372  			Value:  value,
   373  			Column: currency.FieldMarketValueHigh,
   374  		})
   375  		_node.MarketValueHigh = value
   376  	}
   377  	if value, ok := cc.mutation.MarketValueLow(); ok {
   378  		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
   379  			Type:   field.TypeOther,
   380  			Value:  value,
   381  			Column: currency.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.Currency.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.CurrencyUpsert) {
   401  //			SetCreatedAt(v+v).
   402  //		}).
   403  //		Exec(ctx)
   404  //
   405  func (cc *CurrencyCreate) OnConflict(opts ...sql.ConflictOption) *CurrencyUpsertOne {
   406  	cc.conflict = opts
   407  	return &CurrencyUpsertOne{
   408  		create: cc,
   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.Currency.Create().
   416  //		OnConflict(sql.ConflictColumns(columns...)).
   417  //		Exec(ctx)
   418  //
   419  func (cc *CurrencyCreate) OnConflictColumns(columns ...string) *CurrencyUpsertOne {
   420  	cc.conflict = append(cc.conflict, sql.ConflictColumns(columns...))
   421  	return &CurrencyUpsertOne{
   422  		create: cc,
   423  	}
   424  }
   425  
   426  type (
   427  	// CurrencyUpsertOne is the builder for "upsert"-ing
   428  	//  one Currency node.
   429  	CurrencyUpsertOne struct {
   430  		create *CurrencyCreate
   431  	}
   432  
   433  	// CurrencyUpsert is the "OnConflict" setter.
   434  	CurrencyUpsert struct {
   435  		*sql.UpdateSet
   436  	}
   437  )
   438  
   439  // SetCreatedAt sets the "created_at" field.
   440  func (u *CurrencyUpsert) SetCreatedAt(v uint32) *CurrencyUpsert {
   441  	u.Set(currency.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 *CurrencyUpsert) UpdateCreatedAt() *CurrencyUpsert {
   447  	u.SetExcluded(currency.FieldCreatedAt)
   448  	return u
   449  }
   450  
   451  // AddCreatedAt adds v to the "created_at" field.
   452  func (u *CurrencyUpsert) AddCreatedAt(v uint32) *CurrencyUpsert {
   453  	u.Add(currency.FieldCreatedAt, v)
   454  	return u
   455  }
   456  
   457  // SetUpdatedAt sets the "updated_at" field.
   458  func (u *CurrencyUpsert) SetUpdatedAt(v uint32) *CurrencyUpsert {
   459  	u.Set(currency.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 *CurrencyUpsert) UpdateUpdatedAt() *CurrencyUpsert {
   465  	u.SetExcluded(currency.FieldUpdatedAt)
   466  	return u
   467  }
   468  
   469  // AddUpdatedAt adds v to the "updated_at" field.
   470  func (u *CurrencyUpsert) AddUpdatedAt(v uint32) *CurrencyUpsert {
   471  	u.Add(currency.FieldUpdatedAt, v)
   472  	return u
   473  }
   474  
   475  // SetDeletedAt sets the "deleted_at" field.
   476  func (u *CurrencyUpsert) SetDeletedAt(v uint32) *CurrencyUpsert {
   477  	u.Set(currency.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 *CurrencyUpsert) UpdateDeletedAt() *CurrencyUpsert {
   483  	u.SetExcluded(currency.FieldDeletedAt)
   484  	return u
   485  }
   486  
   487  // AddDeletedAt adds v to the "deleted_at" field.
   488  func (u *CurrencyUpsert) AddDeletedAt(v uint32) *CurrencyUpsert {
   489  	u.Add(currency.FieldDeletedAt, v)
   490  	return u
   491  }
   492  
   493  // SetEntID sets the "ent_id" field.
   494  func (u *CurrencyUpsert) SetEntID(v uuid.UUID) *CurrencyUpsert {
   495  	u.Set(currency.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 *CurrencyUpsert) UpdateEntID() *CurrencyUpsert {
   501  	u.SetExcluded(currency.FieldEntID)
   502  	return u
   503  }
   504  
   505  // SetCoinTypeID sets the "coin_type_id" field.
   506  func (u *CurrencyUpsert) SetCoinTypeID(v uuid.UUID) *CurrencyUpsert {
   507  	u.Set(currency.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 *CurrencyUpsert) UpdateCoinTypeID() *CurrencyUpsert {
   513  	u.SetExcluded(currency.FieldCoinTypeID)
   514  	return u
   515  }
   516  
   517  // ClearCoinTypeID clears the value of the "coin_type_id" field.
   518  func (u *CurrencyUpsert) ClearCoinTypeID() *CurrencyUpsert {
   519  	u.SetNull(currency.FieldCoinTypeID)
   520  	return u
   521  }
   522  
   523  // SetFeedType sets the "feed_type" field.
   524  func (u *CurrencyUpsert) SetFeedType(v string) *CurrencyUpsert {
   525  	u.Set(currency.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 *CurrencyUpsert) UpdateFeedType() *CurrencyUpsert {
   531  	u.SetExcluded(currency.FieldFeedType)
   532  	return u
   533  }
   534  
   535  // ClearFeedType clears the value of the "feed_type" field.
   536  func (u *CurrencyUpsert) ClearFeedType() *CurrencyUpsert {
   537  	u.SetNull(currency.FieldFeedType)
   538  	return u
   539  }
   540  
   541  // SetMarketValueHigh sets the "market_value_high" field.
   542  func (u *CurrencyUpsert) SetMarketValueHigh(v decimal.Decimal) *CurrencyUpsert {
   543  	u.Set(currency.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 *CurrencyUpsert) UpdateMarketValueHigh() *CurrencyUpsert {
   549  	u.SetExcluded(currency.FieldMarketValueHigh)
   550  	return u
   551  }
   552  
   553  // ClearMarketValueHigh clears the value of the "market_value_high" field.
   554  func (u *CurrencyUpsert) ClearMarketValueHigh() *CurrencyUpsert {
   555  	u.SetNull(currency.FieldMarketValueHigh)
   556  	return u
   557  }
   558  
   559  // SetMarketValueLow sets the "market_value_low" field.
   560  func (u *CurrencyUpsert) SetMarketValueLow(v decimal.Decimal) *CurrencyUpsert {
   561  	u.Set(currency.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 *CurrencyUpsert) UpdateMarketValueLow() *CurrencyUpsert {
   567  	u.SetExcluded(currency.FieldMarketValueLow)
   568  	return u
   569  }
   570  
   571  // ClearMarketValueLow clears the value of the "market_value_low" field.
   572  func (u *CurrencyUpsert) ClearMarketValueLow() *CurrencyUpsert {
   573  	u.SetNull(currency.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.Currency.Create().
   581  //		OnConflict(
   582  //			sql.ResolveWithNewValues(),
   583  //			sql.ResolveWith(func(u *sql.UpdateSet) {
   584  //				u.SetIgnore(currency.FieldID)
   585  //			}),
   586  //		).
   587  //		Exec(ctx)
   588  //
   589  func (u *CurrencyUpsertOne) UpdateNewValues() *CurrencyUpsertOne {
   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(currency.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.Currency.Create().
   603  //      OnConflict(sql.ResolveWithIgnore()).
   604  //      Exec(ctx)
   605  //
   606  func (u *CurrencyUpsertOne) Ignore() *CurrencyUpsertOne {
   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 *CurrencyUpsertOne) DoNothing() *CurrencyUpsertOne {
   614  	u.create.conflict = append(u.create.conflict, sql.DoNothing())
   615  	return u
   616  }
   617  
   618  // Update allows overriding fields `UPDATE` values. See the CurrencyCreate.OnConflict
   619  // documentation for more info.
   620  func (u *CurrencyUpsertOne) Update(set func(*CurrencyUpsert)) *CurrencyUpsertOne {
   621  	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
   622  		set(&CurrencyUpsert{UpdateSet: update})
   623  	}))
   624  	return u
   625  }
   626  
   627  // SetCreatedAt sets the "created_at" field.
   628  func (u *CurrencyUpsertOne) SetCreatedAt(v uint32) *CurrencyUpsertOne {
   629  	return u.Update(func(s *CurrencyUpsert) {
   630  		s.SetCreatedAt(v)
   631  	})
   632  }
   633  
   634  // AddCreatedAt adds v to the "created_at" field.
   635  func (u *CurrencyUpsertOne) AddCreatedAt(v uint32) *CurrencyUpsertOne {
   636  	return u.Update(func(s *CurrencyUpsert) {
   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 *CurrencyUpsertOne) UpdateCreatedAt() *CurrencyUpsertOne {
   643  	return u.Update(func(s *CurrencyUpsert) {
   644  		s.UpdateCreatedAt()
   645  	})
   646  }
   647  
   648  // SetUpdatedAt sets the "updated_at" field.
   649  func (u *CurrencyUpsertOne) SetUpdatedAt(v uint32) *CurrencyUpsertOne {
   650  	return u.Update(func(s *CurrencyUpsert) {
   651  		s.SetUpdatedAt(v)
   652  	})
   653  }
   654  
   655  // AddUpdatedAt adds v to the "updated_at" field.
   656  func (u *CurrencyUpsertOne) AddUpdatedAt(v uint32) *CurrencyUpsertOne {
   657  	return u.Update(func(s *CurrencyUpsert) {
   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 *CurrencyUpsertOne) UpdateUpdatedAt() *CurrencyUpsertOne {
   664  	return u.Update(func(s *CurrencyUpsert) {
   665  		s.UpdateUpdatedAt()
   666  	})
   667  }
   668  
   669  // SetDeletedAt sets the "deleted_at" field.
   670  func (u *CurrencyUpsertOne) SetDeletedAt(v uint32) *CurrencyUpsertOne {
   671  	return u.Update(func(s *CurrencyUpsert) {
   672  		s.SetDeletedAt(v)
   673  	})
   674  }
   675  
   676  // AddDeletedAt adds v to the "deleted_at" field.
   677  func (u *CurrencyUpsertOne) AddDeletedAt(v uint32) *CurrencyUpsertOne {
   678  	return u.Update(func(s *CurrencyUpsert) {
   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 *CurrencyUpsertOne) UpdateDeletedAt() *CurrencyUpsertOne {
   685  	return u.Update(func(s *CurrencyUpsert) {
   686  		s.UpdateDeletedAt()
   687  	})
   688  }
   689  
   690  // SetEntID sets the "ent_id" field.
   691  func (u *CurrencyUpsertOne) SetEntID(v uuid.UUID) *CurrencyUpsertOne {
   692  	return u.Update(func(s *CurrencyUpsert) {
   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 *CurrencyUpsertOne) UpdateEntID() *CurrencyUpsertOne {
   699  	return u.Update(func(s *CurrencyUpsert) {
   700  		s.UpdateEntID()
   701  	})
   702  }
   703  
   704  // SetCoinTypeID sets the "coin_type_id" field.
   705  func (u *CurrencyUpsertOne) SetCoinTypeID(v uuid.UUID) *CurrencyUpsertOne {
   706  	return u.Update(func(s *CurrencyUpsert) {
   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 *CurrencyUpsertOne) UpdateCoinTypeID() *CurrencyUpsertOne {
   713  	return u.Update(func(s *CurrencyUpsert) {
   714  		s.UpdateCoinTypeID()
   715  	})
   716  }
   717  
   718  // ClearCoinTypeID clears the value of the "coin_type_id" field.
   719  func (u *CurrencyUpsertOne) ClearCoinTypeID() *CurrencyUpsertOne {
   720  	return u.Update(func(s *CurrencyUpsert) {
   721  		s.ClearCoinTypeID()
   722  	})
   723  }
   724  
   725  // SetFeedType sets the "feed_type" field.
   726  func (u *CurrencyUpsertOne) SetFeedType(v string) *CurrencyUpsertOne {
   727  	return u.Update(func(s *CurrencyUpsert) {
   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 *CurrencyUpsertOne) UpdateFeedType() *CurrencyUpsertOne {
   734  	return u.Update(func(s *CurrencyUpsert) {
   735  		s.UpdateFeedType()
   736  	})
   737  }
   738  
   739  // ClearFeedType clears the value of the "feed_type" field.
   740  func (u *CurrencyUpsertOne) ClearFeedType() *CurrencyUpsertOne {
   741  	return u.Update(func(s *CurrencyUpsert) {
   742  		s.ClearFeedType()
   743  	})
   744  }
   745  
   746  // SetMarketValueHigh sets the "market_value_high" field.
   747  func (u *CurrencyUpsertOne) SetMarketValueHigh(v decimal.Decimal) *CurrencyUpsertOne {
   748  	return u.Update(func(s *CurrencyUpsert) {
   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 *CurrencyUpsertOne) UpdateMarketValueHigh() *CurrencyUpsertOne {
   755  	return u.Update(func(s *CurrencyUpsert) {
   756  		s.UpdateMarketValueHigh()
   757  	})
   758  }
   759  
   760  // ClearMarketValueHigh clears the value of the "market_value_high" field.
   761  func (u *CurrencyUpsertOne) ClearMarketValueHigh() *CurrencyUpsertOne {
   762  	return u.Update(func(s *CurrencyUpsert) {
   763  		s.ClearMarketValueHigh()
   764  	})
   765  }
   766  
   767  // SetMarketValueLow sets the "market_value_low" field.
   768  func (u *CurrencyUpsertOne) SetMarketValueLow(v decimal.Decimal) *CurrencyUpsertOne {
   769  	return u.Update(func(s *CurrencyUpsert) {
   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 *CurrencyUpsertOne) UpdateMarketValueLow() *CurrencyUpsertOne {
   776  	return u.Update(func(s *CurrencyUpsert) {
   777  		s.UpdateMarketValueLow()
   778  	})
   779  }
   780  
   781  // ClearMarketValueLow clears the value of the "market_value_low" field.
   782  func (u *CurrencyUpsertOne) ClearMarketValueLow() *CurrencyUpsertOne {
   783  	return u.Update(func(s *CurrencyUpsert) {
   784  		s.ClearMarketValueLow()
   785  	})
   786  }
   787  
   788  // Exec executes the query.
   789  func (u *CurrencyUpsertOne) Exec(ctx context.Context) error {
   790  	if len(u.create.conflict) == 0 {
   791  		return errors.New("ent: missing options for CurrencyCreate.OnConflict")
   792  	}
   793  	return u.create.Exec(ctx)
   794  }
   795  
   796  // ExecX is like Exec, but panics if an error occurs.
   797  func (u *CurrencyUpsertOne) 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 *CurrencyUpsertOne) 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 *CurrencyUpsertOne) 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  // CurrencyCreateBulk is the builder for creating many Currency entities in bulk.
   822  type CurrencyCreateBulk struct {
   823  	config
   824  	builders []*CurrencyCreate
   825  	conflict []sql.ConflictOption
   826  }
   827  
   828  // Save creates the Currency entities in the database.
   829  func (ccb *CurrencyCreateBulk) Save(ctx context.Context) ([]*Currency, error) {
   830  	specs := make([]*sqlgraph.CreateSpec, len(ccb.builders))
   831  	nodes := make([]*Currency, len(ccb.builders))
   832  	mutators := make([]Mutator, len(ccb.builders))
   833  	for i := range ccb.builders {
   834  		func(i int, root context.Context) {
   835  			builder := ccb.builders[i]
   836  			builder.defaults()
   837  			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
   838  				mutation, ok := m.(*CurrencyMutation)
   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, ccb.builders[i+1].mutation)
   850  				} else {
   851  					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
   852  					spec.OnConflict = ccb.conflict
   853  					// Invoke the actual operation on the latest mutation in the chain.
   854  					if err = sqlgraph.BatchCreate(ctx, ccb.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, ccb.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 (ccb *CurrencyCreateBulk) SaveX(ctx context.Context) []*Currency {
   887  	v, err := ccb.Save(ctx)
   888  	if err != nil {
   889  		panic(err)
   890  	}
   891  	return v
   892  }
   893  
   894  // Exec executes the query.
   895  func (ccb *CurrencyCreateBulk) Exec(ctx context.Context) error {
   896  	_, err := ccb.Save(ctx)
   897  	return err
   898  }
   899  
   900  // ExecX is like Exec, but panics if an error occurs.
   901  func (ccb *CurrencyCreateBulk) ExecX(ctx context.Context) {
   902  	if err := ccb.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.Currency.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.CurrencyUpsert) {
   919  //			SetCreatedAt(v+v).
   920  //		}).
   921  //		Exec(ctx)
   922  //
   923  func (ccb *CurrencyCreateBulk) OnConflict(opts ...sql.ConflictOption) *CurrencyUpsertBulk {
   924  	ccb.conflict = opts
   925  	return &CurrencyUpsertBulk{
   926  		create: ccb,
   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.Currency.Create().
   934  //		OnConflict(sql.ConflictColumns(columns...)).
   935  //		Exec(ctx)
   936  //
   937  func (ccb *CurrencyCreateBulk) OnConflictColumns(columns ...string) *CurrencyUpsertBulk {
   938  	ccb.conflict = append(ccb.conflict, sql.ConflictColumns(columns...))
   939  	return &CurrencyUpsertBulk{
   940  		create: ccb,
   941  	}
   942  }
   943  
   944  // CurrencyUpsertBulk is the builder for "upsert"-ing
   945  // a bulk of Currency nodes.
   946  type CurrencyUpsertBulk struct {
   947  	create *CurrencyCreateBulk
   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.Currency.Create().
   954  //		OnConflict(
   955  //			sql.ResolveWithNewValues(),
   956  //			sql.ResolveWith(func(u *sql.UpdateSet) {
   957  //				u.SetIgnore(currency.FieldID)
   958  //			}),
   959  //		).
   960  //		Exec(ctx)
   961  //
   962  func (u *CurrencyUpsertBulk) UpdateNewValues() *CurrencyUpsertBulk {
   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(currency.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.Currency.Create().
   979  //		OnConflict(sql.ResolveWithIgnore()).
   980  //		Exec(ctx)
   981  //
   982  func (u *CurrencyUpsertBulk) Ignore() *CurrencyUpsertBulk {
   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 *CurrencyUpsertBulk) DoNothing() *CurrencyUpsertBulk {
   990  	u.create.conflict = append(u.create.conflict, sql.DoNothing())
   991  	return u
   992  }
   993  
   994  // Update allows overriding fields `UPDATE` values. See the CurrencyCreateBulk.OnConflict
   995  // documentation for more info.
   996  func (u *CurrencyUpsertBulk) Update(set func(*CurrencyUpsert)) *CurrencyUpsertBulk {
   997  	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
   998  		set(&CurrencyUpsert{UpdateSet: update})
   999  	}))
  1000  	return u
  1001  }
  1002  
  1003  // SetCreatedAt sets the "created_at" field.
  1004  func (u *CurrencyUpsertBulk) SetCreatedAt(v uint32) *CurrencyUpsertBulk {
  1005  	return u.Update(func(s *CurrencyUpsert) {
  1006  		s.SetCreatedAt(v)
  1007  	})
  1008  }
  1009  
  1010  // AddCreatedAt adds v to the "created_at" field.
  1011  func (u *CurrencyUpsertBulk) AddCreatedAt(v uint32) *CurrencyUpsertBulk {
  1012  	return u.Update(func(s *CurrencyUpsert) {
  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 *CurrencyUpsertBulk) UpdateCreatedAt() *CurrencyUpsertBulk {
  1019  	return u.Update(func(s *CurrencyUpsert) {
  1020  		s.UpdateCreatedAt()
  1021  	})
  1022  }
  1023  
  1024  // SetUpdatedAt sets the "updated_at" field.
  1025  func (u *CurrencyUpsertBulk) SetUpdatedAt(v uint32) *CurrencyUpsertBulk {
  1026  	return u.Update(func(s *CurrencyUpsert) {
  1027  		s.SetUpdatedAt(v)
  1028  	})
  1029  }
  1030  
  1031  // AddUpdatedAt adds v to the "updated_at" field.
  1032  func (u *CurrencyUpsertBulk) AddUpdatedAt(v uint32) *CurrencyUpsertBulk {
  1033  	return u.Update(func(s *CurrencyUpsert) {
  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 *CurrencyUpsertBulk) UpdateUpdatedAt() *CurrencyUpsertBulk {
  1040  	return u.Update(func(s *CurrencyUpsert) {
  1041  		s.UpdateUpdatedAt()
  1042  	})
  1043  }
  1044  
  1045  // SetDeletedAt sets the "deleted_at" field.
  1046  func (u *CurrencyUpsertBulk) SetDeletedAt(v uint32) *CurrencyUpsertBulk {
  1047  	return u.Update(func(s *CurrencyUpsert) {
  1048  		s.SetDeletedAt(v)
  1049  	})
  1050  }
  1051  
  1052  // AddDeletedAt adds v to the "deleted_at" field.
  1053  func (u *CurrencyUpsertBulk) AddDeletedAt(v uint32) *CurrencyUpsertBulk {
  1054  	return u.Update(func(s *CurrencyUpsert) {
  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 *CurrencyUpsertBulk) UpdateDeletedAt() *CurrencyUpsertBulk {
  1061  	return u.Update(func(s *CurrencyUpsert) {
  1062  		s.UpdateDeletedAt()
  1063  	})
  1064  }
  1065  
  1066  // SetEntID sets the "ent_id" field.
  1067  func (u *CurrencyUpsertBulk) SetEntID(v uuid.UUID) *CurrencyUpsertBulk {
  1068  	return u.Update(func(s *CurrencyUpsert) {
  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 *CurrencyUpsertBulk) UpdateEntID() *CurrencyUpsertBulk {
  1075  	return u.Update(func(s *CurrencyUpsert) {
  1076  		s.UpdateEntID()
  1077  	})
  1078  }
  1079  
  1080  // SetCoinTypeID sets the "coin_type_id" field.
  1081  func (u *CurrencyUpsertBulk) SetCoinTypeID(v uuid.UUID) *CurrencyUpsertBulk {
  1082  	return u.Update(func(s *CurrencyUpsert) {
  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 *CurrencyUpsertBulk) UpdateCoinTypeID() *CurrencyUpsertBulk {
  1089  	return u.Update(func(s *CurrencyUpsert) {
  1090  		s.UpdateCoinTypeID()
  1091  	})
  1092  }
  1093  
  1094  // ClearCoinTypeID clears the value of the "coin_type_id" field.
  1095  func (u *CurrencyUpsertBulk) ClearCoinTypeID() *CurrencyUpsertBulk {
  1096  	return u.Update(func(s *CurrencyUpsert) {
  1097  		s.ClearCoinTypeID()
  1098  	})
  1099  }
  1100  
  1101  // SetFeedType sets the "feed_type" field.
  1102  func (u *CurrencyUpsertBulk) SetFeedType(v string) *CurrencyUpsertBulk {
  1103  	return u.Update(func(s *CurrencyUpsert) {
  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 *CurrencyUpsertBulk) UpdateFeedType() *CurrencyUpsertBulk {
  1110  	return u.Update(func(s *CurrencyUpsert) {
  1111  		s.UpdateFeedType()
  1112  	})
  1113  }
  1114  
  1115  // ClearFeedType clears the value of the "feed_type" field.
  1116  func (u *CurrencyUpsertBulk) ClearFeedType() *CurrencyUpsertBulk {
  1117  	return u.Update(func(s *CurrencyUpsert) {
  1118  		s.ClearFeedType()
  1119  	})
  1120  }
  1121  
  1122  // SetMarketValueHigh sets the "market_value_high" field.
  1123  func (u *CurrencyUpsertBulk) SetMarketValueHigh(v decimal.Decimal) *CurrencyUpsertBulk {
  1124  	return u.Update(func(s *CurrencyUpsert) {
  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 *CurrencyUpsertBulk) UpdateMarketValueHigh() *CurrencyUpsertBulk {
  1131  	return u.Update(func(s *CurrencyUpsert) {
  1132  		s.UpdateMarketValueHigh()
  1133  	})
  1134  }
  1135  
  1136  // ClearMarketValueHigh clears the value of the "market_value_high" field.
  1137  func (u *CurrencyUpsertBulk) ClearMarketValueHigh() *CurrencyUpsertBulk {
  1138  	return u.Update(func(s *CurrencyUpsert) {
  1139  		s.ClearMarketValueHigh()
  1140  	})
  1141  }
  1142  
  1143  // SetMarketValueLow sets the "market_value_low" field.
  1144  func (u *CurrencyUpsertBulk) SetMarketValueLow(v decimal.Decimal) *CurrencyUpsertBulk {
  1145  	return u.Update(func(s *CurrencyUpsert) {
  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 *CurrencyUpsertBulk) UpdateMarketValueLow() *CurrencyUpsertBulk {
  1152  	return u.Update(func(s *CurrencyUpsert) {
  1153  		s.UpdateMarketValueLow()
  1154  	})
  1155  }
  1156  
  1157  // ClearMarketValueLow clears the value of the "market_value_low" field.
  1158  func (u *CurrencyUpsertBulk) ClearMarketValueLow() *CurrencyUpsertBulk {
  1159  	return u.Update(func(s *CurrencyUpsert) {
  1160  		s.ClearMarketValueLow()
  1161  	})
  1162  }
  1163  
  1164  // Exec executes the query.
  1165  func (u *CurrencyUpsertBulk) 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 CurrencyCreateBulk instead", i)
  1169  		}
  1170  	}
  1171  	if len(u.create.conflict) == 0 {
  1172  		return errors.New("ent: missing options for CurrencyCreateBulk.OnConflict")
  1173  	}
  1174  	return u.create.Exec(ctx)
  1175  }
  1176  
  1177  // ExecX is like Exec, but panics if an error occurs.
  1178  func (u *CurrencyUpsertBulk) ExecX(ctx context.Context) {
  1179  	if err := u.create.Exec(ctx); err != nil {
  1180  		panic(err)
  1181  	}
  1182  }