chatrecords_update.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  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/chatrecords"
  9. "wechat-api/ent/predicate"
  10. "entgo.io/ent/dialect/sql"
  11. "entgo.io/ent/dialect/sql/sqlgraph"
  12. "entgo.io/ent/schema/field"
  13. )
  14. // ChatRecordsUpdate is the builder for updating ChatRecords entities.
  15. type ChatRecordsUpdate struct {
  16. config
  17. hooks []Hook
  18. mutation *ChatRecordsMutation
  19. }
  20. // Where appends a list predicates to the ChatRecordsUpdate builder.
  21. func (cru *ChatRecordsUpdate) Where(ps ...predicate.ChatRecords) *ChatRecordsUpdate {
  22. cru.mutation.Where(ps...)
  23. return cru
  24. }
  25. // SetUpdatedAt sets the "updated_at" field.
  26. func (cru *ChatRecordsUpdate) SetUpdatedAt(t time.Time) *ChatRecordsUpdate {
  27. cru.mutation.SetUpdatedAt(t)
  28. return cru
  29. }
  30. // SetDeletedAt sets the "deleted_at" field.
  31. func (cru *ChatRecordsUpdate) SetDeletedAt(t time.Time) *ChatRecordsUpdate {
  32. cru.mutation.SetDeletedAt(t)
  33. return cru
  34. }
  35. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  36. func (cru *ChatRecordsUpdate) SetNillableDeletedAt(t *time.Time) *ChatRecordsUpdate {
  37. if t != nil {
  38. cru.SetDeletedAt(*t)
  39. }
  40. return cru
  41. }
  42. // ClearDeletedAt clears the value of the "deleted_at" field.
  43. func (cru *ChatRecordsUpdate) ClearDeletedAt() *ChatRecordsUpdate {
  44. cru.mutation.ClearDeletedAt()
  45. return cru
  46. }
  47. // SetContent sets the "content" field.
  48. func (cru *ChatRecordsUpdate) SetContent(s string) *ChatRecordsUpdate {
  49. cru.mutation.SetContent(s)
  50. return cru
  51. }
  52. // SetNillableContent sets the "content" field if the given value is not nil.
  53. func (cru *ChatRecordsUpdate) SetNillableContent(s *string) *ChatRecordsUpdate {
  54. if s != nil {
  55. cru.SetContent(*s)
  56. }
  57. return cru
  58. }
  59. // SetContentType sets the "content_type" field.
  60. func (cru *ChatRecordsUpdate) SetContentType(u uint8) *ChatRecordsUpdate {
  61. cru.mutation.ResetContentType()
  62. cru.mutation.SetContentType(u)
  63. return cru
  64. }
  65. // SetNillableContentType sets the "content_type" field if the given value is not nil.
  66. func (cru *ChatRecordsUpdate) SetNillableContentType(u *uint8) *ChatRecordsUpdate {
  67. if u != nil {
  68. cru.SetContentType(*u)
  69. }
  70. return cru
  71. }
  72. // AddContentType adds u to the "content_type" field.
  73. func (cru *ChatRecordsUpdate) AddContentType(u int8) *ChatRecordsUpdate {
  74. cru.mutation.AddContentType(u)
  75. return cru
  76. }
  77. // SetSessionID sets the "session_id" field.
  78. func (cru *ChatRecordsUpdate) SetSessionID(u uint64) *ChatRecordsUpdate {
  79. cru.mutation.ResetSessionID()
  80. cru.mutation.SetSessionID(u)
  81. return cru
  82. }
  83. // SetNillableSessionID sets the "session_id" field if the given value is not nil.
  84. func (cru *ChatRecordsUpdate) SetNillableSessionID(u *uint64) *ChatRecordsUpdate {
  85. if u != nil {
  86. cru.SetSessionID(*u)
  87. }
  88. return cru
  89. }
  90. // AddSessionID adds u to the "session_id" field.
  91. func (cru *ChatRecordsUpdate) AddSessionID(u int64) *ChatRecordsUpdate {
  92. cru.mutation.AddSessionID(u)
  93. return cru
  94. }
  95. // SetUserID sets the "user_id" field.
  96. func (cru *ChatRecordsUpdate) SetUserID(u uint64) *ChatRecordsUpdate {
  97. cru.mutation.ResetUserID()
  98. cru.mutation.SetUserID(u)
  99. return cru
  100. }
  101. // SetNillableUserID sets the "user_id" field if the given value is not nil.
  102. func (cru *ChatRecordsUpdate) SetNillableUserID(u *uint64) *ChatRecordsUpdate {
  103. if u != nil {
  104. cru.SetUserID(*u)
  105. }
  106. return cru
  107. }
  108. // AddUserID adds u to the "user_id" field.
  109. func (cru *ChatRecordsUpdate) AddUserID(u int64) *ChatRecordsUpdate {
  110. cru.mutation.AddUserID(u)
  111. return cru
  112. }
  113. // SetBotID sets the "bot_id" field.
  114. func (cru *ChatRecordsUpdate) SetBotID(u uint64) *ChatRecordsUpdate {
  115. cru.mutation.ResetBotID()
  116. cru.mutation.SetBotID(u)
  117. return cru
  118. }
  119. // SetNillableBotID sets the "bot_id" field if the given value is not nil.
  120. func (cru *ChatRecordsUpdate) SetNillableBotID(u *uint64) *ChatRecordsUpdate {
  121. if u != nil {
  122. cru.SetBotID(*u)
  123. }
  124. return cru
  125. }
  126. // AddBotID adds u to the "bot_id" field.
  127. func (cru *ChatRecordsUpdate) AddBotID(u int64) *ChatRecordsUpdate {
  128. cru.mutation.AddBotID(u)
  129. return cru
  130. }
  131. // SetBotType sets the "bot_type" field.
  132. func (cru *ChatRecordsUpdate) SetBotType(u uint8) *ChatRecordsUpdate {
  133. cru.mutation.ResetBotType()
  134. cru.mutation.SetBotType(u)
  135. return cru
  136. }
  137. // SetNillableBotType sets the "bot_type" field if the given value is not nil.
  138. func (cru *ChatRecordsUpdate) SetNillableBotType(u *uint8) *ChatRecordsUpdate {
  139. if u != nil {
  140. cru.SetBotType(*u)
  141. }
  142. return cru
  143. }
  144. // AddBotType adds u to the "bot_type" field.
  145. func (cru *ChatRecordsUpdate) AddBotType(u int8) *ChatRecordsUpdate {
  146. cru.mutation.AddBotType(u)
  147. return cru
  148. }
  149. // Mutation returns the ChatRecordsMutation object of the builder.
  150. func (cru *ChatRecordsUpdate) Mutation() *ChatRecordsMutation {
  151. return cru.mutation
  152. }
  153. // Save executes the query and returns the number of nodes affected by the update operation.
  154. func (cru *ChatRecordsUpdate) Save(ctx context.Context) (int, error) {
  155. if err := cru.defaults(); err != nil {
  156. return 0, err
  157. }
  158. return withHooks(ctx, cru.sqlSave, cru.mutation, cru.hooks)
  159. }
  160. // SaveX is like Save, but panics if an error occurs.
  161. func (cru *ChatRecordsUpdate) SaveX(ctx context.Context) int {
  162. affected, err := cru.Save(ctx)
  163. if err != nil {
  164. panic(err)
  165. }
  166. return affected
  167. }
  168. // Exec executes the query.
  169. func (cru *ChatRecordsUpdate) Exec(ctx context.Context) error {
  170. _, err := cru.Save(ctx)
  171. return err
  172. }
  173. // ExecX is like Exec, but panics if an error occurs.
  174. func (cru *ChatRecordsUpdate) ExecX(ctx context.Context) {
  175. if err := cru.Exec(ctx); err != nil {
  176. panic(err)
  177. }
  178. }
  179. // defaults sets the default values of the builder before save.
  180. func (cru *ChatRecordsUpdate) defaults() error {
  181. if _, ok := cru.mutation.UpdatedAt(); !ok {
  182. if chatrecords.UpdateDefaultUpdatedAt == nil {
  183. return fmt.Errorf("ent: uninitialized chatrecords.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  184. }
  185. v := chatrecords.UpdateDefaultUpdatedAt()
  186. cru.mutation.SetUpdatedAt(v)
  187. }
  188. return nil
  189. }
  190. func (cru *ChatRecordsUpdate) sqlSave(ctx context.Context) (n int, err error) {
  191. _spec := sqlgraph.NewUpdateSpec(chatrecords.Table, chatrecords.Columns, sqlgraph.NewFieldSpec(chatrecords.FieldID, field.TypeUint64))
  192. if ps := cru.mutation.predicates; len(ps) > 0 {
  193. _spec.Predicate = func(selector *sql.Selector) {
  194. for i := range ps {
  195. ps[i](selector)
  196. }
  197. }
  198. }
  199. if value, ok := cru.mutation.UpdatedAt(); ok {
  200. _spec.SetField(chatrecords.FieldUpdatedAt, field.TypeTime, value)
  201. }
  202. if value, ok := cru.mutation.DeletedAt(); ok {
  203. _spec.SetField(chatrecords.FieldDeletedAt, field.TypeTime, value)
  204. }
  205. if cru.mutation.DeletedAtCleared() {
  206. _spec.ClearField(chatrecords.FieldDeletedAt, field.TypeTime)
  207. }
  208. if value, ok := cru.mutation.Content(); ok {
  209. _spec.SetField(chatrecords.FieldContent, field.TypeString, value)
  210. }
  211. if value, ok := cru.mutation.ContentType(); ok {
  212. _spec.SetField(chatrecords.FieldContentType, field.TypeUint8, value)
  213. }
  214. if value, ok := cru.mutation.AddedContentType(); ok {
  215. _spec.AddField(chatrecords.FieldContentType, field.TypeUint8, value)
  216. }
  217. if value, ok := cru.mutation.SessionID(); ok {
  218. _spec.SetField(chatrecords.FieldSessionID, field.TypeUint64, value)
  219. }
  220. if value, ok := cru.mutation.AddedSessionID(); ok {
  221. _spec.AddField(chatrecords.FieldSessionID, field.TypeUint64, value)
  222. }
  223. if value, ok := cru.mutation.UserID(); ok {
  224. _spec.SetField(chatrecords.FieldUserID, field.TypeUint64, value)
  225. }
  226. if value, ok := cru.mutation.AddedUserID(); ok {
  227. _spec.AddField(chatrecords.FieldUserID, field.TypeUint64, value)
  228. }
  229. if value, ok := cru.mutation.BotID(); ok {
  230. _spec.SetField(chatrecords.FieldBotID, field.TypeUint64, value)
  231. }
  232. if value, ok := cru.mutation.AddedBotID(); ok {
  233. _spec.AddField(chatrecords.FieldBotID, field.TypeUint64, value)
  234. }
  235. if value, ok := cru.mutation.BotType(); ok {
  236. _spec.SetField(chatrecords.FieldBotType, field.TypeUint8, value)
  237. }
  238. if value, ok := cru.mutation.AddedBotType(); ok {
  239. _spec.AddField(chatrecords.FieldBotType, field.TypeUint8, value)
  240. }
  241. if n, err = sqlgraph.UpdateNodes(ctx, cru.driver, _spec); err != nil {
  242. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  243. err = &NotFoundError{chatrecords.Label}
  244. } else if sqlgraph.IsConstraintError(err) {
  245. err = &ConstraintError{msg: err.Error(), wrap: err}
  246. }
  247. return 0, err
  248. }
  249. cru.mutation.done = true
  250. return n, nil
  251. }
  252. // ChatRecordsUpdateOne is the builder for updating a single ChatRecords entity.
  253. type ChatRecordsUpdateOne struct {
  254. config
  255. fields []string
  256. hooks []Hook
  257. mutation *ChatRecordsMutation
  258. }
  259. // SetUpdatedAt sets the "updated_at" field.
  260. func (cruo *ChatRecordsUpdateOne) SetUpdatedAt(t time.Time) *ChatRecordsUpdateOne {
  261. cruo.mutation.SetUpdatedAt(t)
  262. return cruo
  263. }
  264. // SetDeletedAt sets the "deleted_at" field.
  265. func (cruo *ChatRecordsUpdateOne) SetDeletedAt(t time.Time) *ChatRecordsUpdateOne {
  266. cruo.mutation.SetDeletedAt(t)
  267. return cruo
  268. }
  269. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  270. func (cruo *ChatRecordsUpdateOne) SetNillableDeletedAt(t *time.Time) *ChatRecordsUpdateOne {
  271. if t != nil {
  272. cruo.SetDeletedAt(*t)
  273. }
  274. return cruo
  275. }
  276. // ClearDeletedAt clears the value of the "deleted_at" field.
  277. func (cruo *ChatRecordsUpdateOne) ClearDeletedAt() *ChatRecordsUpdateOne {
  278. cruo.mutation.ClearDeletedAt()
  279. return cruo
  280. }
  281. // SetContent sets the "content" field.
  282. func (cruo *ChatRecordsUpdateOne) SetContent(s string) *ChatRecordsUpdateOne {
  283. cruo.mutation.SetContent(s)
  284. return cruo
  285. }
  286. // SetNillableContent sets the "content" field if the given value is not nil.
  287. func (cruo *ChatRecordsUpdateOne) SetNillableContent(s *string) *ChatRecordsUpdateOne {
  288. if s != nil {
  289. cruo.SetContent(*s)
  290. }
  291. return cruo
  292. }
  293. // SetContentType sets the "content_type" field.
  294. func (cruo *ChatRecordsUpdateOne) SetContentType(u uint8) *ChatRecordsUpdateOne {
  295. cruo.mutation.ResetContentType()
  296. cruo.mutation.SetContentType(u)
  297. return cruo
  298. }
  299. // SetNillableContentType sets the "content_type" field if the given value is not nil.
  300. func (cruo *ChatRecordsUpdateOne) SetNillableContentType(u *uint8) *ChatRecordsUpdateOne {
  301. if u != nil {
  302. cruo.SetContentType(*u)
  303. }
  304. return cruo
  305. }
  306. // AddContentType adds u to the "content_type" field.
  307. func (cruo *ChatRecordsUpdateOne) AddContentType(u int8) *ChatRecordsUpdateOne {
  308. cruo.mutation.AddContentType(u)
  309. return cruo
  310. }
  311. // SetSessionID sets the "session_id" field.
  312. func (cruo *ChatRecordsUpdateOne) SetSessionID(u uint64) *ChatRecordsUpdateOne {
  313. cruo.mutation.ResetSessionID()
  314. cruo.mutation.SetSessionID(u)
  315. return cruo
  316. }
  317. // SetNillableSessionID sets the "session_id" field if the given value is not nil.
  318. func (cruo *ChatRecordsUpdateOne) SetNillableSessionID(u *uint64) *ChatRecordsUpdateOne {
  319. if u != nil {
  320. cruo.SetSessionID(*u)
  321. }
  322. return cruo
  323. }
  324. // AddSessionID adds u to the "session_id" field.
  325. func (cruo *ChatRecordsUpdateOne) AddSessionID(u int64) *ChatRecordsUpdateOne {
  326. cruo.mutation.AddSessionID(u)
  327. return cruo
  328. }
  329. // SetUserID sets the "user_id" field.
  330. func (cruo *ChatRecordsUpdateOne) SetUserID(u uint64) *ChatRecordsUpdateOne {
  331. cruo.mutation.ResetUserID()
  332. cruo.mutation.SetUserID(u)
  333. return cruo
  334. }
  335. // SetNillableUserID sets the "user_id" field if the given value is not nil.
  336. func (cruo *ChatRecordsUpdateOne) SetNillableUserID(u *uint64) *ChatRecordsUpdateOne {
  337. if u != nil {
  338. cruo.SetUserID(*u)
  339. }
  340. return cruo
  341. }
  342. // AddUserID adds u to the "user_id" field.
  343. func (cruo *ChatRecordsUpdateOne) AddUserID(u int64) *ChatRecordsUpdateOne {
  344. cruo.mutation.AddUserID(u)
  345. return cruo
  346. }
  347. // SetBotID sets the "bot_id" field.
  348. func (cruo *ChatRecordsUpdateOne) SetBotID(u uint64) *ChatRecordsUpdateOne {
  349. cruo.mutation.ResetBotID()
  350. cruo.mutation.SetBotID(u)
  351. return cruo
  352. }
  353. // SetNillableBotID sets the "bot_id" field if the given value is not nil.
  354. func (cruo *ChatRecordsUpdateOne) SetNillableBotID(u *uint64) *ChatRecordsUpdateOne {
  355. if u != nil {
  356. cruo.SetBotID(*u)
  357. }
  358. return cruo
  359. }
  360. // AddBotID adds u to the "bot_id" field.
  361. func (cruo *ChatRecordsUpdateOne) AddBotID(u int64) *ChatRecordsUpdateOne {
  362. cruo.mutation.AddBotID(u)
  363. return cruo
  364. }
  365. // SetBotType sets the "bot_type" field.
  366. func (cruo *ChatRecordsUpdateOne) SetBotType(u uint8) *ChatRecordsUpdateOne {
  367. cruo.mutation.ResetBotType()
  368. cruo.mutation.SetBotType(u)
  369. return cruo
  370. }
  371. // SetNillableBotType sets the "bot_type" field if the given value is not nil.
  372. func (cruo *ChatRecordsUpdateOne) SetNillableBotType(u *uint8) *ChatRecordsUpdateOne {
  373. if u != nil {
  374. cruo.SetBotType(*u)
  375. }
  376. return cruo
  377. }
  378. // AddBotType adds u to the "bot_type" field.
  379. func (cruo *ChatRecordsUpdateOne) AddBotType(u int8) *ChatRecordsUpdateOne {
  380. cruo.mutation.AddBotType(u)
  381. return cruo
  382. }
  383. // Mutation returns the ChatRecordsMutation object of the builder.
  384. func (cruo *ChatRecordsUpdateOne) Mutation() *ChatRecordsMutation {
  385. return cruo.mutation
  386. }
  387. // Where appends a list predicates to the ChatRecordsUpdate builder.
  388. func (cruo *ChatRecordsUpdateOne) Where(ps ...predicate.ChatRecords) *ChatRecordsUpdateOne {
  389. cruo.mutation.Where(ps...)
  390. return cruo
  391. }
  392. // Select allows selecting one or more fields (columns) of the returned entity.
  393. // The default is selecting all fields defined in the entity schema.
  394. func (cruo *ChatRecordsUpdateOne) Select(field string, fields ...string) *ChatRecordsUpdateOne {
  395. cruo.fields = append([]string{field}, fields...)
  396. return cruo
  397. }
  398. // Save executes the query and returns the updated ChatRecords entity.
  399. func (cruo *ChatRecordsUpdateOne) Save(ctx context.Context) (*ChatRecords, error) {
  400. if err := cruo.defaults(); err != nil {
  401. return nil, err
  402. }
  403. return withHooks(ctx, cruo.sqlSave, cruo.mutation, cruo.hooks)
  404. }
  405. // SaveX is like Save, but panics if an error occurs.
  406. func (cruo *ChatRecordsUpdateOne) SaveX(ctx context.Context) *ChatRecords {
  407. node, err := cruo.Save(ctx)
  408. if err != nil {
  409. panic(err)
  410. }
  411. return node
  412. }
  413. // Exec executes the query on the entity.
  414. func (cruo *ChatRecordsUpdateOne) Exec(ctx context.Context) error {
  415. _, err := cruo.Save(ctx)
  416. return err
  417. }
  418. // ExecX is like Exec, but panics if an error occurs.
  419. func (cruo *ChatRecordsUpdateOne) ExecX(ctx context.Context) {
  420. if err := cruo.Exec(ctx); err != nil {
  421. panic(err)
  422. }
  423. }
  424. // defaults sets the default values of the builder before save.
  425. func (cruo *ChatRecordsUpdateOne) defaults() error {
  426. if _, ok := cruo.mutation.UpdatedAt(); !ok {
  427. if chatrecords.UpdateDefaultUpdatedAt == nil {
  428. return fmt.Errorf("ent: uninitialized chatrecords.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  429. }
  430. v := chatrecords.UpdateDefaultUpdatedAt()
  431. cruo.mutation.SetUpdatedAt(v)
  432. }
  433. return nil
  434. }
  435. func (cruo *ChatRecordsUpdateOne) sqlSave(ctx context.Context) (_node *ChatRecords, err error) {
  436. _spec := sqlgraph.NewUpdateSpec(chatrecords.Table, chatrecords.Columns, sqlgraph.NewFieldSpec(chatrecords.FieldID, field.TypeUint64))
  437. id, ok := cruo.mutation.ID()
  438. if !ok {
  439. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ChatRecords.id" for update`)}
  440. }
  441. _spec.Node.ID.Value = id
  442. if fields := cruo.fields; len(fields) > 0 {
  443. _spec.Node.Columns = make([]string, 0, len(fields))
  444. _spec.Node.Columns = append(_spec.Node.Columns, chatrecords.FieldID)
  445. for _, f := range fields {
  446. if !chatrecords.ValidColumn(f) {
  447. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  448. }
  449. if f != chatrecords.FieldID {
  450. _spec.Node.Columns = append(_spec.Node.Columns, f)
  451. }
  452. }
  453. }
  454. if ps := cruo.mutation.predicates; len(ps) > 0 {
  455. _spec.Predicate = func(selector *sql.Selector) {
  456. for i := range ps {
  457. ps[i](selector)
  458. }
  459. }
  460. }
  461. if value, ok := cruo.mutation.UpdatedAt(); ok {
  462. _spec.SetField(chatrecords.FieldUpdatedAt, field.TypeTime, value)
  463. }
  464. if value, ok := cruo.mutation.DeletedAt(); ok {
  465. _spec.SetField(chatrecords.FieldDeletedAt, field.TypeTime, value)
  466. }
  467. if cruo.mutation.DeletedAtCleared() {
  468. _spec.ClearField(chatrecords.FieldDeletedAt, field.TypeTime)
  469. }
  470. if value, ok := cruo.mutation.Content(); ok {
  471. _spec.SetField(chatrecords.FieldContent, field.TypeString, value)
  472. }
  473. if value, ok := cruo.mutation.ContentType(); ok {
  474. _spec.SetField(chatrecords.FieldContentType, field.TypeUint8, value)
  475. }
  476. if value, ok := cruo.mutation.AddedContentType(); ok {
  477. _spec.AddField(chatrecords.FieldContentType, field.TypeUint8, value)
  478. }
  479. if value, ok := cruo.mutation.SessionID(); ok {
  480. _spec.SetField(chatrecords.FieldSessionID, field.TypeUint64, value)
  481. }
  482. if value, ok := cruo.mutation.AddedSessionID(); ok {
  483. _spec.AddField(chatrecords.FieldSessionID, field.TypeUint64, value)
  484. }
  485. if value, ok := cruo.mutation.UserID(); ok {
  486. _spec.SetField(chatrecords.FieldUserID, field.TypeUint64, value)
  487. }
  488. if value, ok := cruo.mutation.AddedUserID(); ok {
  489. _spec.AddField(chatrecords.FieldUserID, field.TypeUint64, value)
  490. }
  491. if value, ok := cruo.mutation.BotID(); ok {
  492. _spec.SetField(chatrecords.FieldBotID, field.TypeUint64, value)
  493. }
  494. if value, ok := cruo.mutation.AddedBotID(); ok {
  495. _spec.AddField(chatrecords.FieldBotID, field.TypeUint64, value)
  496. }
  497. if value, ok := cruo.mutation.BotType(); ok {
  498. _spec.SetField(chatrecords.FieldBotType, field.TypeUint8, value)
  499. }
  500. if value, ok := cruo.mutation.AddedBotType(); ok {
  501. _spec.AddField(chatrecords.FieldBotType, field.TypeUint8, value)
  502. }
  503. _node = &ChatRecords{config: cruo.config}
  504. _spec.Assign = _node.assignValues
  505. _spec.ScanValues = _node.scanValues
  506. if err = sqlgraph.UpdateNode(ctx, cruo.driver, _spec); err != nil {
  507. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  508. err = &NotFoundError{chatrecords.Label}
  509. } else if sqlgraph.IsConstraintError(err) {
  510. err = &ConstraintError{msg: err.Error(), wrap: err}
  511. }
  512. return nil, err
  513. }
  514. cruo.mutation.done = true
  515. return _node, nil
  516. }