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