messagerecords_create.go 53 KB

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