sopnode_create.go 36 KB

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