// 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) } }