sopnode_create.go 35 KB

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