securitysecret_create.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "entgo.io/ent/dialect/sql"
  9. "entgo.io/ent/dialect/sql/sqlgraph"
  10. "entgo.io/ent/schema/field"
  11. "github.com/Wei-Shaw/sub2api/ent/securitysecret"
  12. )
  13. // SecuritySecretCreate is the builder for creating a SecuritySecret entity.
  14. type SecuritySecretCreate struct {
  15. config
  16. mutation *SecuritySecretMutation
  17. hooks []Hook
  18. conflict []sql.ConflictOption
  19. }
  20. // SetCreatedAt sets the "created_at" field.
  21. func (_c *SecuritySecretCreate) SetCreatedAt(v time.Time) *SecuritySecretCreate {
  22. _c.mutation.SetCreatedAt(v)
  23. return _c
  24. }
  25. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  26. func (_c *SecuritySecretCreate) SetNillableCreatedAt(v *time.Time) *SecuritySecretCreate {
  27. if v != nil {
  28. _c.SetCreatedAt(*v)
  29. }
  30. return _c
  31. }
  32. // SetUpdatedAt sets the "updated_at" field.
  33. func (_c *SecuritySecretCreate) SetUpdatedAt(v time.Time) *SecuritySecretCreate {
  34. _c.mutation.SetUpdatedAt(v)
  35. return _c
  36. }
  37. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  38. func (_c *SecuritySecretCreate) SetNillableUpdatedAt(v *time.Time) *SecuritySecretCreate {
  39. if v != nil {
  40. _c.SetUpdatedAt(*v)
  41. }
  42. return _c
  43. }
  44. // SetKey sets the "key" field.
  45. func (_c *SecuritySecretCreate) SetKey(v string) *SecuritySecretCreate {
  46. _c.mutation.SetKey(v)
  47. return _c
  48. }
  49. // SetValue sets the "value" field.
  50. func (_c *SecuritySecretCreate) SetValue(v string) *SecuritySecretCreate {
  51. _c.mutation.SetValue(v)
  52. return _c
  53. }
  54. // Mutation returns the SecuritySecretMutation object of the builder.
  55. func (_c *SecuritySecretCreate) Mutation() *SecuritySecretMutation {
  56. return _c.mutation
  57. }
  58. // Save creates the SecuritySecret in the database.
  59. func (_c *SecuritySecretCreate) Save(ctx context.Context) (*SecuritySecret, error) {
  60. _c.defaults()
  61. return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
  62. }
  63. // SaveX calls Save and panics if Save returns an error.
  64. func (_c *SecuritySecretCreate) SaveX(ctx context.Context) *SecuritySecret {
  65. v, err := _c.Save(ctx)
  66. if err != nil {
  67. panic(err)
  68. }
  69. return v
  70. }
  71. // Exec executes the query.
  72. func (_c *SecuritySecretCreate) Exec(ctx context.Context) error {
  73. _, err := _c.Save(ctx)
  74. return err
  75. }
  76. // ExecX is like Exec, but panics if an error occurs.
  77. func (_c *SecuritySecretCreate) ExecX(ctx context.Context) {
  78. if err := _c.Exec(ctx); err != nil {
  79. panic(err)
  80. }
  81. }
  82. // defaults sets the default values of the builder before save.
  83. func (_c *SecuritySecretCreate) defaults() {
  84. if _, ok := _c.mutation.CreatedAt(); !ok {
  85. v := securitysecret.DefaultCreatedAt()
  86. _c.mutation.SetCreatedAt(v)
  87. }
  88. if _, ok := _c.mutation.UpdatedAt(); !ok {
  89. v := securitysecret.DefaultUpdatedAt()
  90. _c.mutation.SetUpdatedAt(v)
  91. }
  92. }
  93. // check runs all checks and user-defined validators on the builder.
  94. func (_c *SecuritySecretCreate) check() error {
  95. if _, ok := _c.mutation.CreatedAt(); !ok {
  96. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "SecuritySecret.created_at"`)}
  97. }
  98. if _, ok := _c.mutation.UpdatedAt(); !ok {
  99. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "SecuritySecret.updated_at"`)}
  100. }
  101. if _, ok := _c.mutation.Key(); !ok {
  102. return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "SecuritySecret.key"`)}
  103. }
  104. if v, ok := _c.mutation.Key(); ok {
  105. if err := securitysecret.KeyValidator(v); err != nil {
  106. return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "SecuritySecret.key": %w`, err)}
  107. }
  108. }
  109. if _, ok := _c.mutation.Value(); !ok {
  110. return &ValidationError{Name: "value", err: errors.New(`ent: missing required field "SecuritySecret.value"`)}
  111. }
  112. if v, ok := _c.mutation.Value(); ok {
  113. if err := securitysecret.ValueValidator(v); err != nil {
  114. return &ValidationError{Name: "value", err: fmt.Errorf(`ent: validator failed for field "SecuritySecret.value": %w`, err)}
  115. }
  116. }
  117. return nil
  118. }
  119. func (_c *SecuritySecretCreate) sqlSave(ctx context.Context) (*SecuritySecret, error) {
  120. if err := _c.check(); err != nil {
  121. return nil, err
  122. }
  123. _node, _spec := _c.createSpec()
  124. if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
  125. if sqlgraph.IsConstraintError(err) {
  126. err = &ConstraintError{msg: err.Error(), wrap: err}
  127. }
  128. return nil, err
  129. }
  130. id := _spec.ID.Value.(int64)
  131. _node.ID = int64(id)
  132. _c.mutation.id = &_node.ID
  133. _c.mutation.done = true
  134. return _node, nil
  135. }
  136. func (_c *SecuritySecretCreate) createSpec() (*SecuritySecret, *sqlgraph.CreateSpec) {
  137. var (
  138. _node = &SecuritySecret{config: _c.config}
  139. _spec = sqlgraph.NewCreateSpec(securitysecret.Table, sqlgraph.NewFieldSpec(securitysecret.FieldID, field.TypeInt64))
  140. )
  141. _spec.OnConflict = _c.conflict
  142. if value, ok := _c.mutation.CreatedAt(); ok {
  143. _spec.SetField(securitysecret.FieldCreatedAt, field.TypeTime, value)
  144. _node.CreatedAt = value
  145. }
  146. if value, ok := _c.mutation.UpdatedAt(); ok {
  147. _spec.SetField(securitysecret.FieldUpdatedAt, field.TypeTime, value)
  148. _node.UpdatedAt = value
  149. }
  150. if value, ok := _c.mutation.Key(); ok {
  151. _spec.SetField(securitysecret.FieldKey, field.TypeString, value)
  152. _node.Key = value
  153. }
  154. if value, ok := _c.mutation.Value(); ok {
  155. _spec.SetField(securitysecret.FieldValue, field.TypeString, value)
  156. _node.Value = value
  157. }
  158. return _node, _spec
  159. }
  160. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  161. // of the `INSERT` statement. For example:
  162. //
  163. // client.SecuritySecret.Create().
  164. // SetCreatedAt(v).
  165. // OnConflict(
  166. // // Update the row with the new values
  167. // // the was proposed for insertion.
  168. // sql.ResolveWithNewValues(),
  169. // ).
  170. // // Override some of the fields with custom
  171. // // update values.
  172. // Update(func(u *ent.SecuritySecretUpsert) {
  173. // SetCreatedAt(v+v).
  174. // }).
  175. // Exec(ctx)
  176. func (_c *SecuritySecretCreate) OnConflict(opts ...sql.ConflictOption) *SecuritySecretUpsertOne {
  177. _c.conflict = opts
  178. return &SecuritySecretUpsertOne{
  179. create: _c,
  180. }
  181. }
  182. // OnConflictColumns calls `OnConflict` and configures the columns
  183. // as conflict target. Using this option is equivalent to using:
  184. //
  185. // client.SecuritySecret.Create().
  186. // OnConflict(sql.ConflictColumns(columns...)).
  187. // Exec(ctx)
  188. func (_c *SecuritySecretCreate) OnConflictColumns(columns ...string) *SecuritySecretUpsertOne {
  189. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  190. return &SecuritySecretUpsertOne{
  191. create: _c,
  192. }
  193. }
  194. type (
  195. // SecuritySecretUpsertOne is the builder for "upsert"-ing
  196. // one SecuritySecret node.
  197. SecuritySecretUpsertOne struct {
  198. create *SecuritySecretCreate
  199. }
  200. // SecuritySecretUpsert is the "OnConflict" setter.
  201. SecuritySecretUpsert struct {
  202. *sql.UpdateSet
  203. }
  204. )
  205. // SetUpdatedAt sets the "updated_at" field.
  206. func (u *SecuritySecretUpsert) SetUpdatedAt(v time.Time) *SecuritySecretUpsert {
  207. u.Set(securitysecret.FieldUpdatedAt, v)
  208. return u
  209. }
  210. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  211. func (u *SecuritySecretUpsert) UpdateUpdatedAt() *SecuritySecretUpsert {
  212. u.SetExcluded(securitysecret.FieldUpdatedAt)
  213. return u
  214. }
  215. // SetKey sets the "key" field.
  216. func (u *SecuritySecretUpsert) SetKey(v string) *SecuritySecretUpsert {
  217. u.Set(securitysecret.FieldKey, v)
  218. return u
  219. }
  220. // UpdateKey sets the "key" field to the value that was provided on create.
  221. func (u *SecuritySecretUpsert) UpdateKey() *SecuritySecretUpsert {
  222. u.SetExcluded(securitysecret.FieldKey)
  223. return u
  224. }
  225. // SetValue sets the "value" field.
  226. func (u *SecuritySecretUpsert) SetValue(v string) *SecuritySecretUpsert {
  227. u.Set(securitysecret.FieldValue, v)
  228. return u
  229. }
  230. // UpdateValue sets the "value" field to the value that was provided on create.
  231. func (u *SecuritySecretUpsert) UpdateValue() *SecuritySecretUpsert {
  232. u.SetExcluded(securitysecret.FieldValue)
  233. return u
  234. }
  235. // UpdateNewValues updates the mutable fields using the new values that were set on create.
  236. // Using this option is equivalent to using:
  237. //
  238. // client.SecuritySecret.Create().
  239. // OnConflict(
  240. // sql.ResolveWithNewValues(),
  241. // ).
  242. // Exec(ctx)
  243. func (u *SecuritySecretUpsertOne) UpdateNewValues() *SecuritySecretUpsertOne {
  244. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  245. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  246. if _, exists := u.create.mutation.CreatedAt(); exists {
  247. s.SetIgnore(securitysecret.FieldCreatedAt)
  248. }
  249. }))
  250. return u
  251. }
  252. // Ignore sets each column to itself in case of conflict.
  253. // Using this option is equivalent to using:
  254. //
  255. // client.SecuritySecret.Create().
  256. // OnConflict(sql.ResolveWithIgnore()).
  257. // Exec(ctx)
  258. func (u *SecuritySecretUpsertOne) Ignore() *SecuritySecretUpsertOne {
  259. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  260. return u
  261. }
  262. // DoNothing configures the conflict_action to `DO NOTHING`.
  263. // Supported only by SQLite and PostgreSQL.
  264. func (u *SecuritySecretUpsertOne) DoNothing() *SecuritySecretUpsertOne {
  265. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  266. return u
  267. }
  268. // Update allows overriding fields `UPDATE` values. See the SecuritySecretCreate.OnConflict
  269. // documentation for more info.
  270. func (u *SecuritySecretUpsertOne) Update(set func(*SecuritySecretUpsert)) *SecuritySecretUpsertOne {
  271. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  272. set(&SecuritySecretUpsert{UpdateSet: update})
  273. }))
  274. return u
  275. }
  276. // SetUpdatedAt sets the "updated_at" field.
  277. func (u *SecuritySecretUpsertOne) SetUpdatedAt(v time.Time) *SecuritySecretUpsertOne {
  278. return u.Update(func(s *SecuritySecretUpsert) {
  279. s.SetUpdatedAt(v)
  280. })
  281. }
  282. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  283. func (u *SecuritySecretUpsertOne) UpdateUpdatedAt() *SecuritySecretUpsertOne {
  284. return u.Update(func(s *SecuritySecretUpsert) {
  285. s.UpdateUpdatedAt()
  286. })
  287. }
  288. // SetKey sets the "key" field.
  289. func (u *SecuritySecretUpsertOne) SetKey(v string) *SecuritySecretUpsertOne {
  290. return u.Update(func(s *SecuritySecretUpsert) {
  291. s.SetKey(v)
  292. })
  293. }
  294. // UpdateKey sets the "key" field to the value that was provided on create.
  295. func (u *SecuritySecretUpsertOne) UpdateKey() *SecuritySecretUpsertOne {
  296. return u.Update(func(s *SecuritySecretUpsert) {
  297. s.UpdateKey()
  298. })
  299. }
  300. // SetValue sets the "value" field.
  301. func (u *SecuritySecretUpsertOne) SetValue(v string) *SecuritySecretUpsertOne {
  302. return u.Update(func(s *SecuritySecretUpsert) {
  303. s.SetValue(v)
  304. })
  305. }
  306. // UpdateValue sets the "value" field to the value that was provided on create.
  307. func (u *SecuritySecretUpsertOne) UpdateValue() *SecuritySecretUpsertOne {
  308. return u.Update(func(s *SecuritySecretUpsert) {
  309. s.UpdateValue()
  310. })
  311. }
  312. // Exec executes the query.
  313. func (u *SecuritySecretUpsertOne) Exec(ctx context.Context) error {
  314. if len(u.create.conflict) == 0 {
  315. return errors.New("ent: missing options for SecuritySecretCreate.OnConflict")
  316. }
  317. return u.create.Exec(ctx)
  318. }
  319. // ExecX is like Exec, but panics if an error occurs.
  320. func (u *SecuritySecretUpsertOne) ExecX(ctx context.Context) {
  321. if err := u.create.Exec(ctx); err != nil {
  322. panic(err)
  323. }
  324. }
  325. // Exec executes the UPSERT query and returns the inserted/updated ID.
  326. func (u *SecuritySecretUpsertOne) ID(ctx context.Context) (id int64, err error) {
  327. node, err := u.create.Save(ctx)
  328. if err != nil {
  329. return id, err
  330. }
  331. return node.ID, nil
  332. }
  333. // IDX is like ID, but panics if an error occurs.
  334. func (u *SecuritySecretUpsertOne) IDX(ctx context.Context) int64 {
  335. id, err := u.ID(ctx)
  336. if err != nil {
  337. panic(err)
  338. }
  339. return id
  340. }
  341. // SecuritySecretCreateBulk is the builder for creating many SecuritySecret entities in bulk.
  342. type SecuritySecretCreateBulk struct {
  343. config
  344. err error
  345. builders []*SecuritySecretCreate
  346. conflict []sql.ConflictOption
  347. }
  348. // Save creates the SecuritySecret entities in the database.
  349. func (_c *SecuritySecretCreateBulk) Save(ctx context.Context) ([]*SecuritySecret, error) {
  350. if _c.err != nil {
  351. return nil, _c.err
  352. }
  353. specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
  354. nodes := make([]*SecuritySecret, len(_c.builders))
  355. mutators := make([]Mutator, len(_c.builders))
  356. for i := range _c.builders {
  357. func(i int, root context.Context) {
  358. builder := _c.builders[i]
  359. builder.defaults()
  360. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  361. mutation, ok := m.(*SecuritySecretMutation)
  362. if !ok {
  363. return nil, fmt.Errorf("unexpected mutation type %T", m)
  364. }
  365. if err := builder.check(); err != nil {
  366. return nil, err
  367. }
  368. builder.mutation = mutation
  369. var err error
  370. nodes[i], specs[i] = builder.createSpec()
  371. if i < len(mutators)-1 {
  372. _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
  373. } else {
  374. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  375. spec.OnConflict = _c.conflict
  376. // Invoke the actual operation on the latest mutation in the chain.
  377. if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
  378. if sqlgraph.IsConstraintError(err) {
  379. err = &ConstraintError{msg: err.Error(), wrap: err}
  380. }
  381. }
  382. }
  383. if err != nil {
  384. return nil, err
  385. }
  386. mutation.id = &nodes[i].ID
  387. if specs[i].ID.Value != nil {
  388. id := specs[i].ID.Value.(int64)
  389. nodes[i].ID = int64(id)
  390. }
  391. mutation.done = true
  392. return nodes[i], nil
  393. })
  394. for i := len(builder.hooks) - 1; i >= 0; i-- {
  395. mut = builder.hooks[i](mut)
  396. }
  397. mutators[i] = mut
  398. }(i, ctx)
  399. }
  400. if len(mutators) > 0 {
  401. if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
  402. return nil, err
  403. }
  404. }
  405. return nodes, nil
  406. }
  407. // SaveX is like Save, but panics if an error occurs.
  408. func (_c *SecuritySecretCreateBulk) SaveX(ctx context.Context) []*SecuritySecret {
  409. v, err := _c.Save(ctx)
  410. if err != nil {
  411. panic(err)
  412. }
  413. return v
  414. }
  415. // Exec executes the query.
  416. func (_c *SecuritySecretCreateBulk) Exec(ctx context.Context) error {
  417. _, err := _c.Save(ctx)
  418. return err
  419. }
  420. // ExecX is like Exec, but panics if an error occurs.
  421. func (_c *SecuritySecretCreateBulk) ExecX(ctx context.Context) {
  422. if err := _c.Exec(ctx); err != nil {
  423. panic(err)
  424. }
  425. }
  426. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  427. // of the `INSERT` statement. For example:
  428. //
  429. // client.SecuritySecret.CreateBulk(builders...).
  430. // OnConflict(
  431. // // Update the row with the new values
  432. // // the was proposed for insertion.
  433. // sql.ResolveWithNewValues(),
  434. // ).
  435. // // Override some of the fields with custom
  436. // // update values.
  437. // Update(func(u *ent.SecuritySecretUpsert) {
  438. // SetCreatedAt(v+v).
  439. // }).
  440. // Exec(ctx)
  441. func (_c *SecuritySecretCreateBulk) OnConflict(opts ...sql.ConflictOption) *SecuritySecretUpsertBulk {
  442. _c.conflict = opts
  443. return &SecuritySecretUpsertBulk{
  444. create: _c,
  445. }
  446. }
  447. // OnConflictColumns calls `OnConflict` and configures the columns
  448. // as conflict target. Using this option is equivalent to using:
  449. //
  450. // client.SecuritySecret.Create().
  451. // OnConflict(sql.ConflictColumns(columns...)).
  452. // Exec(ctx)
  453. func (_c *SecuritySecretCreateBulk) OnConflictColumns(columns ...string) *SecuritySecretUpsertBulk {
  454. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  455. return &SecuritySecretUpsertBulk{
  456. create: _c,
  457. }
  458. }
  459. // SecuritySecretUpsertBulk is the builder for "upsert"-ing
  460. // a bulk of SecuritySecret nodes.
  461. type SecuritySecretUpsertBulk struct {
  462. create *SecuritySecretCreateBulk
  463. }
  464. // UpdateNewValues updates the mutable fields using the new values that
  465. // were set on create. Using this option is equivalent to using:
  466. //
  467. // client.SecuritySecret.Create().
  468. // OnConflict(
  469. // sql.ResolveWithNewValues(),
  470. // ).
  471. // Exec(ctx)
  472. func (u *SecuritySecretUpsertBulk) UpdateNewValues() *SecuritySecretUpsertBulk {
  473. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  474. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  475. for _, b := range u.create.builders {
  476. if _, exists := b.mutation.CreatedAt(); exists {
  477. s.SetIgnore(securitysecret.FieldCreatedAt)
  478. }
  479. }
  480. }))
  481. return u
  482. }
  483. // Ignore sets each column to itself in case of conflict.
  484. // Using this option is equivalent to using:
  485. //
  486. // client.SecuritySecret.Create().
  487. // OnConflict(sql.ResolveWithIgnore()).
  488. // Exec(ctx)
  489. func (u *SecuritySecretUpsertBulk) Ignore() *SecuritySecretUpsertBulk {
  490. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  491. return u
  492. }
  493. // DoNothing configures the conflict_action to `DO NOTHING`.
  494. // Supported only by SQLite and PostgreSQL.
  495. func (u *SecuritySecretUpsertBulk) DoNothing() *SecuritySecretUpsertBulk {
  496. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  497. return u
  498. }
  499. // Update allows overriding fields `UPDATE` values. See the SecuritySecretCreateBulk.OnConflict
  500. // documentation for more info.
  501. func (u *SecuritySecretUpsertBulk) Update(set func(*SecuritySecretUpsert)) *SecuritySecretUpsertBulk {
  502. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  503. set(&SecuritySecretUpsert{UpdateSet: update})
  504. }))
  505. return u
  506. }
  507. // SetUpdatedAt sets the "updated_at" field.
  508. func (u *SecuritySecretUpsertBulk) SetUpdatedAt(v time.Time) *SecuritySecretUpsertBulk {
  509. return u.Update(func(s *SecuritySecretUpsert) {
  510. s.SetUpdatedAt(v)
  511. })
  512. }
  513. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  514. func (u *SecuritySecretUpsertBulk) UpdateUpdatedAt() *SecuritySecretUpsertBulk {
  515. return u.Update(func(s *SecuritySecretUpsert) {
  516. s.UpdateUpdatedAt()
  517. })
  518. }
  519. // SetKey sets the "key" field.
  520. func (u *SecuritySecretUpsertBulk) SetKey(v string) *SecuritySecretUpsertBulk {
  521. return u.Update(func(s *SecuritySecretUpsert) {
  522. s.SetKey(v)
  523. })
  524. }
  525. // UpdateKey sets the "key" field to the value that was provided on create.
  526. func (u *SecuritySecretUpsertBulk) UpdateKey() *SecuritySecretUpsertBulk {
  527. return u.Update(func(s *SecuritySecretUpsert) {
  528. s.UpdateKey()
  529. })
  530. }
  531. // SetValue sets the "value" field.
  532. func (u *SecuritySecretUpsertBulk) SetValue(v string) *SecuritySecretUpsertBulk {
  533. return u.Update(func(s *SecuritySecretUpsert) {
  534. s.SetValue(v)
  535. })
  536. }
  537. // UpdateValue sets the "value" field to the value that was provided on create.
  538. func (u *SecuritySecretUpsertBulk) UpdateValue() *SecuritySecretUpsertBulk {
  539. return u.Update(func(s *SecuritySecretUpsert) {
  540. s.UpdateValue()
  541. })
  542. }
  543. // Exec executes the query.
  544. func (u *SecuritySecretUpsertBulk) Exec(ctx context.Context) error {
  545. if u.create.err != nil {
  546. return u.create.err
  547. }
  548. for i, b := range u.create.builders {
  549. if len(b.conflict) != 0 {
  550. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the SecuritySecretCreateBulk instead", i)
  551. }
  552. }
  553. if len(u.create.conflict) == 0 {
  554. return errors.New("ent: missing options for SecuritySecretCreateBulk.OnConflict")
  555. }
  556. return u.create.Exec(ctx)
  557. }
  558. // ExecX is like Exec, but panics if an error occurs.
  559. func (u *SecuritySecretUpsertBulk) ExecX(ctx context.Context) {
  560. if err := u.create.Exec(ctx); err != nil {
  561. panic(err)
  562. }
  563. }