sopnode_create.go 39 KB

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