creditbalance_update.go 17 KB

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