| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- "github.com/Wei-Shaw/sub2api/ent/channelmonitor"
- "github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
- )
- // ChannelMonitorDailyRollupCreate is the builder for creating a ChannelMonitorDailyRollup entity.
- type ChannelMonitorDailyRollupCreate struct {
- config
- mutation *ChannelMonitorDailyRollupMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetMonitorID sets the "monitor_id" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetMonitorID(v int64) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetMonitorID(v)
- return _c
- }
- // SetModel sets the "model" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetModel(v string) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetModel(v)
- return _c
- }
- // SetBucketDate sets the "bucket_date" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetBucketDate(v time.Time) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetBucketDate(v)
- return _c
- }
- // SetTotalChecks sets the "total_checks" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetTotalChecks(v int) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetTotalChecks(v)
- return _c
- }
- // SetNillableTotalChecks sets the "total_checks" field if the given value is not nil.
- func (_c *ChannelMonitorDailyRollupCreate) SetNillableTotalChecks(v *int) *ChannelMonitorDailyRollupCreate {
- if v != nil {
- _c.SetTotalChecks(*v)
- }
- return _c
- }
- // SetOkCount sets the "ok_count" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetOkCount(v int) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetOkCount(v)
- return _c
- }
- // SetNillableOkCount sets the "ok_count" field if the given value is not nil.
- func (_c *ChannelMonitorDailyRollupCreate) SetNillableOkCount(v *int) *ChannelMonitorDailyRollupCreate {
- if v != nil {
- _c.SetOkCount(*v)
- }
- return _c
- }
- // SetOperationalCount sets the "operational_count" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetOperationalCount(v int) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetOperationalCount(v)
- return _c
- }
- // SetNillableOperationalCount sets the "operational_count" field if the given value is not nil.
- func (_c *ChannelMonitorDailyRollupCreate) SetNillableOperationalCount(v *int) *ChannelMonitorDailyRollupCreate {
- if v != nil {
- _c.SetOperationalCount(*v)
- }
- return _c
- }
- // SetDegradedCount sets the "degraded_count" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetDegradedCount(v int) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetDegradedCount(v)
- return _c
- }
- // SetNillableDegradedCount sets the "degraded_count" field if the given value is not nil.
- func (_c *ChannelMonitorDailyRollupCreate) SetNillableDegradedCount(v *int) *ChannelMonitorDailyRollupCreate {
- if v != nil {
- _c.SetDegradedCount(*v)
- }
- return _c
- }
- // SetFailedCount sets the "failed_count" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetFailedCount(v int) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetFailedCount(v)
- return _c
- }
- // SetNillableFailedCount sets the "failed_count" field if the given value is not nil.
- func (_c *ChannelMonitorDailyRollupCreate) SetNillableFailedCount(v *int) *ChannelMonitorDailyRollupCreate {
- if v != nil {
- _c.SetFailedCount(*v)
- }
- return _c
- }
- // SetErrorCount sets the "error_count" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetErrorCount(v int) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetErrorCount(v)
- return _c
- }
- // SetNillableErrorCount sets the "error_count" field if the given value is not nil.
- func (_c *ChannelMonitorDailyRollupCreate) SetNillableErrorCount(v *int) *ChannelMonitorDailyRollupCreate {
- if v != nil {
- _c.SetErrorCount(*v)
- }
- return _c
- }
- // SetSumLatencyMs sets the "sum_latency_ms" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetSumLatencyMs(v int64) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetSumLatencyMs(v)
- return _c
- }
- // SetNillableSumLatencyMs sets the "sum_latency_ms" field if the given value is not nil.
- func (_c *ChannelMonitorDailyRollupCreate) SetNillableSumLatencyMs(v *int64) *ChannelMonitorDailyRollupCreate {
- if v != nil {
- _c.SetSumLatencyMs(*v)
- }
- return _c
- }
- // SetCountLatency sets the "count_latency" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetCountLatency(v int) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetCountLatency(v)
- return _c
- }
- // SetNillableCountLatency sets the "count_latency" field if the given value is not nil.
- func (_c *ChannelMonitorDailyRollupCreate) SetNillableCountLatency(v *int) *ChannelMonitorDailyRollupCreate {
- if v != nil {
- _c.SetCountLatency(*v)
- }
- return _c
- }
- // SetSumPingLatencyMs sets the "sum_ping_latency_ms" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetSumPingLatencyMs(v)
- return _c
- }
- // SetNillableSumPingLatencyMs sets the "sum_ping_latency_ms" field if the given value is not nil.
- func (_c *ChannelMonitorDailyRollupCreate) SetNillableSumPingLatencyMs(v *int64) *ChannelMonitorDailyRollupCreate {
- if v != nil {
- _c.SetSumPingLatencyMs(*v)
- }
- return _c
- }
- // SetCountPingLatency sets the "count_ping_latency" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetCountPingLatency(v int) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetCountPingLatency(v)
- return _c
- }
- // SetNillableCountPingLatency sets the "count_ping_latency" field if the given value is not nil.
- func (_c *ChannelMonitorDailyRollupCreate) SetNillableCountPingLatency(v *int) *ChannelMonitorDailyRollupCreate {
- if v != nil {
- _c.SetCountPingLatency(*v)
- }
- return _c
- }
- // SetComputedAt sets the "computed_at" field.
- func (_c *ChannelMonitorDailyRollupCreate) SetComputedAt(v time.Time) *ChannelMonitorDailyRollupCreate {
- _c.mutation.SetComputedAt(v)
- return _c
- }
- // SetNillableComputedAt sets the "computed_at" field if the given value is not nil.
- func (_c *ChannelMonitorDailyRollupCreate) SetNillableComputedAt(v *time.Time) *ChannelMonitorDailyRollupCreate {
- if v != nil {
- _c.SetComputedAt(*v)
- }
- return _c
- }
- // SetMonitor sets the "monitor" edge to the ChannelMonitor entity.
- func (_c *ChannelMonitorDailyRollupCreate) SetMonitor(v *ChannelMonitor) *ChannelMonitorDailyRollupCreate {
- return _c.SetMonitorID(v.ID)
- }
- // Mutation returns the ChannelMonitorDailyRollupMutation object of the builder.
- func (_c *ChannelMonitorDailyRollupCreate) Mutation() *ChannelMonitorDailyRollupMutation {
- return _c.mutation
- }
- // Save creates the ChannelMonitorDailyRollup in the database.
- func (_c *ChannelMonitorDailyRollupCreate) Save(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
- _c.defaults()
- return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (_c *ChannelMonitorDailyRollupCreate) SaveX(ctx context.Context) *ChannelMonitorDailyRollup {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *ChannelMonitorDailyRollupCreate) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *ChannelMonitorDailyRollupCreate) ExecX(ctx context.Context) {
- if err := _c.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (_c *ChannelMonitorDailyRollupCreate) defaults() {
- if _, ok := _c.mutation.TotalChecks(); !ok {
- v := channelmonitordailyrollup.DefaultTotalChecks
- _c.mutation.SetTotalChecks(v)
- }
- if _, ok := _c.mutation.OkCount(); !ok {
- v := channelmonitordailyrollup.DefaultOkCount
- _c.mutation.SetOkCount(v)
- }
- if _, ok := _c.mutation.OperationalCount(); !ok {
- v := channelmonitordailyrollup.DefaultOperationalCount
- _c.mutation.SetOperationalCount(v)
- }
- if _, ok := _c.mutation.DegradedCount(); !ok {
- v := channelmonitordailyrollup.DefaultDegradedCount
- _c.mutation.SetDegradedCount(v)
- }
- if _, ok := _c.mutation.FailedCount(); !ok {
- v := channelmonitordailyrollup.DefaultFailedCount
- _c.mutation.SetFailedCount(v)
- }
- if _, ok := _c.mutation.ErrorCount(); !ok {
- v := channelmonitordailyrollup.DefaultErrorCount
- _c.mutation.SetErrorCount(v)
- }
- if _, ok := _c.mutation.SumLatencyMs(); !ok {
- v := channelmonitordailyrollup.DefaultSumLatencyMs
- _c.mutation.SetSumLatencyMs(v)
- }
- if _, ok := _c.mutation.CountLatency(); !ok {
- v := channelmonitordailyrollup.DefaultCountLatency
- _c.mutation.SetCountLatency(v)
- }
- if _, ok := _c.mutation.SumPingLatencyMs(); !ok {
- v := channelmonitordailyrollup.DefaultSumPingLatencyMs
- _c.mutation.SetSumPingLatencyMs(v)
- }
- if _, ok := _c.mutation.CountPingLatency(); !ok {
- v := channelmonitordailyrollup.DefaultCountPingLatency
- _c.mutation.SetCountPingLatency(v)
- }
- if _, ok := _c.mutation.ComputedAt(); !ok {
- v := channelmonitordailyrollup.DefaultComputedAt()
- _c.mutation.SetComputedAt(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (_c *ChannelMonitorDailyRollupCreate) check() error {
- if _, ok := _c.mutation.MonitorID(); !ok {
- return &ValidationError{Name: "monitor_id", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.monitor_id"`)}
- }
- if _, ok := _c.mutation.Model(); !ok {
- return &ValidationError{Name: "model", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.model"`)}
- }
- if v, ok := _c.mutation.Model(); ok {
- if err := channelmonitordailyrollup.ModelValidator(v); err != nil {
- return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitorDailyRollup.model": %w`, err)}
- }
- }
- if _, ok := _c.mutation.BucketDate(); !ok {
- return &ValidationError{Name: "bucket_date", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.bucket_date"`)}
- }
- if _, ok := _c.mutation.TotalChecks(); !ok {
- return &ValidationError{Name: "total_checks", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.total_checks"`)}
- }
- if _, ok := _c.mutation.OkCount(); !ok {
- return &ValidationError{Name: "ok_count", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.ok_count"`)}
- }
- if _, ok := _c.mutation.OperationalCount(); !ok {
- return &ValidationError{Name: "operational_count", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.operational_count"`)}
- }
- if _, ok := _c.mutation.DegradedCount(); !ok {
- return &ValidationError{Name: "degraded_count", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.degraded_count"`)}
- }
- if _, ok := _c.mutation.FailedCount(); !ok {
- return &ValidationError{Name: "failed_count", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.failed_count"`)}
- }
- if _, ok := _c.mutation.ErrorCount(); !ok {
- return &ValidationError{Name: "error_count", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.error_count"`)}
- }
- if _, ok := _c.mutation.SumLatencyMs(); !ok {
- return &ValidationError{Name: "sum_latency_ms", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.sum_latency_ms"`)}
- }
- if _, ok := _c.mutation.CountLatency(); !ok {
- return &ValidationError{Name: "count_latency", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.count_latency"`)}
- }
- if _, ok := _c.mutation.SumPingLatencyMs(); !ok {
- return &ValidationError{Name: "sum_ping_latency_ms", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.sum_ping_latency_ms"`)}
- }
- if _, ok := _c.mutation.CountPingLatency(); !ok {
- return &ValidationError{Name: "count_ping_latency", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.count_ping_latency"`)}
- }
- if _, ok := _c.mutation.ComputedAt(); !ok {
- return &ValidationError{Name: "computed_at", err: errors.New(`ent: missing required field "ChannelMonitorDailyRollup.computed_at"`)}
- }
- if len(_c.mutation.MonitorIDs()) == 0 {
- return &ValidationError{Name: "monitor", err: errors.New(`ent: missing required edge "ChannelMonitorDailyRollup.monitor"`)}
- }
- return nil
- }
- func (_c *ChannelMonitorDailyRollupCreate) sqlSave(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
- if err := _c.check(); err != nil {
- return nil, err
- }
- _node, _spec := _c.createSpec()
- if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- id := _spec.ID.Value.(int64)
- _node.ID = int64(id)
- _c.mutation.id = &_node.ID
- _c.mutation.done = true
- return _node, nil
- }
- func (_c *ChannelMonitorDailyRollupCreate) createSpec() (*ChannelMonitorDailyRollup, *sqlgraph.CreateSpec) {
- var (
- _node = &ChannelMonitorDailyRollup{config: _c.config}
- _spec = sqlgraph.NewCreateSpec(channelmonitordailyrollup.Table, sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64))
- )
- _spec.OnConflict = _c.conflict
- if value, ok := _c.mutation.Model(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldModel, field.TypeString, value)
- _node.Model = value
- }
- if value, ok := _c.mutation.BucketDate(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldBucketDate, field.TypeTime, value)
- _node.BucketDate = value
- }
- if value, ok := _c.mutation.TotalChecks(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldTotalChecks, field.TypeInt, value)
- _node.TotalChecks = value
- }
- if value, ok := _c.mutation.OkCount(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldOkCount, field.TypeInt, value)
- _node.OkCount = value
- }
- if value, ok := _c.mutation.OperationalCount(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldOperationalCount, field.TypeInt, value)
- _node.OperationalCount = value
- }
- if value, ok := _c.mutation.DegradedCount(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldDegradedCount, field.TypeInt, value)
- _node.DegradedCount = value
- }
- if value, ok := _c.mutation.FailedCount(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldFailedCount, field.TypeInt, value)
- _node.FailedCount = value
- }
- if value, ok := _c.mutation.ErrorCount(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldErrorCount, field.TypeInt, value)
- _node.ErrorCount = value
- }
- if value, ok := _c.mutation.SumLatencyMs(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldSumLatencyMs, field.TypeInt64, value)
- _node.SumLatencyMs = value
- }
- if value, ok := _c.mutation.CountLatency(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldCountLatency, field.TypeInt, value)
- _node.CountLatency = value
- }
- if value, ok := _c.mutation.SumPingLatencyMs(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldSumPingLatencyMs, field.TypeInt64, value)
- _node.SumPingLatencyMs = value
- }
- if value, ok := _c.mutation.CountPingLatency(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldCountPingLatency, field.TypeInt, value)
- _node.CountPingLatency = value
- }
- if value, ok := _c.mutation.ComputedAt(); ok {
- _spec.SetField(channelmonitordailyrollup.FieldComputedAt, field.TypeTime, value)
- _node.ComputedAt = value
- }
- if nodes := _c.mutation.MonitorIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: channelmonitordailyrollup.MonitorTable,
- Columns: []string{channelmonitordailyrollup.MonitorColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(channelmonitor.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.MonitorID = nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.ChannelMonitorDailyRollup.Create().
- // SetMonitorID(v).
- // OnConflict(
- // // Update the row with the new values
- // // the was proposed for insertion.
- // sql.ResolveWithNewValues(),
- // ).
- // // Override some of the fields with custom
- // // update values.
- // Update(func(u *ent.ChannelMonitorDailyRollupUpsert) {
- // SetMonitorID(v+v).
- // }).
- // Exec(ctx)
- func (_c *ChannelMonitorDailyRollupCreate) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorDailyRollupUpsertOne {
- _c.conflict = opts
- return &ChannelMonitorDailyRollupUpsertOne{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.ChannelMonitorDailyRollup.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *ChannelMonitorDailyRollupCreate) OnConflictColumns(columns ...string) *ChannelMonitorDailyRollupUpsertOne {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &ChannelMonitorDailyRollupUpsertOne{
- create: _c,
- }
- }
- type (
- // ChannelMonitorDailyRollupUpsertOne is the builder for "upsert"-ing
- // one ChannelMonitorDailyRollup node.
- ChannelMonitorDailyRollupUpsertOne struct {
- create *ChannelMonitorDailyRollupCreate
- }
- // ChannelMonitorDailyRollupUpsert is the "OnConflict" setter.
- ChannelMonitorDailyRollupUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetMonitorID sets the "monitor_id" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldMonitorID, v)
- return u
- }
- // UpdateMonitorID sets the "monitor_id" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateMonitorID() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldMonitorID)
- return u
- }
- // SetModel sets the "model" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetModel(v string) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldModel, v)
- return u
- }
- // UpdateModel sets the "model" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateModel() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldModel)
- return u
- }
- // SetBucketDate sets the "bucket_date" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetBucketDate(v time.Time) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldBucketDate, v)
- return u
- }
- // UpdateBucketDate sets the "bucket_date" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateBucketDate() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldBucketDate)
- return u
- }
- // SetTotalChecks sets the "total_checks" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetTotalChecks(v int) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldTotalChecks, v)
- return u
- }
- // UpdateTotalChecks sets the "total_checks" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateTotalChecks() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldTotalChecks)
- return u
- }
- // AddTotalChecks adds v to the "total_checks" field.
- func (u *ChannelMonitorDailyRollupUpsert) AddTotalChecks(v int) *ChannelMonitorDailyRollupUpsert {
- u.Add(channelmonitordailyrollup.FieldTotalChecks, v)
- return u
- }
- // SetOkCount sets the "ok_count" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetOkCount(v int) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldOkCount, v)
- return u
- }
- // UpdateOkCount sets the "ok_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateOkCount() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldOkCount)
- return u
- }
- // AddOkCount adds v to the "ok_count" field.
- func (u *ChannelMonitorDailyRollupUpsert) AddOkCount(v int) *ChannelMonitorDailyRollupUpsert {
- u.Add(channelmonitordailyrollup.FieldOkCount, v)
- return u
- }
- // SetOperationalCount sets the "operational_count" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetOperationalCount(v int) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldOperationalCount, v)
- return u
- }
- // UpdateOperationalCount sets the "operational_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateOperationalCount() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldOperationalCount)
- return u
- }
- // AddOperationalCount adds v to the "operational_count" field.
- func (u *ChannelMonitorDailyRollupUpsert) AddOperationalCount(v int) *ChannelMonitorDailyRollupUpsert {
- u.Add(channelmonitordailyrollup.FieldOperationalCount, v)
- return u
- }
- // SetDegradedCount sets the "degraded_count" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetDegradedCount(v int) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldDegradedCount, v)
- return u
- }
- // UpdateDegradedCount sets the "degraded_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateDegradedCount() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldDegradedCount)
- return u
- }
- // AddDegradedCount adds v to the "degraded_count" field.
- func (u *ChannelMonitorDailyRollupUpsert) AddDegradedCount(v int) *ChannelMonitorDailyRollupUpsert {
- u.Add(channelmonitordailyrollup.FieldDegradedCount, v)
- return u
- }
- // SetFailedCount sets the "failed_count" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetFailedCount(v int) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldFailedCount, v)
- return u
- }
- // UpdateFailedCount sets the "failed_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateFailedCount() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldFailedCount)
- return u
- }
- // AddFailedCount adds v to the "failed_count" field.
- func (u *ChannelMonitorDailyRollupUpsert) AddFailedCount(v int) *ChannelMonitorDailyRollupUpsert {
- u.Add(channelmonitordailyrollup.FieldFailedCount, v)
- return u
- }
- // SetErrorCount sets the "error_count" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetErrorCount(v int) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldErrorCount, v)
- return u
- }
- // UpdateErrorCount sets the "error_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateErrorCount() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldErrorCount)
- return u
- }
- // AddErrorCount adds v to the "error_count" field.
- func (u *ChannelMonitorDailyRollupUpsert) AddErrorCount(v int) *ChannelMonitorDailyRollupUpsert {
- u.Add(channelmonitordailyrollup.FieldErrorCount, v)
- return u
- }
- // SetSumLatencyMs sets the "sum_latency_ms" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldSumLatencyMs, v)
- return u
- }
- // UpdateSumLatencyMs sets the "sum_latency_ms" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateSumLatencyMs() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldSumLatencyMs)
- return u
- }
- // AddSumLatencyMs adds v to the "sum_latency_ms" field.
- func (u *ChannelMonitorDailyRollupUpsert) AddSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpsert {
- u.Add(channelmonitordailyrollup.FieldSumLatencyMs, v)
- return u
- }
- // SetCountLatency sets the "count_latency" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetCountLatency(v int) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldCountLatency, v)
- return u
- }
- // UpdateCountLatency sets the "count_latency" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateCountLatency() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldCountLatency)
- return u
- }
- // AddCountLatency adds v to the "count_latency" field.
- func (u *ChannelMonitorDailyRollupUpsert) AddCountLatency(v int) *ChannelMonitorDailyRollupUpsert {
- u.Add(channelmonitordailyrollup.FieldCountLatency, v)
- return u
- }
- // SetSumPingLatencyMs sets the "sum_ping_latency_ms" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldSumPingLatencyMs, v)
- return u
- }
- // UpdateSumPingLatencyMs sets the "sum_ping_latency_ms" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateSumPingLatencyMs() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldSumPingLatencyMs)
- return u
- }
- // AddSumPingLatencyMs adds v to the "sum_ping_latency_ms" field.
- func (u *ChannelMonitorDailyRollupUpsert) AddSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpsert {
- u.Add(channelmonitordailyrollup.FieldSumPingLatencyMs, v)
- return u
- }
- // SetCountPingLatency sets the "count_ping_latency" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetCountPingLatency(v int) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldCountPingLatency, v)
- return u
- }
- // UpdateCountPingLatency sets the "count_ping_latency" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateCountPingLatency() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldCountPingLatency)
- return u
- }
- // AddCountPingLatency adds v to the "count_ping_latency" field.
- func (u *ChannelMonitorDailyRollupUpsert) AddCountPingLatency(v int) *ChannelMonitorDailyRollupUpsert {
- u.Add(channelmonitordailyrollup.FieldCountPingLatency, v)
- return u
- }
- // SetComputedAt sets the "computed_at" field.
- func (u *ChannelMonitorDailyRollupUpsert) SetComputedAt(v time.Time) *ChannelMonitorDailyRollupUpsert {
- u.Set(channelmonitordailyrollup.FieldComputedAt, v)
- return u
- }
- // UpdateComputedAt sets the "computed_at" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsert) UpdateComputedAt() *ChannelMonitorDailyRollupUpsert {
- u.SetExcluded(channelmonitordailyrollup.FieldComputedAt)
- return u
- }
- // UpdateNewValues updates the mutable fields using the new values that were set on create.
- // Using this option is equivalent to using:
- //
- // client.ChannelMonitorDailyRollup.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateNewValues() *ChannelMonitorDailyRollupUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.ChannelMonitorDailyRollup.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *ChannelMonitorDailyRollupUpsertOne) Ignore() *ChannelMonitorDailyRollupUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
- return u
- }
- // DoNothing configures the conflict_action to `DO NOTHING`.
- // Supported only by SQLite and PostgreSQL.
- func (u *ChannelMonitorDailyRollupUpsertOne) DoNothing() *ChannelMonitorDailyRollupUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the ChannelMonitorDailyRollupCreate.OnConflict
- // documentation for more info.
- func (u *ChannelMonitorDailyRollupUpsertOne) Update(set func(*ChannelMonitorDailyRollupUpsert)) *ChannelMonitorDailyRollupUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&ChannelMonitorDailyRollupUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetMonitorID sets the "monitor_id" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetMonitorID(v)
- })
- }
- // UpdateMonitorID sets the "monitor_id" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateMonitorID() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateMonitorID()
- })
- }
- // SetModel sets the "model" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetModel(v string) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetModel(v)
- })
- }
- // UpdateModel sets the "model" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateModel() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateModel()
- })
- }
- // SetBucketDate sets the "bucket_date" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetBucketDate(v time.Time) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetBucketDate(v)
- })
- }
- // UpdateBucketDate sets the "bucket_date" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateBucketDate() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateBucketDate()
- })
- }
- // SetTotalChecks sets the "total_checks" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetTotalChecks(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetTotalChecks(v)
- })
- }
- // AddTotalChecks adds v to the "total_checks" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) AddTotalChecks(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddTotalChecks(v)
- })
- }
- // UpdateTotalChecks sets the "total_checks" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateTotalChecks() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateTotalChecks()
- })
- }
- // SetOkCount sets the "ok_count" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetOkCount(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetOkCount(v)
- })
- }
- // AddOkCount adds v to the "ok_count" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) AddOkCount(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddOkCount(v)
- })
- }
- // UpdateOkCount sets the "ok_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateOkCount() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateOkCount()
- })
- }
- // SetOperationalCount sets the "operational_count" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetOperationalCount(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetOperationalCount(v)
- })
- }
- // AddOperationalCount adds v to the "operational_count" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) AddOperationalCount(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddOperationalCount(v)
- })
- }
- // UpdateOperationalCount sets the "operational_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateOperationalCount() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateOperationalCount()
- })
- }
- // SetDegradedCount sets the "degraded_count" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetDegradedCount(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetDegradedCount(v)
- })
- }
- // AddDegradedCount adds v to the "degraded_count" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) AddDegradedCount(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddDegradedCount(v)
- })
- }
- // UpdateDegradedCount sets the "degraded_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateDegradedCount() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateDegradedCount()
- })
- }
- // SetFailedCount sets the "failed_count" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetFailedCount(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetFailedCount(v)
- })
- }
- // AddFailedCount adds v to the "failed_count" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) AddFailedCount(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddFailedCount(v)
- })
- }
- // UpdateFailedCount sets the "failed_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateFailedCount() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateFailedCount()
- })
- }
- // SetErrorCount sets the "error_count" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetErrorCount(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetErrorCount(v)
- })
- }
- // AddErrorCount adds v to the "error_count" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) AddErrorCount(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddErrorCount(v)
- })
- }
- // UpdateErrorCount sets the "error_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateErrorCount() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateErrorCount()
- })
- }
- // SetSumLatencyMs sets the "sum_latency_ms" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetSumLatencyMs(v)
- })
- }
- // AddSumLatencyMs adds v to the "sum_latency_ms" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) AddSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddSumLatencyMs(v)
- })
- }
- // UpdateSumLatencyMs sets the "sum_latency_ms" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateSumLatencyMs() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateSumLatencyMs()
- })
- }
- // SetCountLatency sets the "count_latency" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetCountLatency(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetCountLatency(v)
- })
- }
- // AddCountLatency adds v to the "count_latency" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) AddCountLatency(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddCountLatency(v)
- })
- }
- // UpdateCountLatency sets the "count_latency" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateCountLatency() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateCountLatency()
- })
- }
- // SetSumPingLatencyMs sets the "sum_ping_latency_ms" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetSumPingLatencyMs(v)
- })
- }
- // AddSumPingLatencyMs adds v to the "sum_ping_latency_ms" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) AddSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddSumPingLatencyMs(v)
- })
- }
- // UpdateSumPingLatencyMs sets the "sum_ping_latency_ms" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateSumPingLatencyMs() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateSumPingLatencyMs()
- })
- }
- // SetCountPingLatency sets the "count_ping_latency" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetCountPingLatency(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetCountPingLatency(v)
- })
- }
- // AddCountPingLatency adds v to the "count_ping_latency" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) AddCountPingLatency(v int) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddCountPingLatency(v)
- })
- }
- // UpdateCountPingLatency sets the "count_ping_latency" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateCountPingLatency() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateCountPingLatency()
- })
- }
- // SetComputedAt sets the "computed_at" field.
- func (u *ChannelMonitorDailyRollupUpsertOne) SetComputedAt(v time.Time) *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetComputedAt(v)
- })
- }
- // UpdateComputedAt sets the "computed_at" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertOne) UpdateComputedAt() *ChannelMonitorDailyRollupUpsertOne {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateComputedAt()
- })
- }
- // Exec executes the query.
- func (u *ChannelMonitorDailyRollupUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for ChannelMonitorDailyRollupCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *ChannelMonitorDailyRollupUpsertOne) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // Exec executes the UPSERT query and returns the inserted/updated ID.
- func (u *ChannelMonitorDailyRollupUpsertOne) ID(ctx context.Context) (id int64, err error) {
- node, err := u.create.Save(ctx)
- if err != nil {
- return id, err
- }
- return node.ID, nil
- }
- // IDX is like ID, but panics if an error occurs.
- func (u *ChannelMonitorDailyRollupUpsertOne) IDX(ctx context.Context) int64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // ChannelMonitorDailyRollupCreateBulk is the builder for creating many ChannelMonitorDailyRollup entities in bulk.
- type ChannelMonitorDailyRollupCreateBulk struct {
- config
- err error
- builders []*ChannelMonitorDailyRollupCreate
- conflict []sql.ConflictOption
- }
- // Save creates the ChannelMonitorDailyRollup entities in the database.
- func (_c *ChannelMonitorDailyRollupCreateBulk) Save(ctx context.Context) ([]*ChannelMonitorDailyRollup, error) {
- if _c.err != nil {
- return nil, _c.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
- nodes := make([]*ChannelMonitorDailyRollup, len(_c.builders))
- mutators := make([]Mutator, len(_c.builders))
- for i := range _c.builders {
- func(i int, root context.Context) {
- builder := _c.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*ChannelMonitorDailyRollupMutation)
- if !ok {
- return nil, fmt.Errorf("unexpected mutation type %T", m)
- }
- if err := builder.check(); err != nil {
- return nil, err
- }
- builder.mutation = mutation
- var err error
- nodes[i], specs[i] = builder.createSpec()
- if i < len(mutators)-1 {
- _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = _c.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- }
- }
- if err != nil {
- return nil, err
- }
- mutation.id = &nodes[i].ID
- if specs[i].ID.Value != nil {
- id := specs[i].ID.Value.(int64)
- nodes[i].ID = int64(id)
- }
- mutation.done = true
- return nodes[i], nil
- })
- for i := len(builder.hooks) - 1; i >= 0; i-- {
- mut = builder.hooks[i](mut)
- }
- mutators[i] = mut
- }(i, ctx)
- }
- if len(mutators) > 0 {
- if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (_c *ChannelMonitorDailyRollupCreateBulk) SaveX(ctx context.Context) []*ChannelMonitorDailyRollup {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *ChannelMonitorDailyRollupCreateBulk) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *ChannelMonitorDailyRollupCreateBulk) ExecX(ctx context.Context) {
- if err := _c.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.ChannelMonitorDailyRollup.CreateBulk(builders...).
- // OnConflict(
- // // Update the row with the new values
- // // the was proposed for insertion.
- // sql.ResolveWithNewValues(),
- // ).
- // // Override some of the fields with custom
- // // update values.
- // Update(func(u *ent.ChannelMonitorDailyRollupUpsert) {
- // SetMonitorID(v+v).
- // }).
- // Exec(ctx)
- func (_c *ChannelMonitorDailyRollupCreateBulk) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorDailyRollupUpsertBulk {
- _c.conflict = opts
- return &ChannelMonitorDailyRollupUpsertBulk{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.ChannelMonitorDailyRollup.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *ChannelMonitorDailyRollupCreateBulk) OnConflictColumns(columns ...string) *ChannelMonitorDailyRollupUpsertBulk {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &ChannelMonitorDailyRollupUpsertBulk{
- create: _c,
- }
- }
- // ChannelMonitorDailyRollupUpsertBulk is the builder for "upsert"-ing
- // a bulk of ChannelMonitorDailyRollup nodes.
- type ChannelMonitorDailyRollupUpsertBulk struct {
- create *ChannelMonitorDailyRollupCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.ChannelMonitorDailyRollup.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateNewValues() *ChannelMonitorDailyRollupUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.ChannelMonitorDailyRollup.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *ChannelMonitorDailyRollupUpsertBulk) Ignore() *ChannelMonitorDailyRollupUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
- return u
- }
- // DoNothing configures the conflict_action to `DO NOTHING`.
- // Supported only by SQLite and PostgreSQL.
- func (u *ChannelMonitorDailyRollupUpsertBulk) DoNothing() *ChannelMonitorDailyRollupUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the ChannelMonitorDailyRollupCreateBulk.OnConflict
- // documentation for more info.
- func (u *ChannelMonitorDailyRollupUpsertBulk) Update(set func(*ChannelMonitorDailyRollupUpsert)) *ChannelMonitorDailyRollupUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&ChannelMonitorDailyRollupUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetMonitorID sets the "monitor_id" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetMonitorID(v)
- })
- }
- // UpdateMonitorID sets the "monitor_id" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateMonitorID() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateMonitorID()
- })
- }
- // SetModel sets the "model" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetModel(v string) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetModel(v)
- })
- }
- // UpdateModel sets the "model" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateModel() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateModel()
- })
- }
- // SetBucketDate sets the "bucket_date" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetBucketDate(v time.Time) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetBucketDate(v)
- })
- }
- // UpdateBucketDate sets the "bucket_date" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateBucketDate() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateBucketDate()
- })
- }
- // SetTotalChecks sets the "total_checks" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetTotalChecks(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetTotalChecks(v)
- })
- }
- // AddTotalChecks adds v to the "total_checks" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) AddTotalChecks(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddTotalChecks(v)
- })
- }
- // UpdateTotalChecks sets the "total_checks" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateTotalChecks() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateTotalChecks()
- })
- }
- // SetOkCount sets the "ok_count" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetOkCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetOkCount(v)
- })
- }
- // AddOkCount adds v to the "ok_count" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) AddOkCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddOkCount(v)
- })
- }
- // UpdateOkCount sets the "ok_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateOkCount() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateOkCount()
- })
- }
- // SetOperationalCount sets the "operational_count" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetOperationalCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetOperationalCount(v)
- })
- }
- // AddOperationalCount adds v to the "operational_count" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) AddOperationalCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddOperationalCount(v)
- })
- }
- // UpdateOperationalCount sets the "operational_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateOperationalCount() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateOperationalCount()
- })
- }
- // SetDegradedCount sets the "degraded_count" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetDegradedCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetDegradedCount(v)
- })
- }
- // AddDegradedCount adds v to the "degraded_count" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) AddDegradedCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddDegradedCount(v)
- })
- }
- // UpdateDegradedCount sets the "degraded_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateDegradedCount() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateDegradedCount()
- })
- }
- // SetFailedCount sets the "failed_count" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetFailedCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetFailedCount(v)
- })
- }
- // AddFailedCount adds v to the "failed_count" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) AddFailedCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddFailedCount(v)
- })
- }
- // UpdateFailedCount sets the "failed_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateFailedCount() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateFailedCount()
- })
- }
- // SetErrorCount sets the "error_count" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetErrorCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetErrorCount(v)
- })
- }
- // AddErrorCount adds v to the "error_count" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) AddErrorCount(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddErrorCount(v)
- })
- }
- // UpdateErrorCount sets the "error_count" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateErrorCount() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateErrorCount()
- })
- }
- // SetSumLatencyMs sets the "sum_latency_ms" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetSumLatencyMs(v)
- })
- }
- // AddSumLatencyMs adds v to the "sum_latency_ms" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) AddSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddSumLatencyMs(v)
- })
- }
- // UpdateSumLatencyMs sets the "sum_latency_ms" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateSumLatencyMs() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateSumLatencyMs()
- })
- }
- // SetCountLatency sets the "count_latency" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetCountLatency(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetCountLatency(v)
- })
- }
- // AddCountLatency adds v to the "count_latency" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) AddCountLatency(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddCountLatency(v)
- })
- }
- // UpdateCountLatency sets the "count_latency" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateCountLatency() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateCountLatency()
- })
- }
- // SetSumPingLatencyMs sets the "sum_ping_latency_ms" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetSumPingLatencyMs(v)
- })
- }
- // AddSumPingLatencyMs adds v to the "sum_ping_latency_ms" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) AddSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddSumPingLatencyMs(v)
- })
- }
- // UpdateSumPingLatencyMs sets the "sum_ping_latency_ms" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateSumPingLatencyMs() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateSumPingLatencyMs()
- })
- }
- // SetCountPingLatency sets the "count_ping_latency" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetCountPingLatency(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetCountPingLatency(v)
- })
- }
- // AddCountPingLatency adds v to the "count_ping_latency" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) AddCountPingLatency(v int) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.AddCountPingLatency(v)
- })
- }
- // UpdateCountPingLatency sets the "count_ping_latency" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateCountPingLatency() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateCountPingLatency()
- })
- }
- // SetComputedAt sets the "computed_at" field.
- func (u *ChannelMonitorDailyRollupUpsertBulk) SetComputedAt(v time.Time) *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.SetComputedAt(v)
- })
- }
- // UpdateComputedAt sets the "computed_at" field to the value that was provided on create.
- func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateComputedAt() *ChannelMonitorDailyRollupUpsertBulk {
- return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
- s.UpdateComputedAt()
- })
- }
- // Exec executes the query.
- func (u *ChannelMonitorDailyRollupUpsertBulk) Exec(ctx context.Context) error {
- if u.create.err != nil {
- return u.create.err
- }
- for i, b := range u.create.builders {
- if len(b.conflict) != 0 {
- return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ChannelMonitorDailyRollupCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for ChannelMonitorDailyRollupCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *ChannelMonitorDailyRollupUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|