// 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/AvengeMedia/dankcalendar/core/ent/reminderstate"
)

// ReminderStateCreate is the builder for creating a ReminderState entity.
type ReminderStateCreate struct {
	config
	mutation *ReminderStateMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetCalendarID sets the "calendar_id" field.
func (_c *ReminderStateCreate) SetCalendarID(v string) *ReminderStateCreate {
	_c.mutation.SetCalendarID(v)
	return _c
}

// SetUID sets the "uid" field.
func (_c *ReminderStateCreate) SetUID(v string) *ReminderStateCreate {
	_c.mutation.SetUID(v)
	return _c
}

// SetOccurrenceStart sets the "occurrence_start" field.
func (_c *ReminderStateCreate) SetOccurrenceStart(v time.Time) *ReminderStateCreate {
	_c.mutation.SetOccurrenceStart(v)
	return _c
}

// SetMinutes sets the "minutes" field.
func (_c *ReminderStateCreate) SetMinutes(v int) *ReminderStateCreate {
	_c.mutation.SetMinutes(v)
	return _c
}

// SetFiredAt sets the "fired_at" field.
func (_c *ReminderStateCreate) SetFiredAt(v time.Time) *ReminderStateCreate {
	_c.mutation.SetFiredAt(v)
	return _c
}

// SetNillableFiredAt sets the "fired_at" field if the given value is not nil.
func (_c *ReminderStateCreate) SetNillableFiredAt(v *time.Time) *ReminderStateCreate {
	if v != nil {
		_c.SetFiredAt(*v)
	}
	return _c
}

// SetSnoozedUntil sets the "snoozed_until" field.
func (_c *ReminderStateCreate) SetSnoozedUntil(v time.Time) *ReminderStateCreate {
	_c.mutation.SetSnoozedUntil(v)
	return _c
}

// SetNillableSnoozedUntil sets the "snoozed_until" field if the given value is not nil.
func (_c *ReminderStateCreate) SetNillableSnoozedUntil(v *time.Time) *ReminderStateCreate {
	if v != nil {
		_c.SetSnoozedUntil(*v)
	}
	return _c
}

// Mutation returns the ReminderStateMutation object of the builder.
func (_c *ReminderStateCreate) Mutation() *ReminderStateMutation {
	return _c.mutation
}

// Save creates the ReminderState in the database.
func (_c *ReminderStateCreate) Save(ctx context.Context) (*ReminderState, error) {
	_c.defaults()
	return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}

// SaveX calls Save and panics if Save returns an error.
func (_c *ReminderStateCreate) SaveX(ctx context.Context) *ReminderState {
	v, err := _c.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (_c *ReminderStateCreate) Exec(ctx context.Context) error {
	_, err := _c.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (_c *ReminderStateCreate) 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 *ReminderStateCreate) defaults() {
	if _, ok := _c.mutation.FiredAt(); !ok {
		v := reminderstate.DefaultFiredAt()
		_c.mutation.SetFiredAt(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (_c *ReminderStateCreate) check() error {
	if _, ok := _c.mutation.CalendarID(); !ok {
		return &ValidationError{Name: "calendar_id", err: errors.New(`ent: missing required field "ReminderState.calendar_id"`)}
	}
	if v, ok := _c.mutation.CalendarID(); ok {
		if err := reminderstate.CalendarIDValidator(v); err != nil {
			return &ValidationError{Name: "calendar_id", err: fmt.Errorf(`ent: validator failed for field "ReminderState.calendar_id": %w`, err)}
		}
	}
	if _, ok := _c.mutation.UID(); !ok {
		return &ValidationError{Name: "uid", err: errors.New(`ent: missing required field "ReminderState.uid"`)}
	}
	if v, ok := _c.mutation.UID(); ok {
		if err := reminderstate.UIDValidator(v); err != nil {
			return &ValidationError{Name: "uid", err: fmt.Errorf(`ent: validator failed for field "ReminderState.uid": %w`, err)}
		}
	}
	if _, ok := _c.mutation.OccurrenceStart(); !ok {
		return &ValidationError{Name: "occurrence_start", err: errors.New(`ent: missing required field "ReminderState.occurrence_start"`)}
	}
	if _, ok := _c.mutation.Minutes(); !ok {
		return &ValidationError{Name: "minutes", err: errors.New(`ent: missing required field "ReminderState.minutes"`)}
	}
	if _, ok := _c.mutation.FiredAt(); !ok {
		return &ValidationError{Name: "fired_at", err: errors.New(`ent: missing required field "ReminderState.fired_at"`)}
	}
	return nil
}

func (_c *ReminderStateCreate) sqlSave(ctx context.Context) (*ReminderState, 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 = int(id)
	_c.mutation.id = &_node.ID
	_c.mutation.done = true
	return _node, nil
}

func (_c *ReminderStateCreate) createSpec() (*ReminderState, *sqlgraph.CreateSpec) {
	var (
		_node = &ReminderState{config: _c.config}
		_spec = sqlgraph.NewCreateSpec(reminderstate.Table, sqlgraph.NewFieldSpec(reminderstate.FieldID, field.TypeInt))
	)
	_spec.OnConflict = _c.conflict
	if value, ok := _c.mutation.CalendarID(); ok {
		_spec.SetField(reminderstate.FieldCalendarID, field.TypeString, value)
		_node.CalendarID = value
	}
	if value, ok := _c.mutation.UID(); ok {
		_spec.SetField(reminderstate.FieldUID, field.TypeString, value)
		_node.UID = value
	}
	if value, ok := _c.mutation.OccurrenceStart(); ok {
		_spec.SetField(reminderstate.FieldOccurrenceStart, field.TypeTime, value)
		_node.OccurrenceStart = value
	}
	if value, ok := _c.mutation.Minutes(); ok {
		_spec.SetField(reminderstate.FieldMinutes, field.TypeInt, value)
		_node.Minutes = value
	}
	if value, ok := _c.mutation.FiredAt(); ok {
		_spec.SetField(reminderstate.FieldFiredAt, field.TypeTime, value)
		_node.FiredAt = value
	}
	if value, ok := _c.mutation.SnoozedUntil(); ok {
		_spec.SetField(reminderstate.FieldSnoozedUntil, field.TypeTime, value)
		_node.SnoozedUntil = &value
	}
	return _node, _spec
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.ReminderState.Create().
//		SetCalendarID(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.ReminderStateUpsert) {
//			SetCalendarID(v+v).
//		}).
//		Exec(ctx)
func (_c *ReminderStateCreate) OnConflict(opts ...sql.ConflictOption) *ReminderStateUpsertOne {
	_c.conflict = opts
	return &ReminderStateUpsertOne{
		create: _c,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.ReminderState.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (_c *ReminderStateCreate) OnConflictColumns(columns ...string) *ReminderStateUpsertOne {
	_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
	return &ReminderStateUpsertOne{
		create: _c,
	}
}

type (
	// ReminderStateUpsertOne is the builder for "upsert"-ing
	//  one ReminderState node.
	ReminderStateUpsertOne struct {
		create *ReminderStateCreate
	}

	// ReminderStateUpsert is the "OnConflict" setter.
	ReminderStateUpsert struct {
		*sql.UpdateSet
	}
)

// SetCalendarID sets the "calendar_id" field.
func (u *ReminderStateUpsert) SetCalendarID(v string) *ReminderStateUpsert {
	u.Set(reminderstate.FieldCalendarID, v)
	return u
}

// UpdateCalendarID sets the "calendar_id" field to the value that was provided on create.
func (u *ReminderStateUpsert) UpdateCalendarID() *ReminderStateUpsert {
	u.SetExcluded(reminderstate.FieldCalendarID)
	return u
}

// SetUID sets the "uid" field.
func (u *ReminderStateUpsert) SetUID(v string) *ReminderStateUpsert {
	u.Set(reminderstate.FieldUID, v)
	return u
}

// UpdateUID sets the "uid" field to the value that was provided on create.
func (u *ReminderStateUpsert) UpdateUID() *ReminderStateUpsert {
	u.SetExcluded(reminderstate.FieldUID)
	return u
}

// SetOccurrenceStart sets the "occurrence_start" field.
func (u *ReminderStateUpsert) SetOccurrenceStart(v time.Time) *ReminderStateUpsert {
	u.Set(reminderstate.FieldOccurrenceStart, v)
	return u
}

// UpdateOccurrenceStart sets the "occurrence_start" field to the value that was provided on create.
func (u *ReminderStateUpsert) UpdateOccurrenceStart() *ReminderStateUpsert {
	u.SetExcluded(reminderstate.FieldOccurrenceStart)
	return u
}

// SetMinutes sets the "minutes" field.
func (u *ReminderStateUpsert) SetMinutes(v int) *ReminderStateUpsert {
	u.Set(reminderstate.FieldMinutes, v)
	return u
}

// UpdateMinutes sets the "minutes" field to the value that was provided on create.
func (u *ReminderStateUpsert) UpdateMinutes() *ReminderStateUpsert {
	u.SetExcluded(reminderstate.FieldMinutes)
	return u
}

// AddMinutes adds v to the "minutes" field.
func (u *ReminderStateUpsert) AddMinutes(v int) *ReminderStateUpsert {
	u.Add(reminderstate.FieldMinutes, v)
	return u
}

// SetFiredAt sets the "fired_at" field.
func (u *ReminderStateUpsert) SetFiredAt(v time.Time) *ReminderStateUpsert {
	u.Set(reminderstate.FieldFiredAt, v)
	return u
}

// UpdateFiredAt sets the "fired_at" field to the value that was provided on create.
func (u *ReminderStateUpsert) UpdateFiredAt() *ReminderStateUpsert {
	u.SetExcluded(reminderstate.FieldFiredAt)
	return u
}

// SetSnoozedUntil sets the "snoozed_until" field.
func (u *ReminderStateUpsert) SetSnoozedUntil(v time.Time) *ReminderStateUpsert {
	u.Set(reminderstate.FieldSnoozedUntil, v)
	return u
}

// UpdateSnoozedUntil sets the "snoozed_until" field to the value that was provided on create.
func (u *ReminderStateUpsert) UpdateSnoozedUntil() *ReminderStateUpsert {
	u.SetExcluded(reminderstate.FieldSnoozedUntil)
	return u
}

// ClearSnoozedUntil clears the value of the "snoozed_until" field.
func (u *ReminderStateUpsert) ClearSnoozedUntil() *ReminderStateUpsert {
	u.SetNull(reminderstate.FieldSnoozedUntil)
	return u
}

// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
//	client.ReminderState.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//		).
//		Exec(ctx)
func (u *ReminderStateUpsertOne) UpdateNewValues() *ReminderStateUpsertOne {
	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.ReminderState.Create().
//	    OnConflict(sql.ResolveWithIgnore()).
//	    Exec(ctx)
func (u *ReminderStateUpsertOne) Ignore() *ReminderStateUpsertOne {
	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 *ReminderStateUpsertOne) DoNothing() *ReminderStateUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the ReminderStateCreate.OnConflict
// documentation for more info.
func (u *ReminderStateUpsertOne) Update(set func(*ReminderStateUpsert)) *ReminderStateUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&ReminderStateUpsert{UpdateSet: update})
	}))
	return u
}

// SetCalendarID sets the "calendar_id" field.
func (u *ReminderStateUpsertOne) SetCalendarID(v string) *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.SetCalendarID(v)
	})
}

// UpdateCalendarID sets the "calendar_id" field to the value that was provided on create.
func (u *ReminderStateUpsertOne) UpdateCalendarID() *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.UpdateCalendarID()
	})
}

// SetUID sets the "uid" field.
func (u *ReminderStateUpsertOne) SetUID(v string) *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.SetUID(v)
	})
}

// UpdateUID sets the "uid" field to the value that was provided on create.
func (u *ReminderStateUpsertOne) UpdateUID() *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.UpdateUID()
	})
}

// SetOccurrenceStart sets the "occurrence_start" field.
func (u *ReminderStateUpsertOne) SetOccurrenceStart(v time.Time) *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.SetOccurrenceStart(v)
	})
}

// UpdateOccurrenceStart sets the "occurrence_start" field to the value that was provided on create.
func (u *ReminderStateUpsertOne) UpdateOccurrenceStart() *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.UpdateOccurrenceStart()
	})
}

// SetMinutes sets the "minutes" field.
func (u *ReminderStateUpsertOne) SetMinutes(v int) *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.SetMinutes(v)
	})
}

// AddMinutes adds v to the "minutes" field.
func (u *ReminderStateUpsertOne) AddMinutes(v int) *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.AddMinutes(v)
	})
}

// UpdateMinutes sets the "minutes" field to the value that was provided on create.
func (u *ReminderStateUpsertOne) UpdateMinutes() *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.UpdateMinutes()
	})
}

// SetFiredAt sets the "fired_at" field.
func (u *ReminderStateUpsertOne) SetFiredAt(v time.Time) *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.SetFiredAt(v)
	})
}

// UpdateFiredAt sets the "fired_at" field to the value that was provided on create.
func (u *ReminderStateUpsertOne) UpdateFiredAt() *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.UpdateFiredAt()
	})
}

// SetSnoozedUntil sets the "snoozed_until" field.
func (u *ReminderStateUpsertOne) SetSnoozedUntil(v time.Time) *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.SetSnoozedUntil(v)
	})
}

// UpdateSnoozedUntil sets the "snoozed_until" field to the value that was provided on create.
func (u *ReminderStateUpsertOne) UpdateSnoozedUntil() *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.UpdateSnoozedUntil()
	})
}

// ClearSnoozedUntil clears the value of the "snoozed_until" field.
func (u *ReminderStateUpsertOne) ClearSnoozedUntil() *ReminderStateUpsertOne {
	return u.Update(func(s *ReminderStateUpsert) {
		s.ClearSnoozedUntil()
	})
}

// Exec executes the query.
func (u *ReminderStateUpsertOne) Exec(ctx context.Context) error {
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for ReminderStateCreate.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *ReminderStateUpsertOne) 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 *ReminderStateUpsertOne) ID(ctx context.Context) (id int, 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 *ReminderStateUpsertOne) IDX(ctx context.Context) int {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

// ReminderStateCreateBulk is the builder for creating many ReminderState entities in bulk.
type ReminderStateCreateBulk struct {
	config
	err      error
	builders []*ReminderStateCreate
	conflict []sql.ConflictOption
}

// Save creates the ReminderState entities in the database.
func (_c *ReminderStateCreateBulk) Save(ctx context.Context) ([]*ReminderState, error) {
	if _c.err != nil {
		return nil, _c.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
	nodes := make([]*ReminderState, 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.(*ReminderStateMutation)
				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 = int(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 *ReminderStateCreateBulk) SaveX(ctx context.Context) []*ReminderState {
	v, err := _c.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (_c *ReminderStateCreateBulk) Exec(ctx context.Context) error {
	_, err := _c.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (_c *ReminderStateCreateBulk) 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.ReminderState.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.ReminderStateUpsert) {
//			SetCalendarID(v+v).
//		}).
//		Exec(ctx)
func (_c *ReminderStateCreateBulk) OnConflict(opts ...sql.ConflictOption) *ReminderStateUpsertBulk {
	_c.conflict = opts
	return &ReminderStateUpsertBulk{
		create: _c,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.ReminderState.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (_c *ReminderStateCreateBulk) OnConflictColumns(columns ...string) *ReminderStateUpsertBulk {
	_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
	return &ReminderStateUpsertBulk{
		create: _c,
	}
}

// ReminderStateUpsertBulk is the builder for "upsert"-ing
// a bulk of ReminderState nodes.
type ReminderStateUpsertBulk struct {
	create *ReminderStateCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.ReminderState.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//		).
//		Exec(ctx)
func (u *ReminderStateUpsertBulk) UpdateNewValues() *ReminderStateUpsertBulk {
	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.ReminderState.Create().
//		OnConflict(sql.ResolveWithIgnore()).
//		Exec(ctx)
func (u *ReminderStateUpsertBulk) Ignore() *ReminderStateUpsertBulk {
	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 *ReminderStateUpsertBulk) DoNothing() *ReminderStateUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the ReminderStateCreateBulk.OnConflict
// documentation for more info.
func (u *ReminderStateUpsertBulk) Update(set func(*ReminderStateUpsert)) *ReminderStateUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&ReminderStateUpsert{UpdateSet: update})
	}))
	return u
}

// SetCalendarID sets the "calendar_id" field.
func (u *ReminderStateUpsertBulk) SetCalendarID(v string) *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.SetCalendarID(v)
	})
}

// UpdateCalendarID sets the "calendar_id" field to the value that was provided on create.
func (u *ReminderStateUpsertBulk) UpdateCalendarID() *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.UpdateCalendarID()
	})
}

// SetUID sets the "uid" field.
func (u *ReminderStateUpsertBulk) SetUID(v string) *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.SetUID(v)
	})
}

// UpdateUID sets the "uid" field to the value that was provided on create.
func (u *ReminderStateUpsertBulk) UpdateUID() *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.UpdateUID()
	})
}

// SetOccurrenceStart sets the "occurrence_start" field.
func (u *ReminderStateUpsertBulk) SetOccurrenceStart(v time.Time) *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.SetOccurrenceStart(v)
	})
}

// UpdateOccurrenceStart sets the "occurrence_start" field to the value that was provided on create.
func (u *ReminderStateUpsertBulk) UpdateOccurrenceStart() *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.UpdateOccurrenceStart()
	})
}

// SetMinutes sets the "minutes" field.
func (u *ReminderStateUpsertBulk) SetMinutes(v int) *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.SetMinutes(v)
	})
}

// AddMinutes adds v to the "minutes" field.
func (u *ReminderStateUpsertBulk) AddMinutes(v int) *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.AddMinutes(v)
	})
}

// UpdateMinutes sets the "minutes" field to the value that was provided on create.
func (u *ReminderStateUpsertBulk) UpdateMinutes() *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.UpdateMinutes()
	})
}

// SetFiredAt sets the "fired_at" field.
func (u *ReminderStateUpsertBulk) SetFiredAt(v time.Time) *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.SetFiredAt(v)
	})
}

// UpdateFiredAt sets the "fired_at" field to the value that was provided on create.
func (u *ReminderStateUpsertBulk) UpdateFiredAt() *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.UpdateFiredAt()
	})
}

// SetSnoozedUntil sets the "snoozed_until" field.
func (u *ReminderStateUpsertBulk) SetSnoozedUntil(v time.Time) *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.SetSnoozedUntil(v)
	})
}

// UpdateSnoozedUntil sets the "snoozed_until" field to the value that was provided on create.
func (u *ReminderStateUpsertBulk) UpdateSnoozedUntil() *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.UpdateSnoozedUntil()
	})
}

// ClearSnoozedUntil clears the value of the "snoozed_until" field.
func (u *ReminderStateUpsertBulk) ClearSnoozedUntil() *ReminderStateUpsertBulk {
	return u.Update(func(s *ReminderStateUpsert) {
		s.ClearSnoozedUntil()
	})
}

// Exec executes the query.
func (u *ReminderStateUpsertBulk) 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 ReminderStateCreateBulk instead", i)
		}
	}
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for ReminderStateCreateBulk.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *ReminderStateUpsertBulk) ExecX(ctx context.Context) {
	if err := u.create.Exec(ctx); err != nil {
		panic(err)
	}
}
