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