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