agentbase_create.go 33 KB

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