channelmonitordailyrollup_create.go 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "entgo.io/ent/dialect/sql"
  9. "entgo.io/ent/dialect/sql/sqlgraph"
  10. "entgo.io/ent/schema/field"
  11. "github.com/Wei-Shaw/sub2api/ent/channelmonitor"
  12. "github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
  13. )
  14. // ChannelMonitorDailyRollupCreate is the builder for creating a ChannelMonitorDailyRollup entity.
  15. type ChannelMonitorDailyRollupCreate struct {
  16. config
  17. mutation *ChannelMonitorDailyRollupMutation
  18. hooks []Hook
  19. conflict []sql.ConflictOption
  20. }
  21. // SetMonitorID sets the "monitor_id" field.
  22. func (_c *ChannelMonitorDailyRollupCreate) SetMonitorID(v int64) *ChannelMonitorDailyRollupCreate {
  23. _c.mutation.SetMonitorID(v)
  24. return _c
  25. }
  26. // SetModel sets the "model" field.
  27. func (_c *ChannelMonitorDailyRollupCreate) SetModel(v string) *ChannelMonitorDailyRollupCreate {
  28. _c.mutation.SetModel(v)
  29. return _c
  30. }
  31. // SetBucketDate sets the "bucket_date" field.
  32. func (_c *ChannelMonitorDailyRollupCreate) SetBucketDate(v time.Time) *ChannelMonitorDailyRollupCreate {
  33. _c.mutation.SetBucketDate(v)
  34. return _c
  35. }
  36. // SetTotalChecks sets the "total_checks" field.
  37. func (_c *ChannelMonitorDailyRollupCreate) SetTotalChecks(v int) *ChannelMonitorDailyRollupCreate {
  38. _c.mutation.SetTotalChecks(v)
  39. return _c
  40. }
  41. // SetNillableTotalChecks sets the "total_checks" field if the given value is not nil.
  42. func (_c *ChannelMonitorDailyRollupCreate) SetNillableTotalChecks(v *int) *ChannelMonitorDailyRollupCreate {
  43. if v != nil {
  44. _c.SetTotalChecks(*v)
  45. }
  46. return _c
  47. }
  48. // SetOkCount sets the "ok_count" field.
  49. func (_c *ChannelMonitorDailyRollupCreate) SetOkCount(v int) *ChannelMonitorDailyRollupCreate {
  50. _c.mutation.SetOkCount(v)
  51. return _c
  52. }
  53. // SetNillableOkCount sets the "ok_count" field if the given value is not nil.
  54. func (_c *ChannelMonitorDailyRollupCreate) SetNillableOkCount(v *int) *ChannelMonitorDailyRollupCreate {
  55. if v != nil {
  56. _c.SetOkCount(*v)
  57. }
  58. return _c
  59. }
  60. // SetOperationalCount sets the "operational_count" field.
  61. func (_c *ChannelMonitorDailyRollupCreate) SetOperationalCount(v int) *ChannelMonitorDailyRollupCreate {
  62. _c.mutation.SetOperationalCount(v)
  63. return _c
  64. }
  65. // SetNillableOperationalCount sets the "operational_count" field if the given value is not nil.
  66. func (_c *ChannelMonitorDailyRollupCreate) SetNillableOperationalCount(v *int) *ChannelMonitorDailyRollupCreate {
  67. if v != nil {
  68. _c.SetOperationalCount(*v)
  69. }
  70. return _c
  71. }
  72. // SetDegradedCount sets the "degraded_count" field.
  73. func (_c *ChannelMonitorDailyRollupCreate) SetDegradedCount(v int) *ChannelMonitorDailyRollupCreate {
  74. _c.mutation.SetDegradedCount(v)
  75. return _c
  76. }
  77. // SetNillableDegradedCount sets the "degraded_count" field if the given value is not nil.
  78. func (_c *ChannelMonitorDailyRollupCreate) SetNillableDegradedCount(v *int) *ChannelMonitorDailyRollupCreate {
  79. if v != nil {
  80. _c.SetDegradedCount(*v)
  81. }
  82. return _c
  83. }
  84. // SetFailedCount sets the "failed_count" field.
  85. func (_c *ChannelMonitorDailyRollupCreate) SetFailedCount(v int) *ChannelMonitorDailyRollupCreate {
  86. _c.mutation.SetFailedCount(v)
  87. return _c
  88. }
  89. // SetNillableFailedCount sets the "failed_count" field if the given value is not nil.
  90. func (_c *ChannelMonitorDailyRollupCreate) SetNillableFailedCount(v *int) *ChannelMonitorDailyRollupCreate {
  91. if v != nil {
  92. _c.SetFailedCount(*v)
  93. }
  94. return _c
  95. }
  96. // SetErrorCount sets the "error_count" field.
  97. func (_c *ChannelMonitorDailyRollupCreate) SetErrorCount(v int) *ChannelMonitorDailyRollupCreate {
  98. _c.mutation.SetErrorCount(v)
  99. return _c
  100. }
  101. // SetNillableErrorCount sets the "error_count" field if the given value is not nil.
  102. func (_c *ChannelMonitorDailyRollupCreate) SetNillableErrorCount(v *int) *ChannelMonitorDailyRollupCreate {
  103. if v != nil {
  104. _c.SetErrorCount(*v)
  105. }
  106. return _c
  107. }
  108. // SetSumLatencyMs sets the "sum_latency_ms" field.
  109. func (_c *ChannelMonitorDailyRollupCreate) SetSumLatencyMs(v int64) *ChannelMonitorDailyRollupCreate {
  110. _c.mutation.SetSumLatencyMs(v)
  111. return _c
  112. }
  113. // SetNillableSumLatencyMs sets the "sum_latency_ms" field if the given value is not nil.
  114. func (_c *ChannelMonitorDailyRollupCreate) SetNillableSumLatencyMs(v *int64) *ChannelMonitorDailyRollupCreate {
  115. if v != nil {
  116. _c.SetSumLatencyMs(*v)
  117. }
  118. return _c
  119. }
  120. // SetCountLatency sets the "count_latency" field.
  121. func (_c *ChannelMonitorDailyRollupCreate) SetCountLatency(v int) *ChannelMonitorDailyRollupCreate {
  122. _c.mutation.SetCountLatency(v)
  123. return _c
  124. }
  125. // SetNillableCountLatency sets the "count_latency" field if the given value is not nil.
  126. func (_c *ChannelMonitorDailyRollupCreate) SetNillableCountLatency(v *int) *ChannelMonitorDailyRollupCreate {
  127. if v != nil {
  128. _c.SetCountLatency(*v)
  129. }
  130. return _c
  131. }
  132. // SetSumPingLatencyMs sets the "sum_ping_latency_ms" field.
  133. func (_c *ChannelMonitorDailyRollupCreate) SetSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupCreate {
  134. _c.mutation.SetSumPingLatencyMs(v)
  135. return _c
  136. }
  137. // SetNillableSumPingLatencyMs sets the "sum_ping_latency_ms" field if the given value is not nil.
  138. func (_c *ChannelMonitorDailyRollupCreate) SetNillableSumPingLatencyMs(v *int64) *ChannelMonitorDailyRollupCreate {
  139. if v != nil {
  140. _c.SetSumPingLatencyMs(*v)
  141. }
  142. return _c
  143. }
  144. // SetCountPingLatency sets the "count_ping_latency" field.
  145. func (_c *ChannelMonitorDailyRollupCreate) SetCountPingLatency(v int) *ChannelMonitorDailyRollupCreate {
  146. _c.mutation.SetCountPingLatency(v)
  147. return _c
  148. }
  149. // SetNillableCountPingLatency sets the "count_ping_latency" field if the given value is not nil.
  150. func (_c *ChannelMonitorDailyRollupCreate) SetNillableCountPingLatency(v *int) *ChannelMonitorDailyRollupCreate {
  151. if v != nil {
  152. _c.SetCountPingLatency(*v)
  153. }
  154. return _c
  155. }
  156. // SetComputedAt sets the "computed_at" field.
  157. func (_c *ChannelMonitorDailyRollupCreate) SetComputedAt(v time.Time) *ChannelMonitorDailyRollupCreate {
  158. _c.mutation.SetComputedAt(v)
  159. return _c
  160. }
  161. // SetNillableComputedAt sets the "computed_at" field if the given value is not nil.
  162. func (_c *ChannelMonitorDailyRollupCreate) SetNillableComputedAt(v *time.Time) *ChannelMonitorDailyRollupCreate {
  163. if v != nil {
  164. _c.SetComputedAt(*v)
  165. }
  166. return _c
  167. }
  168. // SetMonitor sets the "monitor" edge to the ChannelMonitor entity.
  169. func (_c *ChannelMonitorDailyRollupCreate) SetMonitor(v *ChannelMonitor) *ChannelMonitorDailyRollupCreate {
  170. return _c.SetMonitorID(v.ID)
  171. }
  172. // Mutation returns the ChannelMonitorDailyRollupMutation object of the builder.
  173. func (_c *ChannelMonitorDailyRollupCreate) Mutation() *ChannelMonitorDailyRollupMutation {
  174. return _c.mutation
  175. }
  176. // Save creates the ChannelMonitorDailyRollup in the database.
  177. func (_c *ChannelMonitorDailyRollupCreate) Save(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
  178. _c.defaults()
  179. return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
  180. }
  181. // SaveX calls Save and panics if Save returns an error.
  182. func (_c *ChannelMonitorDailyRollupCreate) SaveX(ctx context.Context) *ChannelMonitorDailyRollup {
  183. v, err := _c.Save(ctx)
  184. if err != nil {
  185. panic(err)
  186. }
  187. return v
  188. }
  189. // Exec executes the query.
  190. func (_c *ChannelMonitorDailyRollupCreate) Exec(ctx context.Context) error {
  191. _, err := _c.Save(ctx)
  192. return err
  193. }
  194. // ExecX is like Exec, but panics if an error occurs.
  195. func (_c *ChannelMonitorDailyRollupCreate) ExecX(ctx context.Context) {
  196. if err := _c.Exec(ctx); err != nil {
  197. panic(err)
  198. }
  199. }
  200. // defaults sets the default values of the builder before save.
  201. func (_c *ChannelMonitorDailyRollupCreate) defaults() {
  202. if _, ok := _c.mutation.TotalChecks(); !ok {
  203. v := channelmonitordailyrollup.DefaultTotalChecks
  204. _c.mutation.SetTotalChecks(v)
  205. }
  206. if _, ok := _c.mutation.OkCount(); !ok {
  207. v := channelmonitordailyrollup.DefaultOkCount
  208. _c.mutation.SetOkCount(v)
  209. }
  210. if _, ok := _c.mutation.OperationalCount(); !ok {
  211. v := channelmonitordailyrollup.DefaultOperationalCount
  212. _c.mutation.SetOperationalCount(v)
  213. }
  214. if _, ok := _c.mutation.DegradedCount(); !ok {
  215. v := channelmonitordailyrollup.DefaultDegradedCount
  216. _c.mutation.SetDegradedCount(v)
  217. }
  218. if _, ok := _c.mutation.FailedCount(); !ok {
  219. v := channelmonitordailyrollup.DefaultFailedCount
  220. _c.mutation.SetFailedCount(v)
  221. }
  222. if _, ok := _c.mutation.ErrorCount(); !ok {
  223. v := channelmonitordailyrollup.DefaultErrorCount
  224. _c.mutation.SetErrorCount(v)
  225. }
  226. if _, ok := _c.mutation.SumLatencyMs(); !ok {
  227. v := channelmonitordailyrollup.DefaultSumLatencyMs
  228. _c.mutation.SetSumLatencyMs(v)
  229. }
  230. if _, ok := _c.mutation.CountLatency(); !ok {
  231. v := channelmonitordailyrollup.DefaultCountLatency
  232. _c.mutation.SetCountLatency(v)
  233. }
  234. if _, ok := _c.mutation.SumPingLatencyMs(); !ok {
  235. v := channelmonitordailyrollup.DefaultSumPingLatencyMs
  236. _c.mutation.SetSumPingLatencyMs(v)
  237. }
  238. if _, ok := _c.mutation.CountPingLatency(); !ok {
  239. v := channelmonitordailyrollup.DefaultCountPingLatency
  240. _c.mutation.SetCountPingLatency(v)
  241. }
  242. if _, ok := _c.mutation.ComputedAt(); !ok {
  243. v := channelmonitordailyrollup.DefaultComputedAt()
  244. _c.mutation.SetComputedAt(v)
  245. }
  246. }
  247. // check runs all checks and user-defined validators on the builder.
  248. func (_c *ChannelMonitorDailyRollupCreate) check() error {
  249. if _, ok := _c.mutation.MonitorID(); !ok {
  250. return &ValidationError{Name: "monitor_id", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.monitor_id"`)}
  251. }
  252. if _, ok := _c.mutation.Model(); !ok {
  253. return &ValidationError{Name: "model", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.model"`)}
  254. }
  255. if v, ok := _c.mutation.Model(); ok {
  256. if err := channelmonitordailyrollup.ModelValidator(v); err != nil {
  257. return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitorDailyRollup.model": %w`, err)}
  258. }
  259. }
  260. if _, ok := _c.mutation.BucketDate(); !ok {
  261. return &ValidationError{Name: "bucket_date", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.bucket_date"`)}
  262. }
  263. if _, ok := _c.mutation.TotalChecks(); !ok {
  264. return &ValidationError{Name: "total_checks", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.total_checks"`)}
  265. }
  266. if _, ok := _c.mutation.OkCount(); !ok {
  267. return &ValidationError{Name: "ok_count", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.ok_count"`)}
  268. }
  269. if _, ok := _c.mutation.OperationalCount(); !ok {
  270. return &ValidationError{Name: "operational_count", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.operational_count"`)}
  271. }
  272. if _, ok := _c.mutation.DegradedCount(); !ok {
  273. return &ValidationError{Name: "degraded_count", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.degraded_count"`)}
  274. }
  275. if _, ok := _c.mutation.FailedCount(); !ok {
  276. return &ValidationError{Name: "failed_count", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.failed_count"`)}
  277. }
  278. if _, ok := _c.mutation.ErrorCount(); !ok {
  279. return &ValidationError{Name: "error_count", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.error_count"`)}
  280. }
  281. if _, ok := _c.mutation.SumLatencyMs(); !ok {
  282. return &ValidationError{Name: "sum_latency_ms", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.sum_latency_ms"`)}
  283. }
  284. if _, ok := _c.mutation.CountLatency(); !ok {
  285. return &ValidationError{Name: "count_latency", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.count_latency"`)}
  286. }
  287. if _, ok := _c.mutation.SumPingLatencyMs(); !ok {
  288. return &ValidationError{Name: "sum_ping_latency_ms", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.sum_ping_latency_ms"`)}
  289. }
  290. if _, ok := _c.mutation.CountPingLatency(); !ok {
  291. return &ValidationError{Name: "count_ping_latency", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.count_ping_latency"`)}
  292. }
  293. if _, ok := _c.mutation.ComputedAt(); !ok {
  294. return &ValidationError{Name: "computed_at", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.computed_at"`)}
  295. }
  296. if len(_c.mutation.MonitorIDs()) == 0 {
  297. return &ValidationError{Name: "monitor", err: errors.New(`ent: missing required edge "ChannelMonitorDailyRollup.monitor"`)}
  298. }
  299. return nil
  300. }
  301. func (_c *ChannelMonitorDailyRollupCreate) sqlSave(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
  302. if err := _c.check(); err != nil {
  303. return nil, err
  304. }
  305. _node, _spec := _c.createSpec()
  306. if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
  307. if sqlgraph.IsConstraintError(err) {
  308. err = &ConstraintError{msg: err.Error(), wrap: err}
  309. }
  310. return nil, err
  311. }
  312. id := _spec.ID.Value.(int64)
  313. _node.ID = int64(id)
  314. _c.mutation.id = &_node.ID
  315. _c.mutation.done = true
  316. return _node, nil
  317. }
  318. func (_c *ChannelMonitorDailyRollupCreate) createSpec() (*ChannelMonitorDailyRollup, *sqlgraph.CreateSpec) {
  319. var (
  320. _node = &ChannelMonitorDailyRollup{config: _c.config}
  321. _spec = sqlgraph.NewCreateSpec(channelmonitordailyrollup.Table, sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64))
  322. )
  323. _spec.OnConflict = _c.conflict
  324. if value, ok := _c.mutation.Model(); ok {
  325. _spec.SetField(channelmonitordailyrollup.FieldModel, field.TypeString, value)
  326. _node.Model = value
  327. }
  328. if value, ok := _c.mutation.BucketDate(); ok {
  329. _spec.SetField(channelmonitordailyrollup.FieldBucketDate, field.TypeTime, value)
  330. _node.BucketDate = value
  331. }
  332. if value, ok := _c.mutation.TotalChecks(); ok {
  333. _spec.SetField(channelmonitordailyrollup.FieldTotalChecks, field.TypeInt, value)
  334. _node.TotalChecks = value
  335. }
  336. if value, ok := _c.mutation.OkCount(); ok {
  337. _spec.SetField(channelmonitordailyrollup.FieldOkCount, field.TypeInt, value)
  338. _node.OkCount = value
  339. }
  340. if value, ok := _c.mutation.OperationalCount(); ok {
  341. _spec.SetField(channelmonitordailyrollup.FieldOperationalCount, field.TypeInt, value)
  342. _node.OperationalCount = value
  343. }
  344. if value, ok := _c.mutation.DegradedCount(); ok {
  345. _spec.SetField(channelmonitordailyrollup.FieldDegradedCount, field.TypeInt, value)
  346. _node.DegradedCount = value
  347. }
  348. if value, ok := _c.mutation.FailedCount(); ok {
  349. _spec.SetField(channelmonitordailyrollup.FieldFailedCount, field.TypeInt, value)
  350. _node.FailedCount = value
  351. }
  352. if value, ok := _c.mutation.ErrorCount(); ok {
  353. _spec.SetField(channelmonitordailyrollup.FieldErrorCount, field.TypeInt, value)
  354. _node.ErrorCount = value
  355. }
  356. if value, ok := _c.mutation.SumLatencyMs(); ok {
  357. _spec.SetField(channelmonitordailyrollup.FieldSumLatencyMs, field.TypeInt64, value)
  358. _node.SumLatencyMs = value
  359. }
  360. if value, ok := _c.mutation.CountLatency(); ok {
  361. _spec.SetField(channelmonitordailyrollup.FieldCountLatency, field.TypeInt, value)
  362. _node.CountLatency = value
  363. }
  364. if value, ok := _c.mutation.SumPingLatencyMs(); ok {
  365. _spec.SetField(channelmonitordailyrollup.FieldSumPingLatencyMs, field.TypeInt64, value)
  366. _node.SumPingLatencyMs = value
  367. }
  368. if value, ok := _c.mutation.CountPingLatency(); ok {
  369. _spec.SetField(channelmonitordailyrollup.FieldCountPingLatency, field.TypeInt, value)
  370. _node.CountPingLatency = value
  371. }
  372. if value, ok := _c.mutation.ComputedAt(); ok {
  373. _spec.SetField(channelmonitordailyrollup.FieldComputedAt, field.TypeTime, value)
  374. _node.ComputedAt = value
  375. }
  376. if nodes := _c.mutation.MonitorIDs(); len(nodes) > 0 {
  377. edge := &sqlgraph.EdgeSpec{
  378. Rel: sqlgraph.M2O,
  379. Inverse: true,
  380. Table: channelmonitordailyrollup.MonitorTable,
  381. Columns: []string{channelmonitordailyrollup.MonitorColumn},
  382. Bidi: false,
  383. Target: &sqlgraph.EdgeTarget{
  384. IDSpec: sqlgraph.NewFieldSpec(channelmonitor.FieldID, field.TypeInt64),
  385. },
  386. }
  387. for _, k := range nodes {
  388. edge.Target.Nodes = append(edge.Target.Nodes, k)
  389. }
  390. _node.MonitorID = nodes[0]
  391. _spec.Edges = append(_spec.Edges, edge)
  392. }
  393. return _node, _spec
  394. }
  395. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  396. // of the `INSERT` statement. For example:
  397. //
  398. // client.ChannelMonitorDailyRollup.Create().
  399. // SetMonitorID(v).
  400. // OnConflict(
  401. // // Update the row with the new values
  402. // // the was proposed for insertion.
  403. // sql.ResolveWithNewValues(),
  404. // ).
  405. // // Override some of the fields with custom
  406. // // update values.
  407. // Update(func(u *ent.ChannelMonitorDailyRollupUpsert) {
  408. // SetMonitorID(v+v).
  409. // }).
  410. // Exec(ctx)
  411. func (_c *ChannelMonitorDailyRollupCreate) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorDailyRollupUpsertOne {
  412. _c.conflict = opts
  413. return &ChannelMonitorDailyRollupUpsertOne{
  414. create: _c,
  415. }
  416. }
  417. // OnConflictColumns calls `OnConflict` and configures the columns
  418. // as conflict target. Using this option is equivalent to using:
  419. //
  420. // client.ChannelMonitorDailyRollup.Create().
  421. // OnConflict(sql.ConflictColumns(columns...)).
  422. // Exec(ctx)
  423. func (_c *ChannelMonitorDailyRollupCreate) OnConflictColumns(columns ...string) *ChannelMonitorDailyRollupUpsertOne {
  424. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  425. return &ChannelMonitorDailyRollupUpsertOne{
  426. create: _c,
  427. }
  428. }
  429. type (
  430. // ChannelMonitorDailyRollupUpsertOne is the builder for "upsert"-ing
  431. // one ChannelMonitorDailyRollup node.
  432. ChannelMonitorDailyRollupUpsertOne struct {
  433. create *ChannelMonitorDailyRollupCreate
  434. }
  435. // ChannelMonitorDailyRollupUpsert is the "OnConflict" setter.
  436. ChannelMonitorDailyRollupUpsert struct {
  437. *sql.UpdateSet
  438. }
  439. )
  440. // SetMonitorID sets the "monitor_id" field.
  441. func (u *ChannelMonitorDailyRollupUpsert) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsert {
  442. u.Set(channelmonitordailyrollup.FieldMonitorID, v)
  443. return u
  444. }
  445. // UpdateMonitorID sets the "monitor_id" field to the value that was provided on create.
  446. func (u *ChannelMonitorDailyRollupUpsert) UpdateMonitorID() *ChannelMonitorDailyRollupUpsert {
  447. u.SetExcluded(channelmonitordailyrollup.FieldMonitorID)
  448. return u
  449. }
  450. // SetModel sets the "model" field.
  451. func (u *ChannelMonitorDailyRollupUpsert) SetModel(v string) *ChannelMonitorDailyRollupUpsert {
  452. u.Set(channelmonitordailyrollup.FieldModel, v)
  453. return u
  454. }
  455. // UpdateModel sets the "model" field to the value that was provided on create.
  456. func (u *ChannelMonitorDailyRollupUpsert) UpdateModel() *ChannelMonitorDailyRollupUpsert {
  457. u.SetExcluded(channelmonitordailyrollup.FieldModel)
  458. return u
  459. }
  460. // SetBucketDate sets the "bucket_date" field.
  461. func (u *ChannelMonitorDailyRollupUpsert) SetBucketDate(v time.Time) *ChannelMonitorDailyRollupUpsert {
  462. u.Set(channelmonitordailyrollup.FieldBucketDate, v)
  463. return u
  464. }
  465. // UpdateBucketDate sets the "bucket_date" field to the value that was provided on create.
  466. func (u *ChannelMonitorDailyRollupUpsert) UpdateBucketDate() *ChannelMonitorDailyRollupUpsert {
  467. u.SetExcluded(channelmonitordailyrollup.FieldBucketDate)
  468. return u
  469. }
  470. // SetTotalChecks sets the "total_checks" field.
  471. func (u *ChannelMonitorDailyRollupUpsert) SetTotalChecks(v int) *ChannelMonitorDailyRollupUpsert {
  472. u.Set(channelmonitordailyrollup.FieldTotalChecks, v)
  473. return u
  474. }
  475. // UpdateTotalChecks sets the "total_checks" field to the value that was provided on create.
  476. func (u *ChannelMonitorDailyRollupUpsert) UpdateTotalChecks() *ChannelMonitorDailyRollupUpsert {
  477. u.SetExcluded(channelmonitordailyrollup.FieldTotalChecks)
  478. return u
  479. }
  480. // AddTotalChecks adds v to the "total_checks" field.
  481. func (u *ChannelMonitorDailyRollupUpsert) AddTotalChecks(v int) *ChannelMonitorDailyRollupUpsert {
  482. u.Add(channelmonitordailyrollup.FieldTotalChecks, v)
  483. return u
  484. }
  485. // SetOkCount sets the "ok_count" field.
  486. func (u *ChannelMonitorDailyRollupUpsert) SetOkCount(v int) *ChannelMonitorDailyRollupUpsert {
  487. u.Set(channelmonitordailyrollup.FieldOkCount, v)
  488. return u
  489. }
  490. // UpdateOkCount sets the "ok_count" field to the value that was provided on create.
  491. func (u *ChannelMonitorDailyRollupUpsert) UpdateOkCount() *ChannelMonitorDailyRollupUpsert {
  492. u.SetExcluded(channelmonitordailyrollup.FieldOkCount)
  493. return u
  494. }
  495. // AddOkCount adds v to the "ok_count" field.
  496. func (u *ChannelMonitorDailyRollupUpsert) AddOkCount(v int) *ChannelMonitorDailyRollupUpsert {
  497. u.Add(channelmonitordailyrollup.FieldOkCount, v)
  498. return u
  499. }
  500. // SetOperationalCount sets the "operational_count" field.
  501. func (u *ChannelMonitorDailyRollupUpsert) SetOperationalCount(v int) *ChannelMonitorDailyRollupUpsert {
  502. u.Set(channelmonitordailyrollup.FieldOperationalCount, v)
  503. return u
  504. }
  505. // UpdateOperationalCount sets the "operational_count" field to the value that was provided on create.
  506. func (u *ChannelMonitorDailyRollupUpsert) UpdateOperationalCount() *ChannelMonitorDailyRollupUpsert {
  507. u.SetExcluded(channelmonitordailyrollup.FieldOperationalCount)
  508. return u
  509. }
  510. // AddOperationalCount adds v to the "operational_count" field.
  511. func (u *ChannelMonitorDailyRollupUpsert) AddOperationalCount(v int) *ChannelMonitorDailyRollupUpsert {
  512. u.Add(channelmonitordailyrollup.FieldOperationalCount, v)
  513. return u
  514. }
  515. // SetDegradedCount sets the "degraded_count" field.
  516. func (u *ChannelMonitorDailyRollupUpsert) SetDegradedCount(v int) *ChannelMonitorDailyRollupUpsert {
  517. u.Set(channelmonitordailyrollup.FieldDegradedCount, v)
  518. return u
  519. }
  520. // UpdateDegradedCount sets the "degraded_count" field to the value that was provided on create.
  521. func (u *ChannelMonitorDailyRollupUpsert) UpdateDegradedCount() *ChannelMonitorDailyRollupUpsert {
  522. u.SetExcluded(channelmonitordailyrollup.FieldDegradedCount)
  523. return u
  524. }
  525. // AddDegradedCount adds v to the "degraded_count" field.
  526. func (u *ChannelMonitorDailyRollupUpsert) AddDegradedCount(v int) *ChannelMonitorDailyRollupUpsert {
  527. u.Add(channelmonitordailyrollup.FieldDegradedCount, v)
  528. return u
  529. }
  530. // SetFailedCount sets the "failed_count" field.
  531. func (u *ChannelMonitorDailyRollupUpsert) SetFailedCount(v int) *ChannelMonitorDailyRollupUpsert {
  532. u.Set(channelmonitordailyrollup.FieldFailedCount, v)
  533. return u
  534. }
  535. // UpdateFailedCount sets the "failed_count" field to the value that was provided on create.
  536. func (u *ChannelMonitorDailyRollupUpsert) UpdateFailedCount() *ChannelMonitorDailyRollupUpsert {
  537. u.SetExcluded(channelmonitordailyrollup.FieldFailedCount)
  538. return u
  539. }
  540. // AddFailedCount adds v to the "failed_count" field.
  541. func (u *ChannelMonitorDailyRollupUpsert) AddFailedCount(v int) *ChannelMonitorDailyRollupUpsert {
  542. u.Add(channelmonitordailyrollup.FieldFailedCount, v)
  543. return u
  544. }
  545. // SetErrorCount sets the "error_count" field.
  546. func (u *ChannelMonitorDailyRollupUpsert) SetErrorCount(v int) *ChannelMonitorDailyRollupUpsert {
  547. u.Set(channelmonitordailyrollup.FieldErrorCount, v)
  548. return u
  549. }
  550. // UpdateErrorCount sets the "error_count" field to the value that was provided on create.
  551. func (u *ChannelMonitorDailyRollupUpsert) UpdateErrorCount() *ChannelMonitorDailyRollupUpsert {
  552. u.SetExcluded(channelmonitordailyrollup.FieldErrorCount)
  553. return u
  554. }
  555. // AddErrorCount adds v to the "error_count" field.
  556. func (u *ChannelMonitorDailyRollupUpsert) AddErrorCount(v int) *ChannelMonitorDailyRollupUpsert {
  557. u.Add(channelmonitordailyrollup.FieldErrorCount, v)
  558. return u
  559. }
  560. // SetSumLatencyMs sets the "sum_latency_ms" field.
  561. func (u *ChannelMonitorDailyRollupUpsert) SetSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpsert {
  562. u.Set(channelmonitordailyrollup.FieldSumLatencyMs, v)
  563. return u
  564. }
  565. // UpdateSumLatencyMs sets the "sum_latency_ms" field to the value that was provided on create.
  566. func (u *ChannelMonitorDailyRollupUpsert) UpdateSumLatencyMs() *ChannelMonitorDailyRollupUpsert {
  567. u.SetExcluded(channelmonitordailyrollup.FieldSumLatencyMs)
  568. return u
  569. }
  570. // AddSumLatencyMs adds v to the "sum_latency_ms" field.
  571. func (u *ChannelMonitorDailyRollupUpsert) AddSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpsert {
  572. u.Add(channelmonitordailyrollup.FieldSumLatencyMs, v)
  573. return u
  574. }
  575. // SetCountLatency sets the "count_latency" field.
  576. func (u *ChannelMonitorDailyRollupUpsert) SetCountLatency(v int) *ChannelMonitorDailyRollupUpsert {
  577. u.Set(channelmonitordailyrollup.FieldCountLatency, v)
  578. return u
  579. }
  580. // UpdateCountLatency sets the "count_latency" field to the value that was provided on create.
  581. func (u *ChannelMonitorDailyRollupUpsert) UpdateCountLatency() *ChannelMonitorDailyRollupUpsert {
  582. u.SetExcluded(channelmonitordailyrollup.FieldCountLatency)
  583. return u
  584. }
  585. // AddCountLatency adds v to the "count_latency" field.
  586. func (u *ChannelMonitorDailyRollupUpsert) AddCountLatency(v int) *ChannelMonitorDailyRollupUpsert {
  587. u.Add(channelmonitordailyrollup.FieldCountLatency, v)
  588. return u
  589. }
  590. // SetSumPingLatencyMs sets the "sum_ping_latency_ms" field.
  591. func (u *ChannelMonitorDailyRollupUpsert) SetSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpsert {
  592. u.Set(channelmonitordailyrollup.FieldSumPingLatencyMs, v)
  593. return u
  594. }
  595. // UpdateSumPingLatencyMs sets the "sum_ping_latency_ms" field to the value that was provided on create.
  596. func (u *ChannelMonitorDailyRollupUpsert) UpdateSumPingLatencyMs() *ChannelMonitorDailyRollupUpsert {
  597. u.SetExcluded(channelmonitordailyrollup.FieldSumPingLatencyMs)
  598. return u
  599. }
  600. // AddSumPingLatencyMs adds v to the "sum_ping_latency_ms" field.
  601. func (u *ChannelMonitorDailyRollupUpsert) AddSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpsert {
  602. u.Add(channelmonitordailyrollup.FieldSumPingLatencyMs, v)
  603. return u
  604. }
  605. // SetCountPingLatency sets the "count_ping_latency" field.
  606. func (u *ChannelMonitorDailyRollupUpsert) SetCountPingLatency(v int) *ChannelMonitorDailyRollupUpsert {
  607. u.Set(channelmonitordailyrollup.FieldCountPingLatency, v)
  608. return u
  609. }
  610. // UpdateCountPingLatency sets the "count_ping_latency" field to the value that was provided on create.
  611. func (u *ChannelMonitorDailyRollupUpsert) UpdateCountPingLatency() *ChannelMonitorDailyRollupUpsert {
  612. u.SetExcluded(channelmonitordailyrollup.FieldCountPingLatency)
  613. return u
  614. }
  615. // AddCountPingLatency adds v to the "count_ping_latency" field.
  616. func (u *ChannelMonitorDailyRollupUpsert) AddCountPingLatency(v int) *ChannelMonitorDailyRollupUpsert {
  617. u.Add(channelmonitordailyrollup.FieldCountPingLatency, v)
  618. return u
  619. }
  620. // SetComputedAt sets the "computed_at" field.
  621. func (u *ChannelMonitorDailyRollupUpsert) SetComputedAt(v time.Time) *ChannelMonitorDailyRollupUpsert {
  622. u.Set(channelmonitordailyrollup.FieldComputedAt, v)
  623. return u
  624. }
  625. // UpdateComputedAt sets the "computed_at" field to the value that was provided on create.
  626. func (u *ChannelMonitorDailyRollupUpsert) UpdateComputedAt() *ChannelMonitorDailyRollupUpsert {
  627. u.SetExcluded(channelmonitordailyrollup.FieldComputedAt)
  628. return u
  629. }
  630. // UpdateNewValues updates the mutable fields using the new values that were set on create.
  631. // Using this option is equivalent to using:
  632. //
  633. // client.ChannelMonitorDailyRollup.Create().
  634. // OnConflict(
  635. // sql.ResolveWithNewValues(),
  636. // ).
  637. // Exec(ctx)
  638. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateNewValues() *ChannelMonitorDailyRollupUpsertOne {
  639. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  640. return u
  641. }
  642. // Ignore sets each column to itself in case of conflict.
  643. // Using this option is equivalent to using:
  644. //
  645. // client.ChannelMonitorDailyRollup.Create().
  646. // OnConflict(sql.ResolveWithIgnore()).
  647. // Exec(ctx)
  648. func (u *ChannelMonitorDailyRollupUpsertOne) Ignore() *ChannelMonitorDailyRollupUpsertOne {
  649. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  650. return u
  651. }
  652. // DoNothing configures the conflict_action to `DO NOTHING`.
  653. // Supported only by SQLite and PostgreSQL.
  654. func (u *ChannelMonitorDailyRollupUpsertOne) DoNothing() *ChannelMonitorDailyRollupUpsertOne {
  655. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  656. return u
  657. }
  658. // Update allows overriding fields `UPDATE` values. See the ChannelMonitorDailyRollupCreate.OnConflict
  659. // documentation for more info.
  660. func (u *ChannelMonitorDailyRollupUpsertOne) Update(set func(*ChannelMonitorDailyRollupUpsert)) *ChannelMonitorDailyRollupUpsertOne {
  661. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  662. set(&ChannelMonitorDailyRollupUpsert{UpdateSet: update})
  663. }))
  664. return u
  665. }
  666. // SetMonitorID sets the "monitor_id" field.
  667. func (u *ChannelMonitorDailyRollupUpsertOne) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsertOne {
  668. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  669. s.SetMonitorID(v)
  670. })
  671. }
  672. // UpdateMonitorID sets the "monitor_id" field to the value that was provided on create.
  673. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateMonitorID() *ChannelMonitorDailyRollupUpsertOne {
  674. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  675. s.UpdateMonitorID()
  676. })
  677. }
  678. // SetModel sets the "model" field.
  679. func (u *ChannelMonitorDailyRollupUpsertOne) SetModel(v string) *ChannelMonitorDailyRollupUpsertOne {
  680. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  681. s.SetModel(v)
  682. })
  683. }
  684. // UpdateModel sets the "model" field to the value that was provided on create.
  685. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateModel() *ChannelMonitorDailyRollupUpsertOne {
  686. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  687. s.UpdateModel()
  688. })
  689. }
  690. // SetBucketDate sets the "bucket_date" field.
  691. func (u *ChannelMonitorDailyRollupUpsertOne) SetBucketDate(v time.Time) *ChannelMonitorDailyRollupUpsertOne {
  692. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  693. s.SetBucketDate(v)
  694. })
  695. }
  696. // UpdateBucketDate sets the "bucket_date" field to the value that was provided on create.
  697. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateBucketDate() *ChannelMonitorDailyRollupUpsertOne {
  698. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  699. s.UpdateBucketDate()
  700. })
  701. }
  702. // SetTotalChecks sets the "total_checks" field.
  703. func (u *ChannelMonitorDailyRollupUpsertOne) SetTotalChecks(v int) *ChannelMonitorDailyRollupUpsertOne {
  704. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  705. s.SetTotalChecks(v)
  706. })
  707. }
  708. // AddTotalChecks adds v to the "total_checks" field.
  709. func (u *ChannelMonitorDailyRollupUpsertOne) AddTotalChecks(v int) *ChannelMonitorDailyRollupUpsertOne {
  710. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  711. s.AddTotalChecks(v)
  712. })
  713. }
  714. // UpdateTotalChecks sets the "total_checks" field to the value that was provided on create.
  715. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateTotalChecks() *ChannelMonitorDailyRollupUpsertOne {
  716. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  717. s.UpdateTotalChecks()
  718. })
  719. }
  720. // SetOkCount sets the "ok_count" field.
  721. func (u *ChannelMonitorDailyRollupUpsertOne) SetOkCount(v int) *ChannelMonitorDailyRollupUpsertOne {
  722. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  723. s.SetOkCount(v)
  724. })
  725. }
  726. // AddOkCount adds v to the "ok_count" field.
  727. func (u *ChannelMonitorDailyRollupUpsertOne) AddOkCount(v int) *ChannelMonitorDailyRollupUpsertOne {
  728. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  729. s.AddOkCount(v)
  730. })
  731. }
  732. // UpdateOkCount sets the "ok_count" field to the value that was provided on create.
  733. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateOkCount() *ChannelMonitorDailyRollupUpsertOne {
  734. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  735. s.UpdateOkCount()
  736. })
  737. }
  738. // SetOperationalCount sets the "operational_count" field.
  739. func (u *ChannelMonitorDailyRollupUpsertOne) SetOperationalCount(v int) *ChannelMonitorDailyRollupUpsertOne {
  740. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  741. s.SetOperationalCount(v)
  742. })
  743. }
  744. // AddOperationalCount adds v to the "operational_count" field.
  745. func (u *ChannelMonitorDailyRollupUpsertOne) AddOperationalCount(v int) *ChannelMonitorDailyRollupUpsertOne {
  746. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  747. s.AddOperationalCount(v)
  748. })
  749. }
  750. // UpdateOperationalCount sets the "operational_count" field to the value that was provided on create.
  751. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateOperationalCount() *ChannelMonitorDailyRollupUpsertOne {
  752. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  753. s.UpdateOperationalCount()
  754. })
  755. }
  756. // SetDegradedCount sets the "degraded_count" field.
  757. func (u *ChannelMonitorDailyRollupUpsertOne) SetDegradedCount(v int) *ChannelMonitorDailyRollupUpsertOne {
  758. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  759. s.SetDegradedCount(v)
  760. })
  761. }
  762. // AddDegradedCount adds v to the "degraded_count" field.
  763. func (u *ChannelMonitorDailyRollupUpsertOne) AddDegradedCount(v int) *ChannelMonitorDailyRollupUpsertOne {
  764. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  765. s.AddDegradedCount(v)
  766. })
  767. }
  768. // UpdateDegradedCount sets the "degraded_count" field to the value that was provided on create.
  769. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateDegradedCount() *ChannelMonitorDailyRollupUpsertOne {
  770. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  771. s.UpdateDegradedCount()
  772. })
  773. }
  774. // SetFailedCount sets the "failed_count" field.
  775. func (u *ChannelMonitorDailyRollupUpsertOne) SetFailedCount(v int) *ChannelMonitorDailyRollupUpsertOne {
  776. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  777. s.SetFailedCount(v)
  778. })
  779. }
  780. // AddFailedCount adds v to the "failed_count" field.
  781. func (u *ChannelMonitorDailyRollupUpsertOne) AddFailedCount(v int) *ChannelMonitorDailyRollupUpsertOne {
  782. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  783. s.AddFailedCount(v)
  784. })
  785. }
  786. // UpdateFailedCount sets the "failed_count" field to the value that was provided on create.
  787. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateFailedCount() *ChannelMonitorDailyRollupUpsertOne {
  788. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  789. s.UpdateFailedCount()
  790. })
  791. }
  792. // SetErrorCount sets the "error_count" field.
  793. func (u *ChannelMonitorDailyRollupUpsertOne) SetErrorCount(v int) *ChannelMonitorDailyRollupUpsertOne {
  794. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  795. s.SetErrorCount(v)
  796. })
  797. }
  798. // AddErrorCount adds v to the "error_count" field.
  799. func (u *ChannelMonitorDailyRollupUpsertOne) AddErrorCount(v int) *ChannelMonitorDailyRollupUpsertOne {
  800. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  801. s.AddErrorCount(v)
  802. })
  803. }
  804. // UpdateErrorCount sets the "error_count" field to the value that was provided on create.
  805. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateErrorCount() *ChannelMonitorDailyRollupUpsertOne {
  806. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  807. s.UpdateErrorCount()
  808. })
  809. }
  810. // SetSumLatencyMs sets the "sum_latency_ms" field.
  811. func (u *ChannelMonitorDailyRollupUpsertOne) SetSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertOne {
  812. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  813. s.SetSumLatencyMs(v)
  814. })
  815. }
  816. // AddSumLatencyMs adds v to the "sum_latency_ms" field.
  817. func (u *ChannelMonitorDailyRollupUpsertOne) AddSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertOne {
  818. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  819. s.AddSumLatencyMs(v)
  820. })
  821. }
  822. // UpdateSumLatencyMs sets the "sum_latency_ms" field to the value that was provided on create.
  823. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateSumLatencyMs() *ChannelMonitorDailyRollupUpsertOne {
  824. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  825. s.UpdateSumLatencyMs()
  826. })
  827. }
  828. // SetCountLatency sets the "count_latency" field.
  829. func (u *ChannelMonitorDailyRollupUpsertOne) SetCountLatency(v int) *ChannelMonitorDailyRollupUpsertOne {
  830. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  831. s.SetCountLatency(v)
  832. })
  833. }
  834. // AddCountLatency adds v to the "count_latency" field.
  835. func (u *ChannelMonitorDailyRollupUpsertOne) AddCountLatency(v int) *ChannelMonitorDailyRollupUpsertOne {
  836. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  837. s.AddCountLatency(v)
  838. })
  839. }
  840. // UpdateCountLatency sets the "count_latency" field to the value that was provided on create.
  841. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateCountLatency() *ChannelMonitorDailyRollupUpsertOne {
  842. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  843. s.UpdateCountLatency()
  844. })
  845. }
  846. // SetSumPingLatencyMs sets the "sum_ping_latency_ms" field.
  847. func (u *ChannelMonitorDailyRollupUpsertOne) SetSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertOne {
  848. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  849. s.SetSumPingLatencyMs(v)
  850. })
  851. }
  852. // AddSumPingLatencyMs adds v to the "sum_ping_latency_ms" field.
  853. func (u *ChannelMonitorDailyRollupUpsertOne) AddSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertOne {
  854. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  855. s.AddSumPingLatencyMs(v)
  856. })
  857. }
  858. // UpdateSumPingLatencyMs sets the "sum_ping_latency_ms" field to the value that was provided on create.
  859. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateSumPingLatencyMs() *ChannelMonitorDailyRollupUpsertOne {
  860. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  861. s.UpdateSumPingLatencyMs()
  862. })
  863. }
  864. // SetCountPingLatency sets the "count_ping_latency" field.
  865. func (u *ChannelMonitorDailyRollupUpsertOne) SetCountPingLatency(v int) *ChannelMonitorDailyRollupUpsertOne {
  866. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  867. s.SetCountPingLatency(v)
  868. })
  869. }
  870. // AddCountPingLatency adds v to the "count_ping_latency" field.
  871. func (u *ChannelMonitorDailyRollupUpsertOne) AddCountPingLatency(v int) *ChannelMonitorDailyRollupUpsertOne {
  872. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  873. s.AddCountPingLatency(v)
  874. })
  875. }
  876. // UpdateCountPingLatency sets the "count_ping_latency" field to the value that was provided on create.
  877. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateCountPingLatency() *ChannelMonitorDailyRollupUpsertOne {
  878. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  879. s.UpdateCountPingLatency()
  880. })
  881. }
  882. // SetComputedAt sets the "computed_at" field.
  883. func (u *ChannelMonitorDailyRollupUpsertOne) SetComputedAt(v time.Time) *ChannelMonitorDailyRollupUpsertOne {
  884. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  885. s.SetComputedAt(v)
  886. })
  887. }
  888. // UpdateComputedAt sets the "computed_at" field to the value that was provided on create.
  889. func (u *ChannelMonitorDailyRollupUpsertOne) UpdateComputedAt() *ChannelMonitorDailyRollupUpsertOne {
  890. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  891. s.UpdateComputedAt()
  892. })
  893. }
  894. // Exec executes the query.
  895. func (u *ChannelMonitorDailyRollupUpsertOne) Exec(ctx context.Context) error {
  896. if len(u.create.conflict) == 0 {
  897. return errors.New("ent: missing options for ChannelMonitorDailyRollupCreate.OnConflict")
  898. }
  899. return u.create.Exec(ctx)
  900. }
  901. // ExecX is like Exec, but panics if an error occurs.
  902. func (u *ChannelMonitorDailyRollupUpsertOne) ExecX(ctx context.Context) {
  903. if err := u.create.Exec(ctx); err != nil {
  904. panic(err)
  905. }
  906. }
  907. // Exec executes the UPSERT query and returns the inserted/updated ID.
  908. func (u *ChannelMonitorDailyRollupUpsertOne) ID(ctx context.Context) (id int64, err error) {
  909. node, err := u.create.Save(ctx)
  910. if err != nil {
  911. return id, err
  912. }
  913. return node.ID, nil
  914. }
  915. // IDX is like ID, but panics if an error occurs.
  916. func (u *ChannelMonitorDailyRollupUpsertOne) IDX(ctx context.Context) int64 {
  917. id, err := u.ID(ctx)
  918. if err != nil {
  919. panic(err)
  920. }
  921. return id
  922. }
  923. // ChannelMonitorDailyRollupCreateBulk is the builder for creating many ChannelMonitorDailyRollup entities in bulk.
  924. type ChannelMonitorDailyRollupCreateBulk struct {
  925. config
  926. err error
  927. builders []*ChannelMonitorDailyRollupCreate
  928. conflict []sql.ConflictOption
  929. }
  930. // Save creates the ChannelMonitorDailyRollup entities in the database.
  931. func (_c *ChannelMonitorDailyRollupCreateBulk) Save(ctx context.Context) ([]*ChannelMonitorDailyRollup, error) {
  932. if _c.err != nil {
  933. return nil, _c.err
  934. }
  935. specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
  936. nodes := make([]*ChannelMonitorDailyRollup, len(_c.builders))
  937. mutators := make([]Mutator, len(_c.builders))
  938. for i := range _c.builders {
  939. func(i int, root context.Context) {
  940. builder := _c.builders[i]
  941. builder.defaults()
  942. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  943. mutation, ok := m.(*ChannelMonitorDailyRollupMutation)
  944. if !ok {
  945. return nil, fmt.Errorf("unexpected mutation type %T", m)
  946. }
  947. if err := builder.check(); err != nil {
  948. return nil, err
  949. }
  950. builder.mutation = mutation
  951. var err error
  952. nodes[i], specs[i] = builder.createSpec()
  953. if i < len(mutators)-1 {
  954. _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
  955. } else {
  956. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  957. spec.OnConflict = _c.conflict
  958. // Invoke the actual operation on the latest mutation in the chain.
  959. if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
  960. if sqlgraph.IsConstraintError(err) {
  961. err = &ConstraintError{msg: err.Error(), wrap: err}
  962. }
  963. }
  964. }
  965. if err != nil {
  966. return nil, err
  967. }
  968. mutation.id = &nodes[i].ID
  969. if specs[i].ID.Value != nil {
  970. id := specs[i].ID.Value.(int64)
  971. nodes[i].ID = int64(id)
  972. }
  973. mutation.done = true
  974. return nodes[i], nil
  975. })
  976. for i := len(builder.hooks) - 1; i >= 0; i-- {
  977. mut = builder.hooks[i](mut)
  978. }
  979. mutators[i] = mut
  980. }(i, ctx)
  981. }
  982. if len(mutators) > 0 {
  983. if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
  984. return nil, err
  985. }
  986. }
  987. return nodes, nil
  988. }
  989. // SaveX is like Save, but panics if an error occurs.
  990. func (_c *ChannelMonitorDailyRollupCreateBulk) SaveX(ctx context.Context) []*ChannelMonitorDailyRollup {
  991. v, err := _c.Save(ctx)
  992. if err != nil {
  993. panic(err)
  994. }
  995. return v
  996. }
  997. // Exec executes the query.
  998. func (_c *ChannelMonitorDailyRollupCreateBulk) Exec(ctx context.Context) error {
  999. _, err := _c.Save(ctx)
  1000. return err
  1001. }
  1002. // ExecX is like Exec, but panics if an error occurs.
  1003. func (_c *ChannelMonitorDailyRollupCreateBulk) ExecX(ctx context.Context) {
  1004. if err := _c.Exec(ctx); err != nil {
  1005. panic(err)
  1006. }
  1007. }
  1008. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1009. // of the `INSERT` statement. For example:
  1010. //
  1011. // client.ChannelMonitorDailyRollup.CreateBulk(builders...).
  1012. // OnConflict(
  1013. // // Update the row with the new values
  1014. // // the was proposed for insertion.
  1015. // sql.ResolveWithNewValues(),
  1016. // ).
  1017. // // Override some of the fields with custom
  1018. // // update values.
  1019. // Update(func(u *ent.ChannelMonitorDailyRollupUpsert) {
  1020. // SetMonitorID(v+v).
  1021. // }).
  1022. // Exec(ctx)
  1023. func (_c *ChannelMonitorDailyRollupCreateBulk) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorDailyRollupUpsertBulk {
  1024. _c.conflict = opts
  1025. return &ChannelMonitorDailyRollupUpsertBulk{
  1026. create: _c,
  1027. }
  1028. }
  1029. // OnConflictColumns calls `OnConflict` and configures the columns
  1030. // as conflict target. Using this option is equivalent to using:
  1031. //
  1032. // client.ChannelMonitorDailyRollup.Create().
  1033. // OnConflict(sql.ConflictColumns(columns...)).
  1034. // Exec(ctx)
  1035. func (_c *ChannelMonitorDailyRollupCreateBulk) OnConflictColumns(columns ...string) *ChannelMonitorDailyRollupUpsertBulk {
  1036. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  1037. return &ChannelMonitorDailyRollupUpsertBulk{
  1038. create: _c,
  1039. }
  1040. }
  1041. // ChannelMonitorDailyRollupUpsertBulk is the builder for "upsert"-ing
  1042. // a bulk of ChannelMonitorDailyRollup nodes.
  1043. type ChannelMonitorDailyRollupUpsertBulk struct {
  1044. create *ChannelMonitorDailyRollupCreateBulk
  1045. }
  1046. // UpdateNewValues updates the mutable fields using the new values that
  1047. // were set on create. Using this option is equivalent to using:
  1048. //
  1049. // client.ChannelMonitorDailyRollup.Create().
  1050. // OnConflict(
  1051. // sql.ResolveWithNewValues(),
  1052. // ).
  1053. // Exec(ctx)
  1054. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateNewValues() *ChannelMonitorDailyRollupUpsertBulk {
  1055. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1056. return u
  1057. }
  1058. // Ignore sets each column to itself in case of conflict.
  1059. // Using this option is equivalent to using:
  1060. //
  1061. // client.ChannelMonitorDailyRollup.Create().
  1062. // OnConflict(sql.ResolveWithIgnore()).
  1063. // Exec(ctx)
  1064. func (u *ChannelMonitorDailyRollupUpsertBulk) Ignore() *ChannelMonitorDailyRollupUpsertBulk {
  1065. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1066. return u
  1067. }
  1068. // DoNothing configures the conflict_action to `DO NOTHING`.
  1069. // Supported only by SQLite and PostgreSQL.
  1070. func (u *ChannelMonitorDailyRollupUpsertBulk) DoNothing() *ChannelMonitorDailyRollupUpsertBulk {
  1071. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1072. return u
  1073. }
  1074. // Update allows overriding fields `UPDATE` values. See the ChannelMonitorDailyRollupCreateBulk.OnConflict
  1075. // documentation for more info.
  1076. func (u *ChannelMonitorDailyRollupUpsertBulk) Update(set func(*ChannelMonitorDailyRollupUpsert)) *ChannelMonitorDailyRollupUpsertBulk {
  1077. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1078. set(&ChannelMonitorDailyRollupUpsert{UpdateSet: update})
  1079. }))
  1080. return u
  1081. }
  1082. // SetMonitorID sets the "monitor_id" field.
  1083. func (u *ChannelMonitorDailyRollupUpsertBulk) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsertBulk {
  1084. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1085. s.SetMonitorID(v)
  1086. })
  1087. }
  1088. // UpdateMonitorID sets the "monitor_id" field to the value that was provided on create.
  1089. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateMonitorID() *ChannelMonitorDailyRollupUpsertBulk {
  1090. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1091. s.UpdateMonitorID()
  1092. })
  1093. }
  1094. // SetModel sets the "model" field.
  1095. func (u *ChannelMonitorDailyRollupUpsertBulk) SetModel(v string) *ChannelMonitorDailyRollupUpsertBulk {
  1096. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1097. s.SetModel(v)
  1098. })
  1099. }
  1100. // UpdateModel sets the "model" field to the value that was provided on create.
  1101. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateModel() *ChannelMonitorDailyRollupUpsertBulk {
  1102. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1103. s.UpdateModel()
  1104. })
  1105. }
  1106. // SetBucketDate sets the "bucket_date" field.
  1107. func (u *ChannelMonitorDailyRollupUpsertBulk) SetBucketDate(v time.Time) *ChannelMonitorDailyRollupUpsertBulk {
  1108. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1109. s.SetBucketDate(v)
  1110. })
  1111. }
  1112. // UpdateBucketDate sets the "bucket_date" field to the value that was provided on create.
  1113. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateBucketDate() *ChannelMonitorDailyRollupUpsertBulk {
  1114. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1115. s.UpdateBucketDate()
  1116. })
  1117. }
  1118. // SetTotalChecks sets the "total_checks" field.
  1119. func (u *ChannelMonitorDailyRollupUpsertBulk) SetTotalChecks(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1120. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1121. s.SetTotalChecks(v)
  1122. })
  1123. }
  1124. // AddTotalChecks adds v to the "total_checks" field.
  1125. func (u *ChannelMonitorDailyRollupUpsertBulk) AddTotalChecks(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1126. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1127. s.AddTotalChecks(v)
  1128. })
  1129. }
  1130. // UpdateTotalChecks sets the "total_checks" field to the value that was provided on create.
  1131. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateTotalChecks() *ChannelMonitorDailyRollupUpsertBulk {
  1132. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1133. s.UpdateTotalChecks()
  1134. })
  1135. }
  1136. // SetOkCount sets the "ok_count" field.
  1137. func (u *ChannelMonitorDailyRollupUpsertBulk) SetOkCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1138. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1139. s.SetOkCount(v)
  1140. })
  1141. }
  1142. // AddOkCount adds v to the "ok_count" field.
  1143. func (u *ChannelMonitorDailyRollupUpsertBulk) AddOkCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1144. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1145. s.AddOkCount(v)
  1146. })
  1147. }
  1148. // UpdateOkCount sets the "ok_count" field to the value that was provided on create.
  1149. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateOkCount() *ChannelMonitorDailyRollupUpsertBulk {
  1150. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1151. s.UpdateOkCount()
  1152. })
  1153. }
  1154. // SetOperationalCount sets the "operational_count" field.
  1155. func (u *ChannelMonitorDailyRollupUpsertBulk) SetOperationalCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1156. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1157. s.SetOperationalCount(v)
  1158. })
  1159. }
  1160. // AddOperationalCount adds v to the "operational_count" field.
  1161. func (u *ChannelMonitorDailyRollupUpsertBulk) AddOperationalCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1162. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1163. s.AddOperationalCount(v)
  1164. })
  1165. }
  1166. // UpdateOperationalCount sets the "operational_count" field to the value that was provided on create.
  1167. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateOperationalCount() *ChannelMonitorDailyRollupUpsertBulk {
  1168. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1169. s.UpdateOperationalCount()
  1170. })
  1171. }
  1172. // SetDegradedCount sets the "degraded_count" field.
  1173. func (u *ChannelMonitorDailyRollupUpsertBulk) SetDegradedCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1174. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1175. s.SetDegradedCount(v)
  1176. })
  1177. }
  1178. // AddDegradedCount adds v to the "degraded_count" field.
  1179. func (u *ChannelMonitorDailyRollupUpsertBulk) AddDegradedCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1180. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1181. s.AddDegradedCount(v)
  1182. })
  1183. }
  1184. // UpdateDegradedCount sets the "degraded_count" field to the value that was provided on create.
  1185. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateDegradedCount() *ChannelMonitorDailyRollupUpsertBulk {
  1186. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1187. s.UpdateDegradedCount()
  1188. })
  1189. }
  1190. // SetFailedCount sets the "failed_count" field.
  1191. func (u *ChannelMonitorDailyRollupUpsertBulk) SetFailedCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1192. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1193. s.SetFailedCount(v)
  1194. })
  1195. }
  1196. // AddFailedCount adds v to the "failed_count" field.
  1197. func (u *ChannelMonitorDailyRollupUpsertBulk) AddFailedCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1198. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1199. s.AddFailedCount(v)
  1200. })
  1201. }
  1202. // UpdateFailedCount sets the "failed_count" field to the value that was provided on create.
  1203. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateFailedCount() *ChannelMonitorDailyRollupUpsertBulk {
  1204. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1205. s.UpdateFailedCount()
  1206. })
  1207. }
  1208. // SetErrorCount sets the "error_count" field.
  1209. func (u *ChannelMonitorDailyRollupUpsertBulk) SetErrorCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1210. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1211. s.SetErrorCount(v)
  1212. })
  1213. }
  1214. // AddErrorCount adds v to the "error_count" field.
  1215. func (u *ChannelMonitorDailyRollupUpsertBulk) AddErrorCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1216. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1217. s.AddErrorCount(v)
  1218. })
  1219. }
  1220. // UpdateErrorCount sets the "error_count" field to the value that was provided on create.
  1221. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateErrorCount() *ChannelMonitorDailyRollupUpsertBulk {
  1222. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1223. s.UpdateErrorCount()
  1224. })
  1225. }
  1226. // SetSumLatencyMs sets the "sum_latency_ms" field.
  1227. func (u *ChannelMonitorDailyRollupUpsertBulk) SetSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertBulk {
  1228. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1229. s.SetSumLatencyMs(v)
  1230. })
  1231. }
  1232. // AddSumLatencyMs adds v to the "sum_latency_ms" field.
  1233. func (u *ChannelMonitorDailyRollupUpsertBulk) AddSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertBulk {
  1234. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1235. s.AddSumLatencyMs(v)
  1236. })
  1237. }
  1238. // UpdateSumLatencyMs sets the "sum_latency_ms" field to the value that was provided on create.
  1239. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateSumLatencyMs() *ChannelMonitorDailyRollupUpsertBulk {
  1240. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1241. s.UpdateSumLatencyMs()
  1242. })
  1243. }
  1244. // SetCountLatency sets the "count_latency" field.
  1245. func (u *ChannelMonitorDailyRollupUpsertBulk) SetCountLatency(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1246. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1247. s.SetCountLatency(v)
  1248. })
  1249. }
  1250. // AddCountLatency adds v to the "count_latency" field.
  1251. func (u *ChannelMonitorDailyRollupUpsertBulk) AddCountLatency(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1252. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1253. s.AddCountLatency(v)
  1254. })
  1255. }
  1256. // UpdateCountLatency sets the "count_latency" field to the value that was provided on create.
  1257. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateCountLatency() *ChannelMonitorDailyRollupUpsertBulk {
  1258. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1259. s.UpdateCountLatency()
  1260. })
  1261. }
  1262. // SetSumPingLatencyMs sets the "sum_ping_latency_ms" field.
  1263. func (u *ChannelMonitorDailyRollupUpsertBulk) SetSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertBulk {
  1264. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1265. s.SetSumPingLatencyMs(v)
  1266. })
  1267. }
  1268. // AddSumPingLatencyMs adds v to the "sum_ping_latency_ms" field.
  1269. func (u *ChannelMonitorDailyRollupUpsertBulk) AddSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertBulk {
  1270. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1271. s.AddSumPingLatencyMs(v)
  1272. })
  1273. }
  1274. // UpdateSumPingLatencyMs sets the "sum_ping_latency_ms" field to the value that was provided on create.
  1275. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateSumPingLatencyMs() *ChannelMonitorDailyRollupUpsertBulk {
  1276. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1277. s.UpdateSumPingLatencyMs()
  1278. })
  1279. }
  1280. // SetCountPingLatency sets the "count_ping_latency" field.
  1281. func (u *ChannelMonitorDailyRollupUpsertBulk) SetCountPingLatency(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1282. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1283. s.SetCountPingLatency(v)
  1284. })
  1285. }
  1286. // AddCountPingLatency adds v to the "count_ping_latency" field.
  1287. func (u *ChannelMonitorDailyRollupUpsertBulk) AddCountPingLatency(v int) *ChannelMonitorDailyRollupUpsertBulk {
  1288. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1289. s.AddCountPingLatency(v)
  1290. })
  1291. }
  1292. // UpdateCountPingLatency sets the "count_ping_latency" field to the value that was provided on create.
  1293. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateCountPingLatency() *ChannelMonitorDailyRollupUpsertBulk {
  1294. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1295. s.UpdateCountPingLatency()
  1296. })
  1297. }
  1298. // SetComputedAt sets the "computed_at" field.
  1299. func (u *ChannelMonitorDailyRollupUpsertBulk) SetComputedAt(v time.Time) *ChannelMonitorDailyRollupUpsertBulk {
  1300. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1301. s.SetComputedAt(v)
  1302. })
  1303. }
  1304. // UpdateComputedAt sets the "computed_at" field to the value that was provided on create.
  1305. func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateComputedAt() *ChannelMonitorDailyRollupUpsertBulk {
  1306. return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
  1307. s.UpdateComputedAt()
  1308. })
  1309. }
  1310. // Exec executes the query.
  1311. func (u *ChannelMonitorDailyRollupUpsertBulk) Exec(ctx context.Context) error {
  1312. if u.create.err != nil {
  1313. return u.create.err
  1314. }
  1315. for i, b := range u.create.builders {
  1316. if len(b.conflict) != 0 {
  1317. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ChannelMonitorDailyRollupCreateBulk instead", i)
  1318. }
  1319. }
  1320. if len(u.create.conflict) == 0 {
  1321. return errors.New("ent: missing options for ChannelMonitorDailyRollupCreateBulk.OnConflict")
  1322. }
  1323. return u.create.Exec(ctx)
  1324. }
  1325. // ExecX is like Exec, but panics if an error occurs.
  1326. func (u *ChannelMonitorDailyRollupUpsertBulk) ExecX(ctx context.Context) {
  1327. if err := u.create.Exec(ctx); err != nil {
  1328. panic(err)
  1329. }
  1330. }