github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/coinfiatcurrencyhistory_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/coinfiatcurrencyhistory" 14 "github.com/google/uuid" 15 "github.com/shopspring/decimal" 16 ) 17 18 // CoinFiatCurrencyHistoryCreate is the builder for creating a CoinFiatCurrencyHistory entity. 19 type CoinFiatCurrencyHistoryCreate struct { 20 config 21 mutation *CoinFiatCurrencyHistoryMutation 22 hooks []Hook 23 conflict []sql.ConflictOption 24 } 25 26 // SetCreatedAt sets the "created_at" field. 27 func (cfchc *CoinFiatCurrencyHistoryCreate) SetCreatedAt(u uint32) *CoinFiatCurrencyHistoryCreate { 28 cfchc.mutation.SetCreatedAt(u) 29 return cfchc 30 } 31 32 // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. 33 func (cfchc *CoinFiatCurrencyHistoryCreate) SetNillableCreatedAt(u *uint32) *CoinFiatCurrencyHistoryCreate { 34 if u != nil { 35 cfchc.SetCreatedAt(*u) 36 } 37 return cfchc 38 } 39 40 // SetUpdatedAt sets the "updated_at" field. 41 func (cfchc *CoinFiatCurrencyHistoryCreate) SetUpdatedAt(u uint32) *CoinFiatCurrencyHistoryCreate { 42 cfchc.mutation.SetUpdatedAt(u) 43 return cfchc 44 } 45 46 // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. 47 func (cfchc *CoinFiatCurrencyHistoryCreate) SetNillableUpdatedAt(u *uint32) *CoinFiatCurrencyHistoryCreate { 48 if u != nil { 49 cfchc.SetUpdatedAt(*u) 50 } 51 return cfchc 52 } 53 54 // SetDeletedAt sets the "deleted_at" field. 55 func (cfchc *CoinFiatCurrencyHistoryCreate) SetDeletedAt(u uint32) *CoinFiatCurrencyHistoryCreate { 56 cfchc.mutation.SetDeletedAt(u) 57 return cfchc 58 } 59 60 // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. 61 func (cfchc *CoinFiatCurrencyHistoryCreate) SetNillableDeletedAt(u *uint32) *CoinFiatCurrencyHistoryCreate { 62 if u != nil { 63 cfchc.SetDeletedAt(*u) 64 } 65 return cfchc 66 } 67 68 // SetEntID sets the "ent_id" field. 69 func (cfchc *CoinFiatCurrencyHistoryCreate) SetEntID(u uuid.UUID) *CoinFiatCurrencyHistoryCreate { 70 cfchc.mutation.SetEntID(u) 71 return cfchc 72 } 73 74 // SetNillableEntID sets the "ent_id" field if the given value is not nil. 75 func (cfchc *CoinFiatCurrencyHistoryCreate) SetNillableEntID(u *uuid.UUID) *CoinFiatCurrencyHistoryCreate { 76 if u != nil { 77 cfchc.SetEntID(*u) 78 } 79 return cfchc 80 } 81 82 // SetCoinTypeID sets the "coin_type_id" field. 83 func (cfchc *CoinFiatCurrencyHistoryCreate) SetCoinTypeID(u uuid.UUID) *CoinFiatCurrencyHistoryCreate { 84 cfchc.mutation.SetCoinTypeID(u) 85 return cfchc 86 } 87 88 // SetNillableCoinTypeID sets the "coin_type_id" field if the given value is not nil. 89 func (cfchc *CoinFiatCurrencyHistoryCreate) SetNillableCoinTypeID(u *uuid.UUID) *CoinFiatCurrencyHistoryCreate { 90 if u != nil { 91 cfchc.SetCoinTypeID(*u) 92 } 93 return cfchc 94 } 95 96 // SetFiatID sets the "fiat_id" field. 97 func (cfchc *CoinFiatCurrencyHistoryCreate) SetFiatID(u uuid.UUID) *CoinFiatCurrencyHistoryCreate { 98 cfchc.mutation.SetFiatID(u) 99 return cfchc 100 } 101 102 // SetNillableFiatID sets the "fiat_id" field if the given value is not nil. 103 func (cfchc *CoinFiatCurrencyHistoryCreate) SetNillableFiatID(u *uuid.UUID) *CoinFiatCurrencyHistoryCreate { 104 if u != nil { 105 cfchc.SetFiatID(*u) 106 } 107 return cfchc 108 } 109 110 // SetFeedType sets the "feed_type" field. 111 func (cfchc *CoinFiatCurrencyHistoryCreate) SetFeedType(s string) *CoinFiatCurrencyHistoryCreate { 112 cfchc.mutation.SetFeedType(s) 113 return cfchc 114 } 115 116 // SetNillableFeedType sets the "feed_type" field if the given value is not nil. 117 func (cfchc *CoinFiatCurrencyHistoryCreate) SetNillableFeedType(s *string) *CoinFiatCurrencyHistoryCreate { 118 if s != nil { 119 cfchc.SetFeedType(*s) 120 } 121 return cfchc 122 } 123 124 // SetMarketValueLow sets the "market_value_low" field. 125 func (cfchc *CoinFiatCurrencyHistoryCreate) SetMarketValueLow(d decimal.Decimal) *CoinFiatCurrencyHistoryCreate { 126 cfchc.mutation.SetMarketValueLow(d) 127 return cfchc 128 } 129 130 // SetNillableMarketValueLow sets the "market_value_low" field if the given value is not nil. 131 func (cfchc *CoinFiatCurrencyHistoryCreate) SetNillableMarketValueLow(d *decimal.Decimal) *CoinFiatCurrencyHistoryCreate { 132 if d != nil { 133 cfchc.SetMarketValueLow(*d) 134 } 135 return cfchc 136 } 137 138 // SetMarketValueHigh sets the "market_value_high" field. 139 func (cfchc *CoinFiatCurrencyHistoryCreate) SetMarketValueHigh(d decimal.Decimal) *CoinFiatCurrencyHistoryCreate { 140 cfchc.mutation.SetMarketValueHigh(d) 141 return cfchc 142 } 143 144 // SetNillableMarketValueHigh sets the "market_value_high" field if the given value is not nil. 145 func (cfchc *CoinFiatCurrencyHistoryCreate) SetNillableMarketValueHigh(d *decimal.Decimal) *CoinFiatCurrencyHistoryCreate { 146 if d != nil { 147 cfchc.SetMarketValueHigh(*d) 148 } 149 return cfchc 150 } 151 152 // SetID sets the "id" field. 153 func (cfchc *CoinFiatCurrencyHistoryCreate) SetID(u uint32) *CoinFiatCurrencyHistoryCreate { 154 cfchc.mutation.SetID(u) 155 return cfchc 156 } 157 158 // Mutation returns the CoinFiatCurrencyHistoryMutation object of the builder. 159 func (cfchc *CoinFiatCurrencyHistoryCreate) Mutation() *CoinFiatCurrencyHistoryMutation { 160 return cfchc.mutation 161 } 162 163 // Save creates the CoinFiatCurrencyHistory in the database. 164 func (cfchc *CoinFiatCurrencyHistoryCreate) Save(ctx context.Context) (*CoinFiatCurrencyHistory, error) { 165 var ( 166 err error 167 node *CoinFiatCurrencyHistory 168 ) 169 if err := cfchc.defaults(); err != nil { 170 return nil, err 171 } 172 if len(cfchc.hooks) == 0 { 173 if err = cfchc.check(); err != nil { 174 return nil, err 175 } 176 node, err = cfchc.sqlSave(ctx) 177 } else { 178 var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { 179 mutation, ok := m.(*CoinFiatCurrencyHistoryMutation) 180 if !ok { 181 return nil, fmt.Errorf("unexpected mutation type %T", m) 182 } 183 if err = cfchc.check(); err != nil { 184 return nil, err 185 } 186 cfchc.mutation = mutation 187 if node, err = cfchc.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(cfchc.hooks) - 1; i >= 0; i-- { 195 if cfchc.hooks[i] == nil { 196 return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") 197 } 198 mut = cfchc.hooks[i](mut) 199 } 200 v, err := mut.Mutate(ctx, cfchc.mutation) 201 if err != nil { 202 return nil, err 203 } 204 nv, ok := v.(*CoinFiatCurrencyHistory) 205 if !ok { 206 return nil, fmt.Errorf("unexpected node type %T returned from CoinFiatCurrencyHistoryMutation", 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 (cfchc *CoinFiatCurrencyHistoryCreate) SaveX(ctx context.Context) *CoinFiatCurrencyHistory { 215 v, err := cfchc.Save(ctx) 216 if err != nil { 217 panic(err) 218 } 219 return v 220 } 221 222 // Exec executes the query. 223 func (cfchc *CoinFiatCurrencyHistoryCreate) Exec(ctx context.Context) error { 224 _, err := cfchc.Save(ctx) 225 return err 226 } 227 228 // ExecX is like Exec, but panics if an error occurs. 229 func (cfchc *CoinFiatCurrencyHistoryCreate) ExecX(ctx context.Context) { 230 if err := cfchc.Exec(ctx); err != nil { 231 panic(err) 232 } 233 } 234 235 // defaults sets the default values of the builder before save. 236 func (cfchc *CoinFiatCurrencyHistoryCreate) defaults() error { 237 if _, ok := cfchc.mutation.CreatedAt(); !ok { 238 if coinfiatcurrencyhistory.DefaultCreatedAt == nil { 239 return fmt.Errorf("ent: uninitialized coinfiatcurrencyhistory.DefaultCreatedAt (forgotten import ent/runtime?)") 240 } 241 v := coinfiatcurrencyhistory.DefaultCreatedAt() 242 cfchc.mutation.SetCreatedAt(v) 243 } 244 if _, ok := cfchc.mutation.UpdatedAt(); !ok { 245 if coinfiatcurrencyhistory.DefaultUpdatedAt == nil { 246 return fmt.Errorf("ent: uninitialized coinfiatcurrencyhistory.DefaultUpdatedAt (forgotten import ent/runtime?)") 247 } 248 v := coinfiatcurrencyhistory.DefaultUpdatedAt() 249 cfchc.mutation.SetUpdatedAt(v) 250 } 251 if _, ok := cfchc.mutation.DeletedAt(); !ok { 252 if coinfiatcurrencyhistory.DefaultDeletedAt == nil { 253 return fmt.Errorf("ent: uninitialized coinfiatcurrencyhistory.DefaultDeletedAt (forgotten import ent/runtime?)") 254 } 255 v := coinfiatcurrencyhistory.DefaultDeletedAt() 256 cfchc.mutation.SetDeletedAt(v) 257 } 258 if _, ok := cfchc.mutation.EntID(); !ok { 259 if coinfiatcurrencyhistory.DefaultEntID == nil { 260 return fmt.Errorf("ent: uninitialized coinfiatcurrencyhistory.DefaultEntID (forgotten import ent/runtime?)") 261 } 262 v := coinfiatcurrencyhistory.DefaultEntID() 263 cfchc.mutation.SetEntID(v) 264 } 265 if _, ok := cfchc.mutation.CoinTypeID(); !ok { 266 if coinfiatcurrencyhistory.DefaultCoinTypeID == nil { 267 return fmt.Errorf("ent: uninitialized coinfiatcurrencyhistory.DefaultCoinTypeID (forgotten import ent/runtime?)") 268 } 269 v := coinfiatcurrencyhistory.DefaultCoinTypeID() 270 cfchc.mutation.SetCoinTypeID(v) 271 } 272 if _, ok := cfchc.mutation.FiatID(); !ok { 273 if coinfiatcurrencyhistory.DefaultFiatID == nil { 274 return fmt.Errorf("ent: uninitialized coinfiatcurrencyhistory.DefaultFiatID (forgotten import ent/runtime?)") 275 } 276 v := coinfiatcurrencyhistory.DefaultFiatID() 277 cfchc.mutation.SetFiatID(v) 278 } 279 if _, ok := cfchc.mutation.FeedType(); !ok { 280 v := coinfiatcurrencyhistory.DefaultFeedType 281 cfchc.mutation.SetFeedType(v) 282 } 283 if _, ok := cfchc.mutation.MarketValueLow(); !ok { 284 v := coinfiatcurrencyhistory.DefaultMarketValueLow 285 cfchc.mutation.SetMarketValueLow(v) 286 } 287 if _, ok := cfchc.mutation.MarketValueHigh(); !ok { 288 v := coinfiatcurrencyhistory.DefaultMarketValueHigh 289 cfchc.mutation.SetMarketValueHigh(v) 290 } 291 return nil 292 } 293 294 // check runs all checks and user-defined validators on the builder. 295 func (cfchc *CoinFiatCurrencyHistoryCreate) check() error { 296 if _, ok := cfchc.mutation.CreatedAt(); !ok { 297 return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "CoinFiatCurrencyHistory.created_at"`)} 298 } 299 if _, ok := cfchc.mutation.UpdatedAt(); !ok { 300 return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "CoinFiatCurrencyHistory.updated_at"`)} 301 } 302 if _, ok := cfchc.mutation.DeletedAt(); !ok { 303 return &ValidationError{Name: "deleted_at", err: errors.New(`ent: missing required field "CoinFiatCurrencyHistory.deleted_at"`)} 304 } 305 if _, ok := cfchc.mutation.EntID(); !ok { 306 return &ValidationError{Name: "ent_id", err: errors.New(`ent: missing required field "CoinFiatCurrencyHistory.ent_id"`)} 307 } 308 return nil 309 } 310 311 func (cfchc *CoinFiatCurrencyHistoryCreate) sqlSave(ctx context.Context) (*CoinFiatCurrencyHistory, error) { 312 _node, _spec := cfchc.createSpec() 313 if err := sqlgraph.CreateNode(ctx, cfchc.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 (cfchc *CoinFiatCurrencyHistoryCreate) createSpec() (*CoinFiatCurrencyHistory, *sqlgraph.CreateSpec) { 327 var ( 328 _node = &CoinFiatCurrencyHistory{config: cfchc.config} 329 _spec = &sqlgraph.CreateSpec{ 330 Table: coinfiatcurrencyhistory.Table, 331 ID: &sqlgraph.FieldSpec{ 332 Type: field.TypeUint32, 333 Column: coinfiatcurrencyhistory.FieldID, 334 }, 335 } 336 ) 337 _spec.OnConflict = cfchc.conflict 338 if id, ok := cfchc.mutation.ID(); ok { 339 _node.ID = id 340 _spec.ID.Value = id 341 } 342 if value, ok := cfchc.mutation.CreatedAt(); ok { 343 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 344 Type: field.TypeUint32, 345 Value: value, 346 Column: coinfiatcurrencyhistory.FieldCreatedAt, 347 }) 348 _node.CreatedAt = value 349 } 350 if value, ok := cfchc.mutation.UpdatedAt(); ok { 351 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 352 Type: field.TypeUint32, 353 Value: value, 354 Column: coinfiatcurrencyhistory.FieldUpdatedAt, 355 }) 356 _node.UpdatedAt = value 357 } 358 if value, ok := cfchc.mutation.DeletedAt(); ok { 359 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 360 Type: field.TypeUint32, 361 Value: value, 362 Column: coinfiatcurrencyhistory.FieldDeletedAt, 363 }) 364 _node.DeletedAt = value 365 } 366 if value, ok := cfchc.mutation.EntID(); ok { 367 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 368 Type: field.TypeUUID, 369 Value: value, 370 Column: coinfiatcurrencyhistory.FieldEntID, 371 }) 372 _node.EntID = value 373 } 374 if value, ok := cfchc.mutation.CoinTypeID(); ok { 375 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 376 Type: field.TypeUUID, 377 Value: value, 378 Column: coinfiatcurrencyhistory.FieldCoinTypeID, 379 }) 380 _node.CoinTypeID = value 381 } 382 if value, ok := cfchc.mutation.FiatID(); ok { 383 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 384 Type: field.TypeUUID, 385 Value: value, 386 Column: coinfiatcurrencyhistory.FieldFiatID, 387 }) 388 _node.FiatID = value 389 } 390 if value, ok := cfchc.mutation.FeedType(); ok { 391 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 392 Type: field.TypeString, 393 Value: value, 394 Column: coinfiatcurrencyhistory.FieldFeedType, 395 }) 396 _node.FeedType = value 397 } 398 if value, ok := cfchc.mutation.MarketValueLow(); ok { 399 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 400 Type: field.TypeOther, 401 Value: value, 402 Column: coinfiatcurrencyhistory.FieldMarketValueLow, 403 }) 404 _node.MarketValueLow = value 405 } 406 if value, ok := cfchc.mutation.MarketValueHigh(); ok { 407 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 408 Type: field.TypeOther, 409 Value: value, 410 Column: coinfiatcurrencyhistory.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.CoinFiatCurrencyHistory.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.CoinFiatCurrencyHistoryUpsert) { 430 // SetCreatedAt(v+v). 431 // }). 432 // Exec(ctx) 433 // 434 func (cfchc *CoinFiatCurrencyHistoryCreate) OnConflict(opts ...sql.ConflictOption) *CoinFiatCurrencyHistoryUpsertOne { 435 cfchc.conflict = opts 436 return &CoinFiatCurrencyHistoryUpsertOne{ 437 create: cfchc, 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.CoinFiatCurrencyHistory.Create(). 445 // OnConflict(sql.ConflictColumns(columns...)). 446 // Exec(ctx) 447 // 448 func (cfchc *CoinFiatCurrencyHistoryCreate) OnConflictColumns(columns ...string) *CoinFiatCurrencyHistoryUpsertOne { 449 cfchc.conflict = append(cfchc.conflict, sql.ConflictColumns(columns...)) 450 return &CoinFiatCurrencyHistoryUpsertOne{ 451 create: cfchc, 452 } 453 } 454 455 type ( 456 // CoinFiatCurrencyHistoryUpsertOne is the builder for "upsert"-ing 457 // one CoinFiatCurrencyHistory node. 458 CoinFiatCurrencyHistoryUpsertOne struct { 459 create *CoinFiatCurrencyHistoryCreate 460 } 461 462 // CoinFiatCurrencyHistoryUpsert is the "OnConflict" setter. 463 CoinFiatCurrencyHistoryUpsert struct { 464 *sql.UpdateSet 465 } 466 ) 467 468 // SetCreatedAt sets the "created_at" field. 469 func (u *CoinFiatCurrencyHistoryUpsert) SetCreatedAt(v uint32) *CoinFiatCurrencyHistoryUpsert { 470 u.Set(coinfiatcurrencyhistory.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 *CoinFiatCurrencyHistoryUpsert) UpdateCreatedAt() *CoinFiatCurrencyHistoryUpsert { 476 u.SetExcluded(coinfiatcurrencyhistory.FieldCreatedAt) 477 return u 478 } 479 480 // AddCreatedAt adds v to the "created_at" field. 481 func (u *CoinFiatCurrencyHistoryUpsert) AddCreatedAt(v uint32) *CoinFiatCurrencyHistoryUpsert { 482 u.Add(coinfiatcurrencyhistory.FieldCreatedAt, v) 483 return u 484 } 485 486 // SetUpdatedAt sets the "updated_at" field. 487 func (u *CoinFiatCurrencyHistoryUpsert) SetUpdatedAt(v uint32) *CoinFiatCurrencyHistoryUpsert { 488 u.Set(coinfiatcurrencyhistory.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 *CoinFiatCurrencyHistoryUpsert) UpdateUpdatedAt() *CoinFiatCurrencyHistoryUpsert { 494 u.SetExcluded(coinfiatcurrencyhistory.FieldUpdatedAt) 495 return u 496 } 497 498 // AddUpdatedAt adds v to the "updated_at" field. 499 func (u *CoinFiatCurrencyHistoryUpsert) AddUpdatedAt(v uint32) *CoinFiatCurrencyHistoryUpsert { 500 u.Add(coinfiatcurrencyhistory.FieldUpdatedAt, v) 501 return u 502 } 503 504 // SetDeletedAt sets the "deleted_at" field. 505 func (u *CoinFiatCurrencyHistoryUpsert) SetDeletedAt(v uint32) *CoinFiatCurrencyHistoryUpsert { 506 u.Set(coinfiatcurrencyhistory.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 *CoinFiatCurrencyHistoryUpsert) UpdateDeletedAt() *CoinFiatCurrencyHistoryUpsert { 512 u.SetExcluded(coinfiatcurrencyhistory.FieldDeletedAt) 513 return u 514 } 515 516 // AddDeletedAt adds v to the "deleted_at" field. 517 func (u *CoinFiatCurrencyHistoryUpsert) AddDeletedAt(v uint32) *CoinFiatCurrencyHistoryUpsert { 518 u.Add(coinfiatcurrencyhistory.FieldDeletedAt, v) 519 return u 520 } 521 522 // SetEntID sets the "ent_id" field. 523 func (u *CoinFiatCurrencyHistoryUpsert) SetEntID(v uuid.UUID) *CoinFiatCurrencyHistoryUpsert { 524 u.Set(coinfiatcurrencyhistory.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 *CoinFiatCurrencyHistoryUpsert) UpdateEntID() *CoinFiatCurrencyHistoryUpsert { 530 u.SetExcluded(coinfiatcurrencyhistory.FieldEntID) 531 return u 532 } 533 534 // SetCoinTypeID sets the "coin_type_id" field. 535 func (u *CoinFiatCurrencyHistoryUpsert) SetCoinTypeID(v uuid.UUID) *CoinFiatCurrencyHistoryUpsert { 536 u.Set(coinfiatcurrencyhistory.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 *CoinFiatCurrencyHistoryUpsert) UpdateCoinTypeID() *CoinFiatCurrencyHistoryUpsert { 542 u.SetExcluded(coinfiatcurrencyhistory.FieldCoinTypeID) 543 return u 544 } 545 546 // ClearCoinTypeID clears the value of the "coin_type_id" field. 547 func (u *CoinFiatCurrencyHistoryUpsert) ClearCoinTypeID() *CoinFiatCurrencyHistoryUpsert { 548 u.SetNull(coinfiatcurrencyhistory.FieldCoinTypeID) 549 return u 550 } 551 552 // SetFiatID sets the "fiat_id" field. 553 func (u *CoinFiatCurrencyHistoryUpsert) SetFiatID(v uuid.UUID) *CoinFiatCurrencyHistoryUpsert { 554 u.Set(coinfiatcurrencyhistory.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 *CoinFiatCurrencyHistoryUpsert) UpdateFiatID() *CoinFiatCurrencyHistoryUpsert { 560 u.SetExcluded(coinfiatcurrencyhistory.FieldFiatID) 561 return u 562 } 563 564 // ClearFiatID clears the value of the "fiat_id" field. 565 func (u *CoinFiatCurrencyHistoryUpsert) ClearFiatID() *CoinFiatCurrencyHistoryUpsert { 566 u.SetNull(coinfiatcurrencyhistory.FieldFiatID) 567 return u 568 } 569 570 // SetFeedType sets the "feed_type" field. 571 func (u *CoinFiatCurrencyHistoryUpsert) SetFeedType(v string) *CoinFiatCurrencyHistoryUpsert { 572 u.Set(coinfiatcurrencyhistory.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 *CoinFiatCurrencyHistoryUpsert) UpdateFeedType() *CoinFiatCurrencyHistoryUpsert { 578 u.SetExcluded(coinfiatcurrencyhistory.FieldFeedType) 579 return u 580 } 581 582 // ClearFeedType clears the value of the "feed_type" field. 583 func (u *CoinFiatCurrencyHistoryUpsert) ClearFeedType() *CoinFiatCurrencyHistoryUpsert { 584 u.SetNull(coinfiatcurrencyhistory.FieldFeedType) 585 return u 586 } 587 588 // SetMarketValueLow sets the "market_value_low" field. 589 func (u *CoinFiatCurrencyHistoryUpsert) SetMarketValueLow(v decimal.Decimal) *CoinFiatCurrencyHistoryUpsert { 590 u.Set(coinfiatcurrencyhistory.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 *CoinFiatCurrencyHistoryUpsert) UpdateMarketValueLow() *CoinFiatCurrencyHistoryUpsert { 596 u.SetExcluded(coinfiatcurrencyhistory.FieldMarketValueLow) 597 return u 598 } 599 600 // ClearMarketValueLow clears the value of the "market_value_low" field. 601 func (u *CoinFiatCurrencyHistoryUpsert) ClearMarketValueLow() *CoinFiatCurrencyHistoryUpsert { 602 u.SetNull(coinfiatcurrencyhistory.FieldMarketValueLow) 603 return u 604 } 605 606 // SetMarketValueHigh sets the "market_value_high" field. 607 func (u *CoinFiatCurrencyHistoryUpsert) SetMarketValueHigh(v decimal.Decimal) *CoinFiatCurrencyHistoryUpsert { 608 u.Set(coinfiatcurrencyhistory.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 *CoinFiatCurrencyHistoryUpsert) UpdateMarketValueHigh() *CoinFiatCurrencyHistoryUpsert { 614 u.SetExcluded(coinfiatcurrencyhistory.FieldMarketValueHigh) 615 return u 616 } 617 618 // ClearMarketValueHigh clears the value of the "market_value_high" field. 619 func (u *CoinFiatCurrencyHistoryUpsert) ClearMarketValueHigh() *CoinFiatCurrencyHistoryUpsert { 620 u.SetNull(coinfiatcurrencyhistory.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.CoinFiatCurrencyHistory.Create(). 628 // OnConflict( 629 // sql.ResolveWithNewValues(), 630 // sql.ResolveWith(func(u *sql.UpdateSet) { 631 // u.SetIgnore(coinfiatcurrencyhistory.FieldID) 632 // }), 633 // ). 634 // Exec(ctx) 635 // 636 func (u *CoinFiatCurrencyHistoryUpsertOne) UpdateNewValues() *CoinFiatCurrencyHistoryUpsertOne { 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(coinfiatcurrencyhistory.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.CoinFiatCurrencyHistory.Create(). 650 // OnConflict(sql.ResolveWithIgnore()). 651 // Exec(ctx) 652 // 653 func (u *CoinFiatCurrencyHistoryUpsertOne) Ignore() *CoinFiatCurrencyHistoryUpsertOne { 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 *CoinFiatCurrencyHistoryUpsertOne) DoNothing() *CoinFiatCurrencyHistoryUpsertOne { 661 u.create.conflict = append(u.create.conflict, sql.DoNothing()) 662 return u 663 } 664 665 // Update allows overriding fields `UPDATE` values. See the CoinFiatCurrencyHistoryCreate.OnConflict 666 // documentation for more info. 667 func (u *CoinFiatCurrencyHistoryUpsertOne) Update(set func(*CoinFiatCurrencyHistoryUpsert)) *CoinFiatCurrencyHistoryUpsertOne { 668 u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { 669 set(&CoinFiatCurrencyHistoryUpsert{UpdateSet: update}) 670 })) 671 return u 672 } 673 674 // SetCreatedAt sets the "created_at" field. 675 func (u *CoinFiatCurrencyHistoryUpsertOne) SetCreatedAt(v uint32) *CoinFiatCurrencyHistoryUpsertOne { 676 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 677 s.SetCreatedAt(v) 678 }) 679 } 680 681 // AddCreatedAt adds v to the "created_at" field. 682 func (u *CoinFiatCurrencyHistoryUpsertOne) AddCreatedAt(v uint32) *CoinFiatCurrencyHistoryUpsertOne { 683 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertOne) UpdateCreatedAt() *CoinFiatCurrencyHistoryUpsertOne { 690 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 691 s.UpdateCreatedAt() 692 }) 693 } 694 695 // SetUpdatedAt sets the "updated_at" field. 696 func (u *CoinFiatCurrencyHistoryUpsertOne) SetUpdatedAt(v uint32) *CoinFiatCurrencyHistoryUpsertOne { 697 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 698 s.SetUpdatedAt(v) 699 }) 700 } 701 702 // AddUpdatedAt adds v to the "updated_at" field. 703 func (u *CoinFiatCurrencyHistoryUpsertOne) AddUpdatedAt(v uint32) *CoinFiatCurrencyHistoryUpsertOne { 704 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertOne) UpdateUpdatedAt() *CoinFiatCurrencyHistoryUpsertOne { 711 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 712 s.UpdateUpdatedAt() 713 }) 714 } 715 716 // SetDeletedAt sets the "deleted_at" field. 717 func (u *CoinFiatCurrencyHistoryUpsertOne) SetDeletedAt(v uint32) *CoinFiatCurrencyHistoryUpsertOne { 718 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 719 s.SetDeletedAt(v) 720 }) 721 } 722 723 // AddDeletedAt adds v to the "deleted_at" field. 724 func (u *CoinFiatCurrencyHistoryUpsertOne) AddDeletedAt(v uint32) *CoinFiatCurrencyHistoryUpsertOne { 725 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertOne) UpdateDeletedAt() *CoinFiatCurrencyHistoryUpsertOne { 732 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 733 s.UpdateDeletedAt() 734 }) 735 } 736 737 // SetEntID sets the "ent_id" field. 738 func (u *CoinFiatCurrencyHistoryUpsertOne) SetEntID(v uuid.UUID) *CoinFiatCurrencyHistoryUpsertOne { 739 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertOne) UpdateEntID() *CoinFiatCurrencyHistoryUpsertOne { 746 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 747 s.UpdateEntID() 748 }) 749 } 750 751 // SetCoinTypeID sets the "coin_type_id" field. 752 func (u *CoinFiatCurrencyHistoryUpsertOne) SetCoinTypeID(v uuid.UUID) *CoinFiatCurrencyHistoryUpsertOne { 753 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertOne) UpdateCoinTypeID() *CoinFiatCurrencyHistoryUpsertOne { 760 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 761 s.UpdateCoinTypeID() 762 }) 763 } 764 765 // ClearCoinTypeID clears the value of the "coin_type_id" field. 766 func (u *CoinFiatCurrencyHistoryUpsertOne) ClearCoinTypeID() *CoinFiatCurrencyHistoryUpsertOne { 767 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 768 s.ClearCoinTypeID() 769 }) 770 } 771 772 // SetFiatID sets the "fiat_id" field. 773 func (u *CoinFiatCurrencyHistoryUpsertOne) SetFiatID(v uuid.UUID) *CoinFiatCurrencyHistoryUpsertOne { 774 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertOne) UpdateFiatID() *CoinFiatCurrencyHistoryUpsertOne { 781 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 782 s.UpdateFiatID() 783 }) 784 } 785 786 // ClearFiatID clears the value of the "fiat_id" field. 787 func (u *CoinFiatCurrencyHistoryUpsertOne) ClearFiatID() *CoinFiatCurrencyHistoryUpsertOne { 788 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 789 s.ClearFiatID() 790 }) 791 } 792 793 // SetFeedType sets the "feed_type" field. 794 func (u *CoinFiatCurrencyHistoryUpsertOne) SetFeedType(v string) *CoinFiatCurrencyHistoryUpsertOne { 795 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertOne) UpdateFeedType() *CoinFiatCurrencyHistoryUpsertOne { 802 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 803 s.UpdateFeedType() 804 }) 805 } 806 807 // ClearFeedType clears the value of the "feed_type" field. 808 func (u *CoinFiatCurrencyHistoryUpsertOne) ClearFeedType() *CoinFiatCurrencyHistoryUpsertOne { 809 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 810 s.ClearFeedType() 811 }) 812 } 813 814 // SetMarketValueLow sets the "market_value_low" field. 815 func (u *CoinFiatCurrencyHistoryUpsertOne) SetMarketValueLow(v decimal.Decimal) *CoinFiatCurrencyHistoryUpsertOne { 816 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertOne) UpdateMarketValueLow() *CoinFiatCurrencyHistoryUpsertOne { 823 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 824 s.UpdateMarketValueLow() 825 }) 826 } 827 828 // ClearMarketValueLow clears the value of the "market_value_low" field. 829 func (u *CoinFiatCurrencyHistoryUpsertOne) ClearMarketValueLow() *CoinFiatCurrencyHistoryUpsertOne { 830 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 831 s.ClearMarketValueLow() 832 }) 833 } 834 835 // SetMarketValueHigh sets the "market_value_high" field. 836 func (u *CoinFiatCurrencyHistoryUpsertOne) SetMarketValueHigh(v decimal.Decimal) *CoinFiatCurrencyHistoryUpsertOne { 837 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertOne) UpdateMarketValueHigh() *CoinFiatCurrencyHistoryUpsertOne { 844 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 845 s.UpdateMarketValueHigh() 846 }) 847 } 848 849 // ClearMarketValueHigh clears the value of the "market_value_high" field. 850 func (u *CoinFiatCurrencyHistoryUpsertOne) ClearMarketValueHigh() *CoinFiatCurrencyHistoryUpsertOne { 851 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 852 s.ClearMarketValueHigh() 853 }) 854 } 855 856 // Exec executes the query. 857 func (u *CoinFiatCurrencyHistoryUpsertOne) Exec(ctx context.Context) error { 858 if len(u.create.conflict) == 0 { 859 return errors.New("ent: missing options for CoinFiatCurrencyHistoryCreate.OnConflict") 860 } 861 return u.create.Exec(ctx) 862 } 863 864 // ExecX is like Exec, but panics if an error occurs. 865 func (u *CoinFiatCurrencyHistoryUpsertOne) 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 *CoinFiatCurrencyHistoryUpsertOne) 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 *CoinFiatCurrencyHistoryUpsertOne) 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 // CoinFiatCurrencyHistoryCreateBulk is the builder for creating many CoinFiatCurrencyHistory entities in bulk. 890 type CoinFiatCurrencyHistoryCreateBulk struct { 891 config 892 builders []*CoinFiatCurrencyHistoryCreate 893 conflict []sql.ConflictOption 894 } 895 896 // Save creates the CoinFiatCurrencyHistory entities in the database. 897 func (cfchcb *CoinFiatCurrencyHistoryCreateBulk) Save(ctx context.Context) ([]*CoinFiatCurrencyHistory, error) { 898 specs := make([]*sqlgraph.CreateSpec, len(cfchcb.builders)) 899 nodes := make([]*CoinFiatCurrencyHistory, len(cfchcb.builders)) 900 mutators := make([]Mutator, len(cfchcb.builders)) 901 for i := range cfchcb.builders { 902 func(i int, root context.Context) { 903 builder := cfchcb.builders[i] 904 builder.defaults() 905 var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { 906 mutation, ok := m.(*CoinFiatCurrencyHistoryMutation) 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, cfchcb.builders[i+1].mutation) 918 } else { 919 spec := &sqlgraph.BatchCreateSpec{Nodes: specs} 920 spec.OnConflict = cfchcb.conflict 921 // Invoke the actual operation on the latest mutation in the chain. 922 if err = sqlgraph.BatchCreate(ctx, cfchcb.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, cfchcb.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 (cfchcb *CoinFiatCurrencyHistoryCreateBulk) SaveX(ctx context.Context) []*CoinFiatCurrencyHistory { 955 v, err := cfchcb.Save(ctx) 956 if err != nil { 957 panic(err) 958 } 959 return v 960 } 961 962 // Exec executes the query. 963 func (cfchcb *CoinFiatCurrencyHistoryCreateBulk) Exec(ctx context.Context) error { 964 _, err := cfchcb.Save(ctx) 965 return err 966 } 967 968 // ExecX is like Exec, but panics if an error occurs. 969 func (cfchcb *CoinFiatCurrencyHistoryCreateBulk) ExecX(ctx context.Context) { 970 if err := cfchcb.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.CoinFiatCurrencyHistory.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.CoinFiatCurrencyHistoryUpsert) { 987 // SetCreatedAt(v+v). 988 // }). 989 // Exec(ctx) 990 // 991 func (cfchcb *CoinFiatCurrencyHistoryCreateBulk) OnConflict(opts ...sql.ConflictOption) *CoinFiatCurrencyHistoryUpsertBulk { 992 cfchcb.conflict = opts 993 return &CoinFiatCurrencyHistoryUpsertBulk{ 994 create: cfchcb, 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.CoinFiatCurrencyHistory.Create(). 1002 // OnConflict(sql.ConflictColumns(columns...)). 1003 // Exec(ctx) 1004 // 1005 func (cfchcb *CoinFiatCurrencyHistoryCreateBulk) OnConflictColumns(columns ...string) *CoinFiatCurrencyHistoryUpsertBulk { 1006 cfchcb.conflict = append(cfchcb.conflict, sql.ConflictColumns(columns...)) 1007 return &CoinFiatCurrencyHistoryUpsertBulk{ 1008 create: cfchcb, 1009 } 1010 } 1011 1012 // CoinFiatCurrencyHistoryUpsertBulk is the builder for "upsert"-ing 1013 // a bulk of CoinFiatCurrencyHistory nodes. 1014 type CoinFiatCurrencyHistoryUpsertBulk struct { 1015 create *CoinFiatCurrencyHistoryCreateBulk 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.CoinFiatCurrencyHistory.Create(). 1022 // OnConflict( 1023 // sql.ResolveWithNewValues(), 1024 // sql.ResolveWith(func(u *sql.UpdateSet) { 1025 // u.SetIgnore(coinfiatcurrencyhistory.FieldID) 1026 // }), 1027 // ). 1028 // Exec(ctx) 1029 // 1030 func (u *CoinFiatCurrencyHistoryUpsertBulk) UpdateNewValues() *CoinFiatCurrencyHistoryUpsertBulk { 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(coinfiatcurrencyhistory.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.CoinFiatCurrencyHistory.Create(). 1047 // OnConflict(sql.ResolveWithIgnore()). 1048 // Exec(ctx) 1049 // 1050 func (u *CoinFiatCurrencyHistoryUpsertBulk) Ignore() *CoinFiatCurrencyHistoryUpsertBulk { 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 *CoinFiatCurrencyHistoryUpsertBulk) DoNothing() *CoinFiatCurrencyHistoryUpsertBulk { 1058 u.create.conflict = append(u.create.conflict, sql.DoNothing()) 1059 return u 1060 } 1061 1062 // Update allows overriding fields `UPDATE` values. See the CoinFiatCurrencyHistoryCreateBulk.OnConflict 1063 // documentation for more info. 1064 func (u *CoinFiatCurrencyHistoryUpsertBulk) Update(set func(*CoinFiatCurrencyHistoryUpsert)) *CoinFiatCurrencyHistoryUpsertBulk { 1065 u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { 1066 set(&CoinFiatCurrencyHistoryUpsert{UpdateSet: update}) 1067 })) 1068 return u 1069 } 1070 1071 // SetCreatedAt sets the "created_at" field. 1072 func (u *CoinFiatCurrencyHistoryUpsertBulk) SetCreatedAt(v uint32) *CoinFiatCurrencyHistoryUpsertBulk { 1073 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1074 s.SetCreatedAt(v) 1075 }) 1076 } 1077 1078 // AddCreatedAt adds v to the "created_at" field. 1079 func (u *CoinFiatCurrencyHistoryUpsertBulk) AddCreatedAt(v uint32) *CoinFiatCurrencyHistoryUpsertBulk { 1080 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertBulk) UpdateCreatedAt() *CoinFiatCurrencyHistoryUpsertBulk { 1087 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1088 s.UpdateCreatedAt() 1089 }) 1090 } 1091 1092 // SetUpdatedAt sets the "updated_at" field. 1093 func (u *CoinFiatCurrencyHistoryUpsertBulk) SetUpdatedAt(v uint32) *CoinFiatCurrencyHistoryUpsertBulk { 1094 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1095 s.SetUpdatedAt(v) 1096 }) 1097 } 1098 1099 // AddUpdatedAt adds v to the "updated_at" field. 1100 func (u *CoinFiatCurrencyHistoryUpsertBulk) AddUpdatedAt(v uint32) *CoinFiatCurrencyHistoryUpsertBulk { 1101 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertBulk) UpdateUpdatedAt() *CoinFiatCurrencyHistoryUpsertBulk { 1108 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1109 s.UpdateUpdatedAt() 1110 }) 1111 } 1112 1113 // SetDeletedAt sets the "deleted_at" field. 1114 func (u *CoinFiatCurrencyHistoryUpsertBulk) SetDeletedAt(v uint32) *CoinFiatCurrencyHistoryUpsertBulk { 1115 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1116 s.SetDeletedAt(v) 1117 }) 1118 } 1119 1120 // AddDeletedAt adds v to the "deleted_at" field. 1121 func (u *CoinFiatCurrencyHistoryUpsertBulk) AddDeletedAt(v uint32) *CoinFiatCurrencyHistoryUpsertBulk { 1122 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertBulk) UpdateDeletedAt() *CoinFiatCurrencyHistoryUpsertBulk { 1129 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1130 s.UpdateDeletedAt() 1131 }) 1132 } 1133 1134 // SetEntID sets the "ent_id" field. 1135 func (u *CoinFiatCurrencyHistoryUpsertBulk) SetEntID(v uuid.UUID) *CoinFiatCurrencyHistoryUpsertBulk { 1136 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertBulk) UpdateEntID() *CoinFiatCurrencyHistoryUpsertBulk { 1143 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1144 s.UpdateEntID() 1145 }) 1146 } 1147 1148 // SetCoinTypeID sets the "coin_type_id" field. 1149 func (u *CoinFiatCurrencyHistoryUpsertBulk) SetCoinTypeID(v uuid.UUID) *CoinFiatCurrencyHistoryUpsertBulk { 1150 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertBulk) UpdateCoinTypeID() *CoinFiatCurrencyHistoryUpsertBulk { 1157 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1158 s.UpdateCoinTypeID() 1159 }) 1160 } 1161 1162 // ClearCoinTypeID clears the value of the "coin_type_id" field. 1163 func (u *CoinFiatCurrencyHistoryUpsertBulk) ClearCoinTypeID() *CoinFiatCurrencyHistoryUpsertBulk { 1164 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1165 s.ClearCoinTypeID() 1166 }) 1167 } 1168 1169 // SetFiatID sets the "fiat_id" field. 1170 func (u *CoinFiatCurrencyHistoryUpsertBulk) SetFiatID(v uuid.UUID) *CoinFiatCurrencyHistoryUpsertBulk { 1171 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertBulk) UpdateFiatID() *CoinFiatCurrencyHistoryUpsertBulk { 1178 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1179 s.UpdateFiatID() 1180 }) 1181 } 1182 1183 // ClearFiatID clears the value of the "fiat_id" field. 1184 func (u *CoinFiatCurrencyHistoryUpsertBulk) ClearFiatID() *CoinFiatCurrencyHistoryUpsertBulk { 1185 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1186 s.ClearFiatID() 1187 }) 1188 } 1189 1190 // SetFeedType sets the "feed_type" field. 1191 func (u *CoinFiatCurrencyHistoryUpsertBulk) SetFeedType(v string) *CoinFiatCurrencyHistoryUpsertBulk { 1192 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertBulk) UpdateFeedType() *CoinFiatCurrencyHistoryUpsertBulk { 1199 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1200 s.UpdateFeedType() 1201 }) 1202 } 1203 1204 // ClearFeedType clears the value of the "feed_type" field. 1205 func (u *CoinFiatCurrencyHistoryUpsertBulk) ClearFeedType() *CoinFiatCurrencyHistoryUpsertBulk { 1206 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1207 s.ClearFeedType() 1208 }) 1209 } 1210 1211 // SetMarketValueLow sets the "market_value_low" field. 1212 func (u *CoinFiatCurrencyHistoryUpsertBulk) SetMarketValueLow(v decimal.Decimal) *CoinFiatCurrencyHistoryUpsertBulk { 1213 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertBulk) UpdateMarketValueLow() *CoinFiatCurrencyHistoryUpsertBulk { 1220 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1221 s.UpdateMarketValueLow() 1222 }) 1223 } 1224 1225 // ClearMarketValueLow clears the value of the "market_value_low" field. 1226 func (u *CoinFiatCurrencyHistoryUpsertBulk) ClearMarketValueLow() *CoinFiatCurrencyHistoryUpsertBulk { 1227 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1228 s.ClearMarketValueLow() 1229 }) 1230 } 1231 1232 // SetMarketValueHigh sets the "market_value_high" field. 1233 func (u *CoinFiatCurrencyHistoryUpsertBulk) SetMarketValueHigh(v decimal.Decimal) *CoinFiatCurrencyHistoryUpsertBulk { 1234 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 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 *CoinFiatCurrencyHistoryUpsertBulk) UpdateMarketValueHigh() *CoinFiatCurrencyHistoryUpsertBulk { 1241 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1242 s.UpdateMarketValueHigh() 1243 }) 1244 } 1245 1246 // ClearMarketValueHigh clears the value of the "market_value_high" field. 1247 func (u *CoinFiatCurrencyHistoryUpsertBulk) ClearMarketValueHigh() *CoinFiatCurrencyHistoryUpsertBulk { 1248 return u.Update(func(s *CoinFiatCurrencyHistoryUpsert) { 1249 s.ClearMarketValueHigh() 1250 }) 1251 } 1252 1253 // Exec executes the query. 1254 func (u *CoinFiatCurrencyHistoryUpsertBulk) 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 CoinFiatCurrencyHistoryCreateBulk instead", i) 1258 } 1259 } 1260 if len(u.create.conflict) == 0 { 1261 return errors.New("ent: missing options for CoinFiatCurrencyHistoryCreateBulk.OnConflict") 1262 } 1263 return u.create.Exec(ctx) 1264 } 1265 1266 // ExecX is like Exec, but panics if an error occurs. 1267 func (u *CoinFiatCurrencyHistoryUpsertBulk) ExecX(ctx context.Context) { 1268 if err := u.create.Exec(ctx); err != nil { 1269 panic(err) 1270 } 1271 }