messagerecords_create.go 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "wechat-api/ent/contact"
  9. "wechat-api/ent/custom_types"
  10. "wechat-api/ent/messagerecords"
  11. "wechat-api/ent/sopnode"
  12. "wechat-api/ent/sopstage"
  13. "entgo.io/ent/dialect/sql"
  14. "entgo.io/ent/dialect/sql/sqlgraph"
  15. "entgo.io/ent/schema/field"
  16. )
  17. // MessageRecordsCreate is the builder for creating a MessageRecords entity.
  18. type MessageRecordsCreate struct {
  19. config
  20. mutation *MessageRecordsMutation
  21. hooks []Hook
  22. conflict []sql.ConflictOption
  23. }
  24. // SetCreatedAt sets the "created_at" field.
  25. func (mrc *MessageRecordsCreate) SetCreatedAt(t time.Time) *MessageRecordsCreate {
  26. mrc.mutation.SetCreatedAt(t)
  27. return mrc
  28. }
  29. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  30. func (mrc *MessageRecordsCreate) SetNillableCreatedAt(t *time.Time) *MessageRecordsCreate {
  31. if t != nil {
  32. mrc.SetCreatedAt(*t)
  33. }
  34. return mrc
  35. }
  36. // SetUpdatedAt sets the "updated_at" field.
  37. func (mrc *MessageRecordsCreate) SetUpdatedAt(t time.Time) *MessageRecordsCreate {
  38. mrc.mutation.SetUpdatedAt(t)
  39. return mrc
  40. }
  41. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  42. func (mrc *MessageRecordsCreate) SetNillableUpdatedAt(t *time.Time) *MessageRecordsCreate {
  43. if t != nil {
  44. mrc.SetUpdatedAt(*t)
  45. }
  46. return mrc
  47. }
  48. // SetStatus sets the "status" field.
  49. func (mrc *MessageRecordsCreate) SetStatus(u uint8) *MessageRecordsCreate {
  50. mrc.mutation.SetStatus(u)
  51. return mrc
  52. }
  53. // SetNillableStatus sets the "status" field if the given value is not nil.
  54. func (mrc *MessageRecordsCreate) SetNillableStatus(u *uint8) *MessageRecordsCreate {
  55. if u != nil {
  56. mrc.SetStatus(*u)
  57. }
  58. return mrc
  59. }
  60. // SetBotWxid sets the "bot_wxid" field.
  61. func (mrc *MessageRecordsCreate) SetBotWxid(s string) *MessageRecordsCreate {
  62. mrc.mutation.SetBotWxid(s)
  63. return mrc
  64. }
  65. // SetContactID sets the "contact_id" field.
  66. func (mrc *MessageRecordsCreate) SetContactID(u uint64) *MessageRecordsCreate {
  67. mrc.mutation.SetContactID(u)
  68. return mrc
  69. }
  70. // SetNillableContactID sets the "contact_id" field if the given value is not nil.
  71. func (mrc *MessageRecordsCreate) SetNillableContactID(u *uint64) *MessageRecordsCreate {
  72. if u != nil {
  73. mrc.SetContactID(*u)
  74. }
  75. return mrc
  76. }
  77. // SetContactType sets the "contact_type" field.
  78. func (mrc *MessageRecordsCreate) SetContactType(i int) *MessageRecordsCreate {
  79. mrc.mutation.SetContactType(i)
  80. return mrc
  81. }
  82. // SetNillableContactType sets the "contact_type" field if the given value is not nil.
  83. func (mrc *MessageRecordsCreate) SetNillableContactType(i *int) *MessageRecordsCreate {
  84. if i != nil {
  85. mrc.SetContactType(*i)
  86. }
  87. return mrc
  88. }
  89. // SetContactWxid sets the "contact_wxid" field.
  90. func (mrc *MessageRecordsCreate) SetContactWxid(s string) *MessageRecordsCreate {
  91. mrc.mutation.SetContactWxid(s)
  92. return mrc
  93. }
  94. // SetNillableContactWxid sets the "contact_wxid" field if the given value is not nil.
  95. func (mrc *MessageRecordsCreate) SetNillableContactWxid(s *string) *MessageRecordsCreate {
  96. if s != nil {
  97. mrc.SetContactWxid(*s)
  98. }
  99. return mrc
  100. }
  101. // SetContentType sets the "content_type" field.
  102. func (mrc *MessageRecordsCreate) SetContentType(i int) *MessageRecordsCreate {
  103. mrc.mutation.SetContentType(i)
  104. return mrc
  105. }
  106. // SetNillableContentType sets the "content_type" field if the given value is not nil.
  107. func (mrc *MessageRecordsCreate) SetNillableContentType(i *int) *MessageRecordsCreate {
  108. if i != nil {
  109. mrc.SetContentType(*i)
  110. }
  111. return mrc
  112. }
  113. // SetContent sets the "content" field.
  114. func (mrc *MessageRecordsCreate) SetContent(s string) *MessageRecordsCreate {
  115. mrc.mutation.SetContent(s)
  116. return mrc
  117. }
  118. // SetNillableContent sets the "content" field if the given value is not nil.
  119. func (mrc *MessageRecordsCreate) SetNillableContent(s *string) *MessageRecordsCreate {
  120. if s != nil {
  121. mrc.SetContent(*s)
  122. }
  123. return mrc
  124. }
  125. // SetMeta sets the "meta" field.
  126. func (mrc *MessageRecordsCreate) SetMeta(ct custom_types.Meta) *MessageRecordsCreate {
  127. mrc.mutation.SetMeta(ct)
  128. return mrc
  129. }
  130. // SetNillableMeta sets the "meta" field if the given value is not nil.
  131. func (mrc *MessageRecordsCreate) SetNillableMeta(ct *custom_types.Meta) *MessageRecordsCreate {
  132. if ct != nil {
  133. mrc.SetMeta(*ct)
  134. }
  135. return mrc
  136. }
  137. // SetErrorDetail sets the "error_detail" field.
  138. func (mrc *MessageRecordsCreate) SetErrorDetail(s string) *MessageRecordsCreate {
  139. mrc.mutation.SetErrorDetail(s)
  140. return mrc
  141. }
  142. // SetNillableErrorDetail sets the "error_detail" field if the given value is not nil.
  143. func (mrc *MessageRecordsCreate) SetNillableErrorDetail(s *string) *MessageRecordsCreate {
  144. if s != nil {
  145. mrc.SetErrorDetail(*s)
  146. }
  147. return mrc
  148. }
  149. // SetSendTime sets the "send_time" field.
  150. func (mrc *MessageRecordsCreate) SetSendTime(t time.Time) *MessageRecordsCreate {
  151. mrc.mutation.SetSendTime(t)
  152. return mrc
  153. }
  154. // SetNillableSendTime sets the "send_time" field if the given value is not nil.
  155. func (mrc *MessageRecordsCreate) SetNillableSendTime(t *time.Time) *MessageRecordsCreate {
  156. if t != nil {
  157. mrc.SetSendTime(*t)
  158. }
  159. return mrc
  160. }
  161. // SetSourceType sets the "source_type" field.
  162. func (mrc *MessageRecordsCreate) SetSourceType(i int) *MessageRecordsCreate {
  163. mrc.mutation.SetSourceType(i)
  164. return mrc
  165. }
  166. // SetNillableSourceType sets the "source_type" field if the given value is not nil.
  167. func (mrc *MessageRecordsCreate) SetNillableSourceType(i *int) *MessageRecordsCreate {
  168. if i != nil {
  169. mrc.SetSourceType(*i)
  170. }
  171. return mrc
  172. }
  173. // SetSourceID sets the "source_id" field.
  174. func (mrc *MessageRecordsCreate) SetSourceID(u uint64) *MessageRecordsCreate {
  175. mrc.mutation.SetSourceID(u)
  176. return mrc
  177. }
  178. // SetNillableSourceID sets the "source_id" field if the given value is not nil.
  179. func (mrc *MessageRecordsCreate) SetNillableSourceID(u *uint64) *MessageRecordsCreate {
  180. if u != nil {
  181. mrc.SetSourceID(*u)
  182. }
  183. return mrc
  184. }
  185. // SetSubSourceID sets the "sub_source_id" field.
  186. func (mrc *MessageRecordsCreate) SetSubSourceID(u uint64) *MessageRecordsCreate {
  187. mrc.mutation.SetSubSourceID(u)
  188. return mrc
  189. }
  190. // SetNillableSubSourceID sets the "sub_source_id" field if the given value is not nil.
  191. func (mrc *MessageRecordsCreate) SetNillableSubSourceID(u *uint64) *MessageRecordsCreate {
  192. if u != nil {
  193. mrc.SetSubSourceID(*u)
  194. }
  195. return mrc
  196. }
  197. // SetOrganizationID sets the "organization_id" field.
  198. func (mrc *MessageRecordsCreate) SetOrganizationID(u uint64) *MessageRecordsCreate {
  199. mrc.mutation.SetOrganizationID(u)
  200. return mrc
  201. }
  202. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  203. func (mrc *MessageRecordsCreate) SetNillableOrganizationID(u *uint64) *MessageRecordsCreate {
  204. if u != nil {
  205. mrc.SetOrganizationID(*u)
  206. }
  207. return mrc
  208. }
  209. // SetID sets the "id" field.
  210. func (mrc *MessageRecordsCreate) SetID(u uint64) *MessageRecordsCreate {
  211. mrc.mutation.SetID(u)
  212. return mrc
  213. }
  214. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by ID.
  215. func (mrc *MessageRecordsCreate) SetSopStageID(id uint64) *MessageRecordsCreate {
  216. mrc.mutation.SetSopStageID(id)
  217. return mrc
  218. }
  219. // SetNillableSopStageID sets the "sop_stage" edge to the SopStage entity by ID if the given value is not nil.
  220. func (mrc *MessageRecordsCreate) SetNillableSopStageID(id *uint64) *MessageRecordsCreate {
  221. if id != nil {
  222. mrc = mrc.SetSopStageID(*id)
  223. }
  224. return mrc
  225. }
  226. // SetSopStage sets the "sop_stage" edge to the SopStage entity.
  227. func (mrc *MessageRecordsCreate) SetSopStage(s *SopStage) *MessageRecordsCreate {
  228. return mrc.SetSopStageID(s.ID)
  229. }
  230. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by ID.
  231. func (mrc *MessageRecordsCreate) SetSopNodeID(id uint64) *MessageRecordsCreate {
  232. mrc.mutation.SetSopNodeID(id)
  233. return mrc
  234. }
  235. // SetNillableSopNodeID sets the "sop_node" edge to the SopNode entity by ID if the given value is not nil.
  236. func (mrc *MessageRecordsCreate) SetNillableSopNodeID(id *uint64) *MessageRecordsCreate {
  237. if id != nil {
  238. mrc = mrc.SetSopNodeID(*id)
  239. }
  240. return mrc
  241. }
  242. // SetSopNode sets the "sop_node" edge to the SopNode entity.
  243. func (mrc *MessageRecordsCreate) SetSopNode(s *SopNode) *MessageRecordsCreate {
  244. return mrc.SetSopNodeID(s.ID)
  245. }
  246. // SetMessageContactID sets the "message_contact" edge to the Contact entity by ID.
  247. func (mrc *MessageRecordsCreate) SetMessageContactID(id uint64) *MessageRecordsCreate {
  248. mrc.mutation.SetMessageContactID(id)
  249. return mrc
  250. }
  251. // SetNillableMessageContactID sets the "message_contact" edge to the Contact entity by ID if the given value is not nil.
  252. func (mrc *MessageRecordsCreate) SetNillableMessageContactID(id *uint64) *MessageRecordsCreate {
  253. if id != nil {
  254. mrc = mrc.SetMessageContactID(*id)
  255. }
  256. return mrc
  257. }
  258. // SetMessageContact sets the "message_contact" edge to the Contact entity.
  259. func (mrc *MessageRecordsCreate) SetMessageContact(c *Contact) *MessageRecordsCreate {
  260. return mrc.SetMessageContactID(c.ID)
  261. }
  262. // Mutation returns the MessageRecordsMutation object of the builder.
  263. func (mrc *MessageRecordsCreate) Mutation() *MessageRecordsMutation {
  264. return mrc.mutation
  265. }
  266. // Save creates the MessageRecords in the database.
  267. func (mrc *MessageRecordsCreate) Save(ctx context.Context) (*MessageRecords, error) {
  268. mrc.defaults()
  269. return withHooks(ctx, mrc.sqlSave, mrc.mutation, mrc.hooks)
  270. }
  271. // SaveX calls Save and panics if Save returns an error.
  272. func (mrc *MessageRecordsCreate) SaveX(ctx context.Context) *MessageRecords {
  273. v, err := mrc.Save(ctx)
  274. if err != nil {
  275. panic(err)
  276. }
  277. return v
  278. }
  279. // Exec executes the query.
  280. func (mrc *MessageRecordsCreate) Exec(ctx context.Context) error {
  281. _, err := mrc.Save(ctx)
  282. return err
  283. }
  284. // ExecX is like Exec, but panics if an error occurs.
  285. func (mrc *MessageRecordsCreate) ExecX(ctx context.Context) {
  286. if err := mrc.Exec(ctx); err != nil {
  287. panic(err)
  288. }
  289. }
  290. // defaults sets the default values of the builder before save.
  291. func (mrc *MessageRecordsCreate) defaults() {
  292. if _, ok := mrc.mutation.CreatedAt(); !ok {
  293. v := messagerecords.DefaultCreatedAt()
  294. mrc.mutation.SetCreatedAt(v)
  295. }
  296. if _, ok := mrc.mutation.UpdatedAt(); !ok {
  297. v := messagerecords.DefaultUpdatedAt()
  298. mrc.mutation.SetUpdatedAt(v)
  299. }
  300. if _, ok := mrc.mutation.Status(); !ok {
  301. v := messagerecords.DefaultStatus
  302. mrc.mutation.SetStatus(v)
  303. }
  304. if _, ok := mrc.mutation.ContactType(); !ok {
  305. v := messagerecords.DefaultContactType
  306. mrc.mutation.SetContactType(v)
  307. }
  308. if _, ok := mrc.mutation.ContactWxid(); !ok {
  309. v := messagerecords.DefaultContactWxid
  310. mrc.mutation.SetContactWxid(v)
  311. }
  312. if _, ok := mrc.mutation.ContentType(); !ok {
  313. v := messagerecords.DefaultContentType
  314. mrc.mutation.SetContentType(v)
  315. }
  316. if _, ok := mrc.mutation.Content(); !ok {
  317. v := messagerecords.DefaultContent
  318. mrc.mutation.SetContent(v)
  319. }
  320. if _, ok := mrc.mutation.ErrorDetail(); !ok {
  321. v := messagerecords.DefaultErrorDetail
  322. mrc.mutation.SetErrorDetail(v)
  323. }
  324. if _, ok := mrc.mutation.SourceType(); !ok {
  325. v := messagerecords.DefaultSourceType
  326. mrc.mutation.SetSourceType(v)
  327. }
  328. if _, ok := mrc.mutation.SourceID(); !ok {
  329. v := messagerecords.DefaultSourceID
  330. mrc.mutation.SetSourceID(v)
  331. }
  332. if _, ok := mrc.mutation.SubSourceID(); !ok {
  333. v := messagerecords.DefaultSubSourceID
  334. mrc.mutation.SetSubSourceID(v)
  335. }
  336. if _, ok := mrc.mutation.OrganizationID(); !ok {
  337. v := messagerecords.DefaultOrganizationID
  338. mrc.mutation.SetOrganizationID(v)
  339. }
  340. }
  341. // check runs all checks and user-defined validators on the builder.
  342. func (mrc *MessageRecordsCreate) check() error {
  343. if _, ok := mrc.mutation.CreatedAt(); !ok {
  344. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "MessageRecords.created_at"`)}
  345. }
  346. if _, ok := mrc.mutation.UpdatedAt(); !ok {
  347. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "MessageRecords.updated_at"`)}
  348. }
  349. if _, ok := mrc.mutation.BotWxid(); !ok {
  350. return &ValidationError{Name: "bot_wxid", err: errors.New(`ent: missing required field "MessageRecords.bot_wxid"`)}
  351. }
  352. if _, ok := mrc.mutation.ContactType(); !ok {
  353. return &ValidationError{Name: "contact_type", err: errors.New(`ent: missing required field "MessageRecords.contact_type"`)}
  354. }
  355. if _, ok := mrc.mutation.ContactWxid(); !ok {
  356. return &ValidationError{Name: "contact_wxid", err: errors.New(`ent: missing required field "MessageRecords.contact_wxid"`)}
  357. }
  358. if _, ok := mrc.mutation.ContentType(); !ok {
  359. return &ValidationError{Name: "content_type", err: errors.New(`ent: missing required field "MessageRecords.content_type"`)}
  360. }
  361. if _, ok := mrc.mutation.Content(); !ok {
  362. return &ValidationError{Name: "content", err: errors.New(`ent: missing required field "MessageRecords.content"`)}
  363. }
  364. if _, ok := mrc.mutation.ErrorDetail(); !ok {
  365. return &ValidationError{Name: "error_detail", err: errors.New(`ent: missing required field "MessageRecords.error_detail"`)}
  366. }
  367. if _, ok := mrc.mutation.SourceType(); !ok {
  368. return &ValidationError{Name: "source_type", err: errors.New(`ent: missing required field "MessageRecords.source_type"`)}
  369. }
  370. return nil
  371. }
  372. func (mrc *MessageRecordsCreate) sqlSave(ctx context.Context) (*MessageRecords, error) {
  373. if err := mrc.check(); err != nil {
  374. return nil, err
  375. }
  376. _node, _spec := mrc.createSpec()
  377. if err := sqlgraph.CreateNode(ctx, mrc.driver, _spec); err != nil {
  378. if sqlgraph.IsConstraintError(err) {
  379. err = &ConstraintError{msg: err.Error(), wrap: err}
  380. }
  381. return nil, err
  382. }
  383. if _spec.ID.Value != _node.ID {
  384. id := _spec.ID.Value.(int64)
  385. _node.ID = uint64(id)
  386. }
  387. mrc.mutation.id = &_node.ID
  388. mrc.mutation.done = true
  389. return _node, nil
  390. }
  391. func (mrc *MessageRecordsCreate) createSpec() (*MessageRecords, *sqlgraph.CreateSpec) {
  392. var (
  393. _node = &MessageRecords{config: mrc.config}
  394. _spec = sqlgraph.NewCreateSpec(messagerecords.Table, sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64))
  395. )
  396. _spec.OnConflict = mrc.conflict
  397. if id, ok := mrc.mutation.ID(); ok {
  398. _node.ID = id
  399. _spec.ID.Value = id
  400. }
  401. if value, ok := mrc.mutation.CreatedAt(); ok {
  402. _spec.SetField(messagerecords.FieldCreatedAt, field.TypeTime, value)
  403. _node.CreatedAt = value
  404. }
  405. if value, ok := mrc.mutation.UpdatedAt(); ok {
  406. _spec.SetField(messagerecords.FieldUpdatedAt, field.TypeTime, value)
  407. _node.UpdatedAt = value
  408. }
  409. if value, ok := mrc.mutation.Status(); ok {
  410. _spec.SetField(messagerecords.FieldStatus, field.TypeUint8, value)
  411. _node.Status = value
  412. }
  413. if value, ok := mrc.mutation.BotWxid(); ok {
  414. _spec.SetField(messagerecords.FieldBotWxid, field.TypeString, value)
  415. _node.BotWxid = value
  416. }
  417. if value, ok := mrc.mutation.ContactType(); ok {
  418. _spec.SetField(messagerecords.FieldContactType, field.TypeInt, value)
  419. _node.ContactType = value
  420. }
  421. if value, ok := mrc.mutation.ContactWxid(); ok {
  422. _spec.SetField(messagerecords.FieldContactWxid, field.TypeString, value)
  423. _node.ContactWxid = value
  424. }
  425. if value, ok := mrc.mutation.ContentType(); ok {
  426. _spec.SetField(messagerecords.FieldContentType, field.TypeInt, value)
  427. _node.ContentType = value
  428. }
  429. if value, ok := mrc.mutation.Content(); ok {
  430. _spec.SetField(messagerecords.FieldContent, field.TypeString, value)
  431. _node.Content = value
  432. }
  433. if value, ok := mrc.mutation.Meta(); ok {
  434. _spec.SetField(messagerecords.FieldMeta, field.TypeJSON, value)
  435. _node.Meta = value
  436. }
  437. if value, ok := mrc.mutation.ErrorDetail(); ok {
  438. _spec.SetField(messagerecords.FieldErrorDetail, field.TypeString, value)
  439. _node.ErrorDetail = value
  440. }
  441. if value, ok := mrc.mutation.SendTime(); ok {
  442. _spec.SetField(messagerecords.FieldSendTime, field.TypeTime, value)
  443. _node.SendTime = value
  444. }
  445. if value, ok := mrc.mutation.SourceType(); ok {
  446. _spec.SetField(messagerecords.FieldSourceType, field.TypeInt, value)
  447. _node.SourceType = value
  448. }
  449. if value, ok := mrc.mutation.OrganizationID(); ok {
  450. _spec.SetField(messagerecords.FieldOrganizationID, field.TypeUint64, value)
  451. _node.OrganizationID = value
  452. }
  453. if nodes := mrc.mutation.SopStageIDs(); len(nodes) > 0 {
  454. edge := &sqlgraph.EdgeSpec{
  455. Rel: sqlgraph.M2O,
  456. Inverse: true,
  457. Table: messagerecords.SopStageTable,
  458. Columns: []string{messagerecords.SopStageColumn},
  459. Bidi: false,
  460. Target: &sqlgraph.EdgeTarget{
  461. IDSpec: sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64),
  462. },
  463. }
  464. for _, k := range nodes {
  465. edge.Target.Nodes = append(edge.Target.Nodes, k)
  466. }
  467. _node.SourceID = nodes[0]
  468. _spec.Edges = append(_spec.Edges, edge)
  469. }
  470. if nodes := mrc.mutation.SopNodeIDs(); len(nodes) > 0 {
  471. edge := &sqlgraph.EdgeSpec{
  472. Rel: sqlgraph.M2O,
  473. Inverse: true,
  474. Table: messagerecords.SopNodeTable,
  475. Columns: []string{messagerecords.SopNodeColumn},
  476. Bidi: false,
  477. Target: &sqlgraph.EdgeTarget{
  478. IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
  479. },
  480. }
  481. for _, k := range nodes {
  482. edge.Target.Nodes = append(edge.Target.Nodes, k)
  483. }
  484. _node.SubSourceID = nodes[0]
  485. _spec.Edges = append(_spec.Edges, edge)
  486. }
  487. if nodes := mrc.mutation.MessageContactIDs(); len(nodes) > 0 {
  488. edge := &sqlgraph.EdgeSpec{
  489. Rel: sqlgraph.M2O,
  490. Inverse: true,
  491. Table: messagerecords.MessageContactTable,
  492. Columns: []string{messagerecords.MessageContactColumn},
  493. Bidi: false,
  494. Target: &sqlgraph.EdgeTarget{
  495. IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64),
  496. },
  497. }
  498. for _, k := range nodes {
  499. edge.Target.Nodes = append(edge.Target.Nodes, k)
  500. }
  501. _node.ContactID = nodes[0]
  502. _spec.Edges = append(_spec.Edges, edge)
  503. }
  504. return _node, _spec
  505. }
  506. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  507. // of the `INSERT` statement. For example:
  508. //
  509. // client.MessageRecords.Create().
  510. // SetCreatedAt(v).
  511. // OnConflict(
  512. // // Update the row with the new values
  513. // // the was proposed for insertion.
  514. // sql.ResolveWithNewValues(),
  515. // ).
  516. // // Override some of the fields with custom
  517. // // update values.
  518. // Update(func(u *ent.MessageRecordsUpsert) {
  519. // SetCreatedAt(v+v).
  520. // }).
  521. // Exec(ctx)
  522. func (mrc *MessageRecordsCreate) OnConflict(opts ...sql.ConflictOption) *MessageRecordsUpsertOne {
  523. mrc.conflict = opts
  524. return &MessageRecordsUpsertOne{
  525. create: mrc,
  526. }
  527. }
  528. // OnConflictColumns calls `OnConflict` and configures the columns
  529. // as conflict target. Using this option is equivalent to using:
  530. //
  531. // client.MessageRecords.Create().
  532. // OnConflict(sql.ConflictColumns(columns...)).
  533. // Exec(ctx)
  534. func (mrc *MessageRecordsCreate) OnConflictColumns(columns ...string) *MessageRecordsUpsertOne {
  535. mrc.conflict = append(mrc.conflict, sql.ConflictColumns(columns...))
  536. return &MessageRecordsUpsertOne{
  537. create: mrc,
  538. }
  539. }
  540. type (
  541. // MessageRecordsUpsertOne is the builder for "upsert"-ing
  542. // one MessageRecords node.
  543. MessageRecordsUpsertOne struct {
  544. create *MessageRecordsCreate
  545. }
  546. // MessageRecordsUpsert is the "OnConflict" setter.
  547. MessageRecordsUpsert struct {
  548. *sql.UpdateSet
  549. }
  550. )
  551. // SetUpdatedAt sets the "updated_at" field.
  552. func (u *MessageRecordsUpsert) SetUpdatedAt(v time.Time) *MessageRecordsUpsert {
  553. u.Set(messagerecords.FieldUpdatedAt, v)
  554. return u
  555. }
  556. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  557. func (u *MessageRecordsUpsert) UpdateUpdatedAt() *MessageRecordsUpsert {
  558. u.SetExcluded(messagerecords.FieldUpdatedAt)
  559. return u
  560. }
  561. // SetStatus sets the "status" field.
  562. func (u *MessageRecordsUpsert) SetStatus(v uint8) *MessageRecordsUpsert {
  563. u.Set(messagerecords.FieldStatus, v)
  564. return u
  565. }
  566. // UpdateStatus sets the "status" field to the value that was provided on create.
  567. func (u *MessageRecordsUpsert) UpdateStatus() *MessageRecordsUpsert {
  568. u.SetExcluded(messagerecords.FieldStatus)
  569. return u
  570. }
  571. // AddStatus adds v to the "status" field.
  572. func (u *MessageRecordsUpsert) AddStatus(v uint8) *MessageRecordsUpsert {
  573. u.Add(messagerecords.FieldStatus, v)
  574. return u
  575. }
  576. // ClearStatus clears the value of the "status" field.
  577. func (u *MessageRecordsUpsert) ClearStatus() *MessageRecordsUpsert {
  578. u.SetNull(messagerecords.FieldStatus)
  579. return u
  580. }
  581. // SetBotWxid sets the "bot_wxid" field.
  582. func (u *MessageRecordsUpsert) SetBotWxid(v string) *MessageRecordsUpsert {
  583. u.Set(messagerecords.FieldBotWxid, v)
  584. return u
  585. }
  586. // UpdateBotWxid sets the "bot_wxid" field to the value that was provided on create.
  587. func (u *MessageRecordsUpsert) UpdateBotWxid() *MessageRecordsUpsert {
  588. u.SetExcluded(messagerecords.FieldBotWxid)
  589. return u
  590. }
  591. // SetContactID sets the "contact_id" field.
  592. func (u *MessageRecordsUpsert) SetContactID(v uint64) *MessageRecordsUpsert {
  593. u.Set(messagerecords.FieldContactID, v)
  594. return u
  595. }
  596. // UpdateContactID sets the "contact_id" field to the value that was provided on create.
  597. func (u *MessageRecordsUpsert) UpdateContactID() *MessageRecordsUpsert {
  598. u.SetExcluded(messagerecords.FieldContactID)
  599. return u
  600. }
  601. // ClearContactID clears the value of the "contact_id" field.
  602. func (u *MessageRecordsUpsert) ClearContactID() *MessageRecordsUpsert {
  603. u.SetNull(messagerecords.FieldContactID)
  604. return u
  605. }
  606. // SetContactType sets the "contact_type" field.
  607. func (u *MessageRecordsUpsert) SetContactType(v int) *MessageRecordsUpsert {
  608. u.Set(messagerecords.FieldContactType, v)
  609. return u
  610. }
  611. // UpdateContactType sets the "contact_type" field to the value that was provided on create.
  612. func (u *MessageRecordsUpsert) UpdateContactType() *MessageRecordsUpsert {
  613. u.SetExcluded(messagerecords.FieldContactType)
  614. return u
  615. }
  616. // AddContactType adds v to the "contact_type" field.
  617. func (u *MessageRecordsUpsert) AddContactType(v int) *MessageRecordsUpsert {
  618. u.Add(messagerecords.FieldContactType, v)
  619. return u
  620. }
  621. // SetContactWxid sets the "contact_wxid" field.
  622. func (u *MessageRecordsUpsert) SetContactWxid(v string) *MessageRecordsUpsert {
  623. u.Set(messagerecords.FieldContactWxid, v)
  624. return u
  625. }
  626. // UpdateContactWxid sets the "contact_wxid" field to the value that was provided on create.
  627. func (u *MessageRecordsUpsert) UpdateContactWxid() *MessageRecordsUpsert {
  628. u.SetExcluded(messagerecords.FieldContactWxid)
  629. return u
  630. }
  631. // SetContentType sets the "content_type" field.
  632. func (u *MessageRecordsUpsert) SetContentType(v int) *MessageRecordsUpsert {
  633. u.Set(messagerecords.FieldContentType, v)
  634. return u
  635. }
  636. // UpdateContentType sets the "content_type" field to the value that was provided on create.
  637. func (u *MessageRecordsUpsert) UpdateContentType() *MessageRecordsUpsert {
  638. u.SetExcluded(messagerecords.FieldContentType)
  639. return u
  640. }
  641. // AddContentType adds v to the "content_type" field.
  642. func (u *MessageRecordsUpsert) AddContentType(v int) *MessageRecordsUpsert {
  643. u.Add(messagerecords.FieldContentType, v)
  644. return u
  645. }
  646. // SetContent sets the "content" field.
  647. func (u *MessageRecordsUpsert) SetContent(v string) *MessageRecordsUpsert {
  648. u.Set(messagerecords.FieldContent, v)
  649. return u
  650. }
  651. // UpdateContent sets the "content" field to the value that was provided on create.
  652. func (u *MessageRecordsUpsert) UpdateContent() *MessageRecordsUpsert {
  653. u.SetExcluded(messagerecords.FieldContent)
  654. return u
  655. }
  656. // SetMeta sets the "meta" field.
  657. func (u *MessageRecordsUpsert) SetMeta(v custom_types.Meta) *MessageRecordsUpsert {
  658. u.Set(messagerecords.FieldMeta, v)
  659. return u
  660. }
  661. // UpdateMeta sets the "meta" field to the value that was provided on create.
  662. func (u *MessageRecordsUpsert) UpdateMeta() *MessageRecordsUpsert {
  663. u.SetExcluded(messagerecords.FieldMeta)
  664. return u
  665. }
  666. // ClearMeta clears the value of the "meta" field.
  667. func (u *MessageRecordsUpsert) ClearMeta() *MessageRecordsUpsert {
  668. u.SetNull(messagerecords.FieldMeta)
  669. return u
  670. }
  671. // SetErrorDetail sets the "error_detail" field.
  672. func (u *MessageRecordsUpsert) SetErrorDetail(v string) *MessageRecordsUpsert {
  673. u.Set(messagerecords.FieldErrorDetail, v)
  674. return u
  675. }
  676. // UpdateErrorDetail sets the "error_detail" field to the value that was provided on create.
  677. func (u *MessageRecordsUpsert) UpdateErrorDetail() *MessageRecordsUpsert {
  678. u.SetExcluded(messagerecords.FieldErrorDetail)
  679. return u
  680. }
  681. // SetSendTime sets the "send_time" field.
  682. func (u *MessageRecordsUpsert) SetSendTime(v time.Time) *MessageRecordsUpsert {
  683. u.Set(messagerecords.FieldSendTime, v)
  684. return u
  685. }
  686. // UpdateSendTime sets the "send_time" field to the value that was provided on create.
  687. func (u *MessageRecordsUpsert) UpdateSendTime() *MessageRecordsUpsert {
  688. u.SetExcluded(messagerecords.FieldSendTime)
  689. return u
  690. }
  691. // ClearSendTime clears the value of the "send_time" field.
  692. func (u *MessageRecordsUpsert) ClearSendTime() *MessageRecordsUpsert {
  693. u.SetNull(messagerecords.FieldSendTime)
  694. return u
  695. }
  696. // SetSourceType sets the "source_type" field.
  697. func (u *MessageRecordsUpsert) SetSourceType(v int) *MessageRecordsUpsert {
  698. u.Set(messagerecords.FieldSourceType, v)
  699. return u
  700. }
  701. // UpdateSourceType sets the "source_type" field to the value that was provided on create.
  702. func (u *MessageRecordsUpsert) UpdateSourceType() *MessageRecordsUpsert {
  703. u.SetExcluded(messagerecords.FieldSourceType)
  704. return u
  705. }
  706. // AddSourceType adds v to the "source_type" field.
  707. func (u *MessageRecordsUpsert) AddSourceType(v int) *MessageRecordsUpsert {
  708. u.Add(messagerecords.FieldSourceType, v)
  709. return u
  710. }
  711. // SetSourceID sets the "source_id" field.
  712. func (u *MessageRecordsUpsert) SetSourceID(v uint64) *MessageRecordsUpsert {
  713. u.Set(messagerecords.FieldSourceID, v)
  714. return u
  715. }
  716. // UpdateSourceID sets the "source_id" field to the value that was provided on create.
  717. func (u *MessageRecordsUpsert) UpdateSourceID() *MessageRecordsUpsert {
  718. u.SetExcluded(messagerecords.FieldSourceID)
  719. return u
  720. }
  721. // ClearSourceID clears the value of the "source_id" field.
  722. func (u *MessageRecordsUpsert) ClearSourceID() *MessageRecordsUpsert {
  723. u.SetNull(messagerecords.FieldSourceID)
  724. return u
  725. }
  726. // SetSubSourceID sets the "sub_source_id" field.
  727. func (u *MessageRecordsUpsert) SetSubSourceID(v uint64) *MessageRecordsUpsert {
  728. u.Set(messagerecords.FieldSubSourceID, v)
  729. return u
  730. }
  731. // UpdateSubSourceID sets the "sub_source_id" field to the value that was provided on create.
  732. func (u *MessageRecordsUpsert) UpdateSubSourceID() *MessageRecordsUpsert {
  733. u.SetExcluded(messagerecords.FieldSubSourceID)
  734. return u
  735. }
  736. // ClearSubSourceID clears the value of the "sub_source_id" field.
  737. func (u *MessageRecordsUpsert) ClearSubSourceID() *MessageRecordsUpsert {
  738. u.SetNull(messagerecords.FieldSubSourceID)
  739. return u
  740. }
  741. // SetOrganizationID sets the "organization_id" field.
  742. func (u *MessageRecordsUpsert) SetOrganizationID(v uint64) *MessageRecordsUpsert {
  743. u.Set(messagerecords.FieldOrganizationID, v)
  744. return u
  745. }
  746. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  747. func (u *MessageRecordsUpsert) UpdateOrganizationID() *MessageRecordsUpsert {
  748. u.SetExcluded(messagerecords.FieldOrganizationID)
  749. return u
  750. }
  751. // AddOrganizationID adds v to the "organization_id" field.
  752. func (u *MessageRecordsUpsert) AddOrganizationID(v uint64) *MessageRecordsUpsert {
  753. u.Add(messagerecords.FieldOrganizationID, v)
  754. return u
  755. }
  756. // ClearOrganizationID clears the value of the "organization_id" field.
  757. func (u *MessageRecordsUpsert) ClearOrganizationID() *MessageRecordsUpsert {
  758. u.SetNull(messagerecords.FieldOrganizationID)
  759. return u
  760. }
  761. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  762. // Using this option is equivalent to using:
  763. //
  764. // client.MessageRecords.Create().
  765. // OnConflict(
  766. // sql.ResolveWithNewValues(),
  767. // sql.ResolveWith(func(u *sql.UpdateSet) {
  768. // u.SetIgnore(messagerecords.FieldID)
  769. // }),
  770. // ).
  771. // Exec(ctx)
  772. func (u *MessageRecordsUpsertOne) UpdateNewValues() *MessageRecordsUpsertOne {
  773. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  774. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  775. if _, exists := u.create.mutation.ID(); exists {
  776. s.SetIgnore(messagerecords.FieldID)
  777. }
  778. if _, exists := u.create.mutation.CreatedAt(); exists {
  779. s.SetIgnore(messagerecords.FieldCreatedAt)
  780. }
  781. }))
  782. return u
  783. }
  784. // Ignore sets each column to itself in case of conflict.
  785. // Using this option is equivalent to using:
  786. //
  787. // client.MessageRecords.Create().
  788. // OnConflict(sql.ResolveWithIgnore()).
  789. // Exec(ctx)
  790. func (u *MessageRecordsUpsertOne) Ignore() *MessageRecordsUpsertOne {
  791. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  792. return u
  793. }
  794. // DoNothing configures the conflict_action to `DO NOTHING`.
  795. // Supported only by SQLite and PostgreSQL.
  796. func (u *MessageRecordsUpsertOne) DoNothing() *MessageRecordsUpsertOne {
  797. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  798. return u
  799. }
  800. // Update allows overriding fields `UPDATE` values. See the MessageRecordsCreate.OnConflict
  801. // documentation for more info.
  802. func (u *MessageRecordsUpsertOne) Update(set func(*MessageRecordsUpsert)) *MessageRecordsUpsertOne {
  803. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  804. set(&MessageRecordsUpsert{UpdateSet: update})
  805. }))
  806. return u
  807. }
  808. // SetUpdatedAt sets the "updated_at" field.
  809. func (u *MessageRecordsUpsertOne) SetUpdatedAt(v time.Time) *MessageRecordsUpsertOne {
  810. return u.Update(func(s *MessageRecordsUpsert) {
  811. s.SetUpdatedAt(v)
  812. })
  813. }
  814. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  815. func (u *MessageRecordsUpsertOne) UpdateUpdatedAt() *MessageRecordsUpsertOne {
  816. return u.Update(func(s *MessageRecordsUpsert) {
  817. s.UpdateUpdatedAt()
  818. })
  819. }
  820. // SetStatus sets the "status" field.
  821. func (u *MessageRecordsUpsertOne) SetStatus(v uint8) *MessageRecordsUpsertOne {
  822. return u.Update(func(s *MessageRecordsUpsert) {
  823. s.SetStatus(v)
  824. })
  825. }
  826. // AddStatus adds v to the "status" field.
  827. func (u *MessageRecordsUpsertOne) AddStatus(v uint8) *MessageRecordsUpsertOne {
  828. return u.Update(func(s *MessageRecordsUpsert) {
  829. s.AddStatus(v)
  830. })
  831. }
  832. // UpdateStatus sets the "status" field to the value that was provided on create.
  833. func (u *MessageRecordsUpsertOne) UpdateStatus() *MessageRecordsUpsertOne {
  834. return u.Update(func(s *MessageRecordsUpsert) {
  835. s.UpdateStatus()
  836. })
  837. }
  838. // ClearStatus clears the value of the "status" field.
  839. func (u *MessageRecordsUpsertOne) ClearStatus() *MessageRecordsUpsertOne {
  840. return u.Update(func(s *MessageRecordsUpsert) {
  841. s.ClearStatus()
  842. })
  843. }
  844. // SetBotWxid sets the "bot_wxid" field.
  845. func (u *MessageRecordsUpsertOne) SetBotWxid(v string) *MessageRecordsUpsertOne {
  846. return u.Update(func(s *MessageRecordsUpsert) {
  847. s.SetBotWxid(v)
  848. })
  849. }
  850. // UpdateBotWxid sets the "bot_wxid" field to the value that was provided on create.
  851. func (u *MessageRecordsUpsertOne) UpdateBotWxid() *MessageRecordsUpsertOne {
  852. return u.Update(func(s *MessageRecordsUpsert) {
  853. s.UpdateBotWxid()
  854. })
  855. }
  856. // SetContactID sets the "contact_id" field.
  857. func (u *MessageRecordsUpsertOne) SetContactID(v uint64) *MessageRecordsUpsertOne {
  858. return u.Update(func(s *MessageRecordsUpsert) {
  859. s.SetContactID(v)
  860. })
  861. }
  862. // UpdateContactID sets the "contact_id" field to the value that was provided on create.
  863. func (u *MessageRecordsUpsertOne) UpdateContactID() *MessageRecordsUpsertOne {
  864. return u.Update(func(s *MessageRecordsUpsert) {
  865. s.UpdateContactID()
  866. })
  867. }
  868. // ClearContactID clears the value of the "contact_id" field.
  869. func (u *MessageRecordsUpsertOne) ClearContactID() *MessageRecordsUpsertOne {
  870. return u.Update(func(s *MessageRecordsUpsert) {
  871. s.ClearContactID()
  872. })
  873. }
  874. // SetContactType sets the "contact_type" field.
  875. func (u *MessageRecordsUpsertOne) SetContactType(v int) *MessageRecordsUpsertOne {
  876. return u.Update(func(s *MessageRecordsUpsert) {
  877. s.SetContactType(v)
  878. })
  879. }
  880. // AddContactType adds v to the "contact_type" field.
  881. func (u *MessageRecordsUpsertOne) AddContactType(v int) *MessageRecordsUpsertOne {
  882. return u.Update(func(s *MessageRecordsUpsert) {
  883. s.AddContactType(v)
  884. })
  885. }
  886. // UpdateContactType sets the "contact_type" field to the value that was provided on create.
  887. func (u *MessageRecordsUpsertOne) UpdateContactType() *MessageRecordsUpsertOne {
  888. return u.Update(func(s *MessageRecordsUpsert) {
  889. s.UpdateContactType()
  890. })
  891. }
  892. // SetContactWxid sets the "contact_wxid" field.
  893. func (u *MessageRecordsUpsertOne) SetContactWxid(v string) *MessageRecordsUpsertOne {
  894. return u.Update(func(s *MessageRecordsUpsert) {
  895. s.SetContactWxid(v)
  896. })
  897. }
  898. // UpdateContactWxid sets the "contact_wxid" field to the value that was provided on create.
  899. func (u *MessageRecordsUpsertOne) UpdateContactWxid() *MessageRecordsUpsertOne {
  900. return u.Update(func(s *MessageRecordsUpsert) {
  901. s.UpdateContactWxid()
  902. })
  903. }
  904. // SetContentType sets the "content_type" field.
  905. func (u *MessageRecordsUpsertOne) SetContentType(v int) *MessageRecordsUpsertOne {
  906. return u.Update(func(s *MessageRecordsUpsert) {
  907. s.SetContentType(v)
  908. })
  909. }
  910. // AddContentType adds v to the "content_type" field.
  911. func (u *MessageRecordsUpsertOne) AddContentType(v int) *MessageRecordsUpsertOne {
  912. return u.Update(func(s *MessageRecordsUpsert) {
  913. s.AddContentType(v)
  914. })
  915. }
  916. // UpdateContentType sets the "content_type" field to the value that was provided on create.
  917. func (u *MessageRecordsUpsertOne) UpdateContentType() *MessageRecordsUpsertOne {
  918. return u.Update(func(s *MessageRecordsUpsert) {
  919. s.UpdateContentType()
  920. })
  921. }
  922. // SetContent sets the "content" field.
  923. func (u *MessageRecordsUpsertOne) SetContent(v string) *MessageRecordsUpsertOne {
  924. return u.Update(func(s *MessageRecordsUpsert) {
  925. s.SetContent(v)
  926. })
  927. }
  928. // UpdateContent sets the "content" field to the value that was provided on create.
  929. func (u *MessageRecordsUpsertOne) UpdateContent() *MessageRecordsUpsertOne {
  930. return u.Update(func(s *MessageRecordsUpsert) {
  931. s.UpdateContent()
  932. })
  933. }
  934. // SetMeta sets the "meta" field.
  935. func (u *MessageRecordsUpsertOne) SetMeta(v custom_types.Meta) *MessageRecordsUpsertOne {
  936. return u.Update(func(s *MessageRecordsUpsert) {
  937. s.SetMeta(v)
  938. })
  939. }
  940. // UpdateMeta sets the "meta" field to the value that was provided on create.
  941. func (u *MessageRecordsUpsertOne) UpdateMeta() *MessageRecordsUpsertOne {
  942. return u.Update(func(s *MessageRecordsUpsert) {
  943. s.UpdateMeta()
  944. })
  945. }
  946. // ClearMeta clears the value of the "meta" field.
  947. func (u *MessageRecordsUpsertOne) ClearMeta() *MessageRecordsUpsertOne {
  948. return u.Update(func(s *MessageRecordsUpsert) {
  949. s.ClearMeta()
  950. })
  951. }
  952. // SetErrorDetail sets the "error_detail" field.
  953. func (u *MessageRecordsUpsertOne) SetErrorDetail(v string) *MessageRecordsUpsertOne {
  954. return u.Update(func(s *MessageRecordsUpsert) {
  955. s.SetErrorDetail(v)
  956. })
  957. }
  958. // UpdateErrorDetail sets the "error_detail" field to the value that was provided on create.
  959. func (u *MessageRecordsUpsertOne) UpdateErrorDetail() *MessageRecordsUpsertOne {
  960. return u.Update(func(s *MessageRecordsUpsert) {
  961. s.UpdateErrorDetail()
  962. })
  963. }
  964. // SetSendTime sets the "send_time" field.
  965. func (u *MessageRecordsUpsertOne) SetSendTime(v time.Time) *MessageRecordsUpsertOne {
  966. return u.Update(func(s *MessageRecordsUpsert) {
  967. s.SetSendTime(v)
  968. })
  969. }
  970. // UpdateSendTime sets the "send_time" field to the value that was provided on create.
  971. func (u *MessageRecordsUpsertOne) UpdateSendTime() *MessageRecordsUpsertOne {
  972. return u.Update(func(s *MessageRecordsUpsert) {
  973. s.UpdateSendTime()
  974. })
  975. }
  976. // ClearSendTime clears the value of the "send_time" field.
  977. func (u *MessageRecordsUpsertOne) ClearSendTime() *MessageRecordsUpsertOne {
  978. return u.Update(func(s *MessageRecordsUpsert) {
  979. s.ClearSendTime()
  980. })
  981. }
  982. // SetSourceType sets the "source_type" field.
  983. func (u *MessageRecordsUpsertOne) SetSourceType(v int) *MessageRecordsUpsertOne {
  984. return u.Update(func(s *MessageRecordsUpsert) {
  985. s.SetSourceType(v)
  986. })
  987. }
  988. // AddSourceType adds v to the "source_type" field.
  989. func (u *MessageRecordsUpsertOne) AddSourceType(v int) *MessageRecordsUpsertOne {
  990. return u.Update(func(s *MessageRecordsUpsert) {
  991. s.AddSourceType(v)
  992. })
  993. }
  994. // UpdateSourceType sets the "source_type" field to the value that was provided on create.
  995. func (u *MessageRecordsUpsertOne) UpdateSourceType() *MessageRecordsUpsertOne {
  996. return u.Update(func(s *MessageRecordsUpsert) {
  997. s.UpdateSourceType()
  998. })
  999. }
  1000. // SetSourceID sets the "source_id" field.
  1001. func (u *MessageRecordsUpsertOne) SetSourceID(v uint64) *MessageRecordsUpsertOne {
  1002. return u.Update(func(s *MessageRecordsUpsert) {
  1003. s.SetSourceID(v)
  1004. })
  1005. }
  1006. // UpdateSourceID sets the "source_id" field to the value that was provided on create.
  1007. func (u *MessageRecordsUpsertOne) UpdateSourceID() *MessageRecordsUpsertOne {
  1008. return u.Update(func(s *MessageRecordsUpsert) {
  1009. s.UpdateSourceID()
  1010. })
  1011. }
  1012. // ClearSourceID clears the value of the "source_id" field.
  1013. func (u *MessageRecordsUpsertOne) ClearSourceID() *MessageRecordsUpsertOne {
  1014. return u.Update(func(s *MessageRecordsUpsert) {
  1015. s.ClearSourceID()
  1016. })
  1017. }
  1018. // SetSubSourceID sets the "sub_source_id" field.
  1019. func (u *MessageRecordsUpsertOne) SetSubSourceID(v uint64) *MessageRecordsUpsertOne {
  1020. return u.Update(func(s *MessageRecordsUpsert) {
  1021. s.SetSubSourceID(v)
  1022. })
  1023. }
  1024. // UpdateSubSourceID sets the "sub_source_id" field to the value that was provided on create.
  1025. func (u *MessageRecordsUpsertOne) UpdateSubSourceID() *MessageRecordsUpsertOne {
  1026. return u.Update(func(s *MessageRecordsUpsert) {
  1027. s.UpdateSubSourceID()
  1028. })
  1029. }
  1030. // ClearSubSourceID clears the value of the "sub_source_id" field.
  1031. func (u *MessageRecordsUpsertOne) ClearSubSourceID() *MessageRecordsUpsertOne {
  1032. return u.Update(func(s *MessageRecordsUpsert) {
  1033. s.ClearSubSourceID()
  1034. })
  1035. }
  1036. // SetOrganizationID sets the "organization_id" field.
  1037. func (u *MessageRecordsUpsertOne) SetOrganizationID(v uint64) *MessageRecordsUpsertOne {
  1038. return u.Update(func(s *MessageRecordsUpsert) {
  1039. s.SetOrganizationID(v)
  1040. })
  1041. }
  1042. // AddOrganizationID adds v to the "organization_id" field.
  1043. func (u *MessageRecordsUpsertOne) AddOrganizationID(v uint64) *MessageRecordsUpsertOne {
  1044. return u.Update(func(s *MessageRecordsUpsert) {
  1045. s.AddOrganizationID(v)
  1046. })
  1047. }
  1048. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1049. func (u *MessageRecordsUpsertOne) UpdateOrganizationID() *MessageRecordsUpsertOne {
  1050. return u.Update(func(s *MessageRecordsUpsert) {
  1051. s.UpdateOrganizationID()
  1052. })
  1053. }
  1054. // ClearOrganizationID clears the value of the "organization_id" field.
  1055. func (u *MessageRecordsUpsertOne) ClearOrganizationID() *MessageRecordsUpsertOne {
  1056. return u.Update(func(s *MessageRecordsUpsert) {
  1057. s.ClearOrganizationID()
  1058. })
  1059. }
  1060. // Exec executes the query.
  1061. func (u *MessageRecordsUpsertOne) Exec(ctx context.Context) error {
  1062. if len(u.create.conflict) == 0 {
  1063. return errors.New("ent: missing options for MessageRecordsCreate.OnConflict")
  1064. }
  1065. return u.create.Exec(ctx)
  1066. }
  1067. // ExecX is like Exec, but panics if an error occurs.
  1068. func (u *MessageRecordsUpsertOne) ExecX(ctx context.Context) {
  1069. if err := u.create.Exec(ctx); err != nil {
  1070. panic(err)
  1071. }
  1072. }
  1073. // Exec executes the UPSERT query and returns the inserted/updated ID.
  1074. func (u *MessageRecordsUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  1075. node, err := u.create.Save(ctx)
  1076. if err != nil {
  1077. return id, err
  1078. }
  1079. return node.ID, nil
  1080. }
  1081. // IDX is like ID, but panics if an error occurs.
  1082. func (u *MessageRecordsUpsertOne) IDX(ctx context.Context) uint64 {
  1083. id, err := u.ID(ctx)
  1084. if err != nil {
  1085. panic(err)
  1086. }
  1087. return id
  1088. }
  1089. // MessageRecordsCreateBulk is the builder for creating many MessageRecords entities in bulk.
  1090. type MessageRecordsCreateBulk struct {
  1091. config
  1092. err error
  1093. builders []*MessageRecordsCreate
  1094. conflict []sql.ConflictOption
  1095. }
  1096. // Save creates the MessageRecords entities in the database.
  1097. func (mrcb *MessageRecordsCreateBulk) Save(ctx context.Context) ([]*MessageRecords, error) {
  1098. if mrcb.err != nil {
  1099. return nil, mrcb.err
  1100. }
  1101. specs := make([]*sqlgraph.CreateSpec, len(mrcb.builders))
  1102. nodes := make([]*MessageRecords, len(mrcb.builders))
  1103. mutators := make([]Mutator, len(mrcb.builders))
  1104. for i := range mrcb.builders {
  1105. func(i int, root context.Context) {
  1106. builder := mrcb.builders[i]
  1107. builder.defaults()
  1108. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1109. mutation, ok := m.(*MessageRecordsMutation)
  1110. if !ok {
  1111. return nil, fmt.Errorf("unexpected mutation type %T", m)
  1112. }
  1113. if err := builder.check(); err != nil {
  1114. return nil, err
  1115. }
  1116. builder.mutation = mutation
  1117. var err error
  1118. nodes[i], specs[i] = builder.createSpec()
  1119. if i < len(mutators)-1 {
  1120. _, err = mutators[i+1].Mutate(root, mrcb.builders[i+1].mutation)
  1121. } else {
  1122. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1123. spec.OnConflict = mrcb.conflict
  1124. // Invoke the actual operation on the latest mutation in the chain.
  1125. if err = sqlgraph.BatchCreate(ctx, mrcb.driver, spec); err != nil {
  1126. if sqlgraph.IsConstraintError(err) {
  1127. err = &ConstraintError{msg: err.Error(), wrap: err}
  1128. }
  1129. }
  1130. }
  1131. if err != nil {
  1132. return nil, err
  1133. }
  1134. mutation.id = &nodes[i].ID
  1135. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  1136. id := specs[i].ID.Value.(int64)
  1137. nodes[i].ID = uint64(id)
  1138. }
  1139. mutation.done = true
  1140. return nodes[i], nil
  1141. })
  1142. for i := len(builder.hooks) - 1; i >= 0; i-- {
  1143. mut = builder.hooks[i](mut)
  1144. }
  1145. mutators[i] = mut
  1146. }(i, ctx)
  1147. }
  1148. if len(mutators) > 0 {
  1149. if _, err := mutators[0].Mutate(ctx, mrcb.builders[0].mutation); err != nil {
  1150. return nil, err
  1151. }
  1152. }
  1153. return nodes, nil
  1154. }
  1155. // SaveX is like Save, but panics if an error occurs.
  1156. func (mrcb *MessageRecordsCreateBulk) SaveX(ctx context.Context) []*MessageRecords {
  1157. v, err := mrcb.Save(ctx)
  1158. if err != nil {
  1159. panic(err)
  1160. }
  1161. return v
  1162. }
  1163. // Exec executes the query.
  1164. func (mrcb *MessageRecordsCreateBulk) Exec(ctx context.Context) error {
  1165. _, err := mrcb.Save(ctx)
  1166. return err
  1167. }
  1168. // ExecX is like Exec, but panics if an error occurs.
  1169. func (mrcb *MessageRecordsCreateBulk) ExecX(ctx context.Context) {
  1170. if err := mrcb.Exec(ctx); err != nil {
  1171. panic(err)
  1172. }
  1173. }
  1174. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1175. // of the `INSERT` statement. For example:
  1176. //
  1177. // client.MessageRecords.CreateBulk(builders...).
  1178. // OnConflict(
  1179. // // Update the row with the new values
  1180. // // the was proposed for insertion.
  1181. // sql.ResolveWithNewValues(),
  1182. // ).
  1183. // // Override some of the fields with custom
  1184. // // update values.
  1185. // Update(func(u *ent.MessageRecordsUpsert) {
  1186. // SetCreatedAt(v+v).
  1187. // }).
  1188. // Exec(ctx)
  1189. func (mrcb *MessageRecordsCreateBulk) OnConflict(opts ...sql.ConflictOption) *MessageRecordsUpsertBulk {
  1190. mrcb.conflict = opts
  1191. return &MessageRecordsUpsertBulk{
  1192. create: mrcb,
  1193. }
  1194. }
  1195. // OnConflictColumns calls `OnConflict` and configures the columns
  1196. // as conflict target. Using this option is equivalent to using:
  1197. //
  1198. // client.MessageRecords.Create().
  1199. // OnConflict(sql.ConflictColumns(columns...)).
  1200. // Exec(ctx)
  1201. func (mrcb *MessageRecordsCreateBulk) OnConflictColumns(columns ...string) *MessageRecordsUpsertBulk {
  1202. mrcb.conflict = append(mrcb.conflict, sql.ConflictColumns(columns...))
  1203. return &MessageRecordsUpsertBulk{
  1204. create: mrcb,
  1205. }
  1206. }
  1207. // MessageRecordsUpsertBulk is the builder for "upsert"-ing
  1208. // a bulk of MessageRecords nodes.
  1209. type MessageRecordsUpsertBulk struct {
  1210. create *MessageRecordsCreateBulk
  1211. }
  1212. // UpdateNewValues updates the mutable fields using the new values that
  1213. // were set on create. Using this option is equivalent to using:
  1214. //
  1215. // client.MessageRecords.Create().
  1216. // OnConflict(
  1217. // sql.ResolveWithNewValues(),
  1218. // sql.ResolveWith(func(u *sql.UpdateSet) {
  1219. // u.SetIgnore(messagerecords.FieldID)
  1220. // }),
  1221. // ).
  1222. // Exec(ctx)
  1223. func (u *MessageRecordsUpsertBulk) UpdateNewValues() *MessageRecordsUpsertBulk {
  1224. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1225. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1226. for _, b := range u.create.builders {
  1227. if _, exists := b.mutation.ID(); exists {
  1228. s.SetIgnore(messagerecords.FieldID)
  1229. }
  1230. if _, exists := b.mutation.CreatedAt(); exists {
  1231. s.SetIgnore(messagerecords.FieldCreatedAt)
  1232. }
  1233. }
  1234. }))
  1235. return u
  1236. }
  1237. // Ignore sets each column to itself in case of conflict.
  1238. // Using this option is equivalent to using:
  1239. //
  1240. // client.MessageRecords.Create().
  1241. // OnConflict(sql.ResolveWithIgnore()).
  1242. // Exec(ctx)
  1243. func (u *MessageRecordsUpsertBulk) Ignore() *MessageRecordsUpsertBulk {
  1244. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1245. return u
  1246. }
  1247. // DoNothing configures the conflict_action to `DO NOTHING`.
  1248. // Supported only by SQLite and PostgreSQL.
  1249. func (u *MessageRecordsUpsertBulk) DoNothing() *MessageRecordsUpsertBulk {
  1250. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1251. return u
  1252. }
  1253. // Update allows overriding fields `UPDATE` values. See the MessageRecordsCreateBulk.OnConflict
  1254. // documentation for more info.
  1255. func (u *MessageRecordsUpsertBulk) Update(set func(*MessageRecordsUpsert)) *MessageRecordsUpsertBulk {
  1256. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1257. set(&MessageRecordsUpsert{UpdateSet: update})
  1258. }))
  1259. return u
  1260. }
  1261. // SetUpdatedAt sets the "updated_at" field.
  1262. func (u *MessageRecordsUpsertBulk) SetUpdatedAt(v time.Time) *MessageRecordsUpsertBulk {
  1263. return u.Update(func(s *MessageRecordsUpsert) {
  1264. s.SetUpdatedAt(v)
  1265. })
  1266. }
  1267. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1268. func (u *MessageRecordsUpsertBulk) UpdateUpdatedAt() *MessageRecordsUpsertBulk {
  1269. return u.Update(func(s *MessageRecordsUpsert) {
  1270. s.UpdateUpdatedAt()
  1271. })
  1272. }
  1273. // SetStatus sets the "status" field.
  1274. func (u *MessageRecordsUpsertBulk) SetStatus(v uint8) *MessageRecordsUpsertBulk {
  1275. return u.Update(func(s *MessageRecordsUpsert) {
  1276. s.SetStatus(v)
  1277. })
  1278. }
  1279. // AddStatus adds v to the "status" field.
  1280. func (u *MessageRecordsUpsertBulk) AddStatus(v uint8) *MessageRecordsUpsertBulk {
  1281. return u.Update(func(s *MessageRecordsUpsert) {
  1282. s.AddStatus(v)
  1283. })
  1284. }
  1285. // UpdateStatus sets the "status" field to the value that was provided on create.
  1286. func (u *MessageRecordsUpsertBulk) UpdateStatus() *MessageRecordsUpsertBulk {
  1287. return u.Update(func(s *MessageRecordsUpsert) {
  1288. s.UpdateStatus()
  1289. })
  1290. }
  1291. // ClearStatus clears the value of the "status" field.
  1292. func (u *MessageRecordsUpsertBulk) ClearStatus() *MessageRecordsUpsertBulk {
  1293. return u.Update(func(s *MessageRecordsUpsert) {
  1294. s.ClearStatus()
  1295. })
  1296. }
  1297. // SetBotWxid sets the "bot_wxid" field.
  1298. func (u *MessageRecordsUpsertBulk) SetBotWxid(v string) *MessageRecordsUpsertBulk {
  1299. return u.Update(func(s *MessageRecordsUpsert) {
  1300. s.SetBotWxid(v)
  1301. })
  1302. }
  1303. // UpdateBotWxid sets the "bot_wxid" field to the value that was provided on create.
  1304. func (u *MessageRecordsUpsertBulk) UpdateBotWxid() *MessageRecordsUpsertBulk {
  1305. return u.Update(func(s *MessageRecordsUpsert) {
  1306. s.UpdateBotWxid()
  1307. })
  1308. }
  1309. // SetContactID sets the "contact_id" field.
  1310. func (u *MessageRecordsUpsertBulk) SetContactID(v uint64) *MessageRecordsUpsertBulk {
  1311. return u.Update(func(s *MessageRecordsUpsert) {
  1312. s.SetContactID(v)
  1313. })
  1314. }
  1315. // UpdateContactID sets the "contact_id" field to the value that was provided on create.
  1316. func (u *MessageRecordsUpsertBulk) UpdateContactID() *MessageRecordsUpsertBulk {
  1317. return u.Update(func(s *MessageRecordsUpsert) {
  1318. s.UpdateContactID()
  1319. })
  1320. }
  1321. // ClearContactID clears the value of the "contact_id" field.
  1322. func (u *MessageRecordsUpsertBulk) ClearContactID() *MessageRecordsUpsertBulk {
  1323. return u.Update(func(s *MessageRecordsUpsert) {
  1324. s.ClearContactID()
  1325. })
  1326. }
  1327. // SetContactType sets the "contact_type" field.
  1328. func (u *MessageRecordsUpsertBulk) SetContactType(v int) *MessageRecordsUpsertBulk {
  1329. return u.Update(func(s *MessageRecordsUpsert) {
  1330. s.SetContactType(v)
  1331. })
  1332. }
  1333. // AddContactType adds v to the "contact_type" field.
  1334. func (u *MessageRecordsUpsertBulk) AddContactType(v int) *MessageRecordsUpsertBulk {
  1335. return u.Update(func(s *MessageRecordsUpsert) {
  1336. s.AddContactType(v)
  1337. })
  1338. }
  1339. // UpdateContactType sets the "contact_type" field to the value that was provided on create.
  1340. func (u *MessageRecordsUpsertBulk) UpdateContactType() *MessageRecordsUpsertBulk {
  1341. return u.Update(func(s *MessageRecordsUpsert) {
  1342. s.UpdateContactType()
  1343. })
  1344. }
  1345. // SetContactWxid sets the "contact_wxid" field.
  1346. func (u *MessageRecordsUpsertBulk) SetContactWxid(v string) *MessageRecordsUpsertBulk {
  1347. return u.Update(func(s *MessageRecordsUpsert) {
  1348. s.SetContactWxid(v)
  1349. })
  1350. }
  1351. // UpdateContactWxid sets the "contact_wxid" field to the value that was provided on create.
  1352. func (u *MessageRecordsUpsertBulk) UpdateContactWxid() *MessageRecordsUpsertBulk {
  1353. return u.Update(func(s *MessageRecordsUpsert) {
  1354. s.UpdateContactWxid()
  1355. })
  1356. }
  1357. // SetContentType sets the "content_type" field.
  1358. func (u *MessageRecordsUpsertBulk) SetContentType(v int) *MessageRecordsUpsertBulk {
  1359. return u.Update(func(s *MessageRecordsUpsert) {
  1360. s.SetContentType(v)
  1361. })
  1362. }
  1363. // AddContentType adds v to the "content_type" field.
  1364. func (u *MessageRecordsUpsertBulk) AddContentType(v int) *MessageRecordsUpsertBulk {
  1365. return u.Update(func(s *MessageRecordsUpsert) {
  1366. s.AddContentType(v)
  1367. })
  1368. }
  1369. // UpdateContentType sets the "content_type" field to the value that was provided on create.
  1370. func (u *MessageRecordsUpsertBulk) UpdateContentType() *MessageRecordsUpsertBulk {
  1371. return u.Update(func(s *MessageRecordsUpsert) {
  1372. s.UpdateContentType()
  1373. })
  1374. }
  1375. // SetContent sets the "content" field.
  1376. func (u *MessageRecordsUpsertBulk) SetContent(v string) *MessageRecordsUpsertBulk {
  1377. return u.Update(func(s *MessageRecordsUpsert) {
  1378. s.SetContent(v)
  1379. })
  1380. }
  1381. // UpdateContent sets the "content" field to the value that was provided on create.
  1382. func (u *MessageRecordsUpsertBulk) UpdateContent() *MessageRecordsUpsertBulk {
  1383. return u.Update(func(s *MessageRecordsUpsert) {
  1384. s.UpdateContent()
  1385. })
  1386. }
  1387. // SetMeta sets the "meta" field.
  1388. func (u *MessageRecordsUpsertBulk) SetMeta(v custom_types.Meta) *MessageRecordsUpsertBulk {
  1389. return u.Update(func(s *MessageRecordsUpsert) {
  1390. s.SetMeta(v)
  1391. })
  1392. }
  1393. // UpdateMeta sets the "meta" field to the value that was provided on create.
  1394. func (u *MessageRecordsUpsertBulk) UpdateMeta() *MessageRecordsUpsertBulk {
  1395. return u.Update(func(s *MessageRecordsUpsert) {
  1396. s.UpdateMeta()
  1397. })
  1398. }
  1399. // ClearMeta clears the value of the "meta" field.
  1400. func (u *MessageRecordsUpsertBulk) ClearMeta() *MessageRecordsUpsertBulk {
  1401. return u.Update(func(s *MessageRecordsUpsert) {
  1402. s.ClearMeta()
  1403. })
  1404. }
  1405. // SetErrorDetail sets the "error_detail" field.
  1406. func (u *MessageRecordsUpsertBulk) SetErrorDetail(v string) *MessageRecordsUpsertBulk {
  1407. return u.Update(func(s *MessageRecordsUpsert) {
  1408. s.SetErrorDetail(v)
  1409. })
  1410. }
  1411. // UpdateErrorDetail sets the "error_detail" field to the value that was provided on create.
  1412. func (u *MessageRecordsUpsertBulk) UpdateErrorDetail() *MessageRecordsUpsertBulk {
  1413. return u.Update(func(s *MessageRecordsUpsert) {
  1414. s.UpdateErrorDetail()
  1415. })
  1416. }
  1417. // SetSendTime sets the "send_time" field.
  1418. func (u *MessageRecordsUpsertBulk) SetSendTime(v time.Time) *MessageRecordsUpsertBulk {
  1419. return u.Update(func(s *MessageRecordsUpsert) {
  1420. s.SetSendTime(v)
  1421. })
  1422. }
  1423. // UpdateSendTime sets the "send_time" field to the value that was provided on create.
  1424. func (u *MessageRecordsUpsertBulk) UpdateSendTime() *MessageRecordsUpsertBulk {
  1425. return u.Update(func(s *MessageRecordsUpsert) {
  1426. s.UpdateSendTime()
  1427. })
  1428. }
  1429. // ClearSendTime clears the value of the "send_time" field.
  1430. func (u *MessageRecordsUpsertBulk) ClearSendTime() *MessageRecordsUpsertBulk {
  1431. return u.Update(func(s *MessageRecordsUpsert) {
  1432. s.ClearSendTime()
  1433. })
  1434. }
  1435. // SetSourceType sets the "source_type" field.
  1436. func (u *MessageRecordsUpsertBulk) SetSourceType(v int) *MessageRecordsUpsertBulk {
  1437. return u.Update(func(s *MessageRecordsUpsert) {
  1438. s.SetSourceType(v)
  1439. })
  1440. }
  1441. // AddSourceType adds v to the "source_type" field.
  1442. func (u *MessageRecordsUpsertBulk) AddSourceType(v int) *MessageRecordsUpsertBulk {
  1443. return u.Update(func(s *MessageRecordsUpsert) {
  1444. s.AddSourceType(v)
  1445. })
  1446. }
  1447. // UpdateSourceType sets the "source_type" field to the value that was provided on create.
  1448. func (u *MessageRecordsUpsertBulk) UpdateSourceType() *MessageRecordsUpsertBulk {
  1449. return u.Update(func(s *MessageRecordsUpsert) {
  1450. s.UpdateSourceType()
  1451. })
  1452. }
  1453. // SetSourceID sets the "source_id" field.
  1454. func (u *MessageRecordsUpsertBulk) SetSourceID(v uint64) *MessageRecordsUpsertBulk {
  1455. return u.Update(func(s *MessageRecordsUpsert) {
  1456. s.SetSourceID(v)
  1457. })
  1458. }
  1459. // UpdateSourceID sets the "source_id" field to the value that was provided on create.
  1460. func (u *MessageRecordsUpsertBulk) UpdateSourceID() *MessageRecordsUpsertBulk {
  1461. return u.Update(func(s *MessageRecordsUpsert) {
  1462. s.UpdateSourceID()
  1463. })
  1464. }
  1465. // ClearSourceID clears the value of the "source_id" field.
  1466. func (u *MessageRecordsUpsertBulk) ClearSourceID() *MessageRecordsUpsertBulk {
  1467. return u.Update(func(s *MessageRecordsUpsert) {
  1468. s.ClearSourceID()
  1469. })
  1470. }
  1471. // SetSubSourceID sets the "sub_source_id" field.
  1472. func (u *MessageRecordsUpsertBulk) SetSubSourceID(v uint64) *MessageRecordsUpsertBulk {
  1473. return u.Update(func(s *MessageRecordsUpsert) {
  1474. s.SetSubSourceID(v)
  1475. })
  1476. }
  1477. // UpdateSubSourceID sets the "sub_source_id" field to the value that was provided on create.
  1478. func (u *MessageRecordsUpsertBulk) UpdateSubSourceID() *MessageRecordsUpsertBulk {
  1479. return u.Update(func(s *MessageRecordsUpsert) {
  1480. s.UpdateSubSourceID()
  1481. })
  1482. }
  1483. // ClearSubSourceID clears the value of the "sub_source_id" field.
  1484. func (u *MessageRecordsUpsertBulk) ClearSubSourceID() *MessageRecordsUpsertBulk {
  1485. return u.Update(func(s *MessageRecordsUpsert) {
  1486. s.ClearSubSourceID()
  1487. })
  1488. }
  1489. // SetOrganizationID sets the "organization_id" field.
  1490. func (u *MessageRecordsUpsertBulk) SetOrganizationID(v uint64) *MessageRecordsUpsertBulk {
  1491. return u.Update(func(s *MessageRecordsUpsert) {
  1492. s.SetOrganizationID(v)
  1493. })
  1494. }
  1495. // AddOrganizationID adds v to the "organization_id" field.
  1496. func (u *MessageRecordsUpsertBulk) AddOrganizationID(v uint64) *MessageRecordsUpsertBulk {
  1497. return u.Update(func(s *MessageRecordsUpsert) {
  1498. s.AddOrganizationID(v)
  1499. })
  1500. }
  1501. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1502. func (u *MessageRecordsUpsertBulk) UpdateOrganizationID() *MessageRecordsUpsertBulk {
  1503. return u.Update(func(s *MessageRecordsUpsert) {
  1504. s.UpdateOrganizationID()
  1505. })
  1506. }
  1507. // ClearOrganizationID clears the value of the "organization_id" field.
  1508. func (u *MessageRecordsUpsertBulk) ClearOrganizationID() *MessageRecordsUpsertBulk {
  1509. return u.Update(func(s *MessageRecordsUpsert) {
  1510. s.ClearOrganizationID()
  1511. })
  1512. }
  1513. // Exec executes the query.
  1514. func (u *MessageRecordsUpsertBulk) Exec(ctx context.Context) error {
  1515. if u.create.err != nil {
  1516. return u.create.err
  1517. }
  1518. for i, b := range u.create.builders {
  1519. if len(b.conflict) != 0 {
  1520. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the MessageRecordsCreateBulk instead", i)
  1521. }
  1522. }
  1523. if len(u.create.conflict) == 0 {
  1524. return errors.New("ent: missing options for MessageRecordsCreateBulk.OnConflict")
  1525. }
  1526. return u.create.Exec(ctx)
  1527. }
  1528. // ExecX is like Exec, but panics if an error occurs.
  1529. func (u *MessageRecordsUpsertBulk) ExecX(ctx context.Context) {
  1530. if err := u.create.Exec(ctx); err != nil {
  1531. panic(err)
  1532. }
  1533. }