usagestatisticmonth_create.go 55 KB

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