compositemodelroute_create.go 41 KB

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