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