// 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/anzhiyu-c/anheyu-app/ent/visitorlog"
)

// VisitorLogCreate is the builder for creating a VisitorLog entity.
type VisitorLogCreate struct {
	config
	mutation *VisitorLogMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetCreatedAt sets the "created_at" field.
func (_c *VisitorLogCreate) SetCreatedAt(v time.Time) *VisitorLogCreate {
	_c.mutation.SetCreatedAt(v)
	return _c
}

// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *VisitorLogCreate) SetNillableCreatedAt(v *time.Time) *VisitorLogCreate {
	if v != nil {
		_c.SetCreatedAt(*v)
	}
	return _c
}

// SetVisitorID sets the "visitor_id" field.
func (_c *VisitorLogCreate) SetVisitorID(v string) *VisitorLogCreate {
	_c.mutation.SetVisitorID(v)
	return _c
}

// SetSessionID sets the "session_id" field.
func (_c *VisitorLogCreate) SetSessionID(v string) *VisitorLogCreate {
	_c.mutation.SetSessionID(v)
	return _c
}

// SetNillableSessionID sets the "session_id" field if the given value is not nil.
func (_c *VisitorLogCreate) SetNillableSessionID(v *string) *VisitorLogCreate {
	if v != nil {
		_c.SetSessionID(*v)
	}
	return _c
}

// SetIPAddress sets the "ip_address" field.
func (_c *VisitorLogCreate) SetIPAddress(v string) *VisitorLogCreate {
	_c.mutation.SetIPAddress(v)
	return _c
}

// SetUserAgent sets the "user_agent" field.
func (_c *VisitorLogCreate) SetUserAgent(v string) *VisitorLogCreate {
	_c.mutation.SetUserAgent(v)
	return _c
}

// SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
func (_c *VisitorLogCreate) SetNillableUserAgent(v *string) *VisitorLogCreate {
	if v != nil {
		_c.SetUserAgent(*v)
	}
	return _c
}

// SetReferer sets the "referer" field.
func (_c *VisitorLogCreate) SetReferer(v string) *VisitorLogCreate {
	_c.mutation.SetReferer(v)
	return _c
}

// SetNillableReferer sets the "referer" field if the given value is not nil.
func (_c *VisitorLogCreate) SetNillableReferer(v *string) *VisitorLogCreate {
	if v != nil {
		_c.SetReferer(*v)
	}
	return _c
}

// SetURLPath sets the "url_path" field.
func (_c *VisitorLogCreate) SetURLPath(v string) *VisitorLogCreate {
	_c.mutation.SetURLPath(v)
	return _c
}

// SetCountry sets the "country" field.
func (_c *VisitorLogCreate) SetCountry(v string) *VisitorLogCreate {
	_c.mutation.SetCountry(v)
	return _c
}

// SetNillableCountry sets the "country" field if the given value is not nil.
func (_c *VisitorLogCreate) SetNillableCountry(v *string) *VisitorLogCreate {
	if v != nil {
		_c.SetCountry(*v)
	}
	return _c
}

// SetRegion sets the "region" field.
func (_c *VisitorLogCreate) SetRegion(v string) *VisitorLogCreate {
	_c.mutation.SetRegion(v)
	return _c
}

// SetNillableRegion sets the "region" field if the given value is not nil.
func (_c *VisitorLogCreate) SetNillableRegion(v *string) *VisitorLogCreate {
	if v != nil {
		_c.SetRegion(*v)
	}
	return _c
}

// SetCity sets the "city" field.
func (_c *VisitorLogCreate) SetCity(v string) *VisitorLogCreate {
	_c.mutation.SetCity(v)
	return _c
}

// SetNillableCity sets the "city" field if the given value is not nil.
func (_c *VisitorLogCreate) SetNillableCity(v *string) *VisitorLogCreate {
	if v != nil {
		_c.SetCity(*v)
	}
	return _c
}

// SetBrowser sets the "browser" field.
func (_c *VisitorLogCreate) SetBrowser(v string) *VisitorLogCreate {
	_c.mutation.SetBrowser(v)
	return _c
}

// SetNillableBrowser sets the "browser" field if the given value is not nil.
func (_c *VisitorLogCreate) SetNillableBrowser(v *string) *VisitorLogCreate {
	if v != nil {
		_c.SetBrowser(*v)
	}
	return _c
}

// SetOs sets the "os" field.
func (_c *VisitorLogCreate) SetOs(v string) *VisitorLogCreate {
	_c.mutation.SetOs(v)
	return _c
}

// SetNillableOs sets the "os" field if the given value is not nil.
func (_c *VisitorLogCreate) SetNillableOs(v *string) *VisitorLogCreate {
	if v != nil {
		_c.SetOs(*v)
	}
	return _c
}

// SetDevice sets the "device" field.
func (_c *VisitorLogCreate) SetDevice(v string) *VisitorLogCreate {
	_c.mutation.SetDevice(v)
	return _c
}

// SetNillableDevice sets the "device" field if the given value is not nil.
func (_c *VisitorLogCreate) SetNillableDevice(v *string) *VisitorLogCreate {
	if v != nil {
		_c.SetDevice(*v)
	}
	return _c
}

// SetDuration sets the "duration" field.
func (_c *VisitorLogCreate) SetDuration(v int) *VisitorLogCreate {
	_c.mutation.SetDuration(v)
	return _c
}

// SetNillableDuration sets the "duration" field if the given value is not nil.
func (_c *VisitorLogCreate) SetNillableDuration(v *int) *VisitorLogCreate {
	if v != nil {
		_c.SetDuration(*v)
	}
	return _c
}

// SetIsBounce sets the "is_bounce" field.
func (_c *VisitorLogCreate) SetIsBounce(v bool) *VisitorLogCreate {
	_c.mutation.SetIsBounce(v)
	return _c
}

// SetNillableIsBounce sets the "is_bounce" field if the given value is not nil.
func (_c *VisitorLogCreate) SetNillableIsBounce(v *bool) *VisitorLogCreate {
	if v != nil {
		_c.SetIsBounce(*v)
	}
	return _c
}

// SetID sets the "id" field.
func (_c *VisitorLogCreate) SetID(v uint) *VisitorLogCreate {
	_c.mutation.SetID(v)
	return _c
}

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

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

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

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

// ExecX is like Exec, but panics if an error occurs.
func (_c *VisitorLogCreate) 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 *VisitorLogCreate) defaults() {
	if _, ok := _c.mutation.CreatedAt(); !ok {
		v := visitorlog.DefaultCreatedAt()
		_c.mutation.SetCreatedAt(v)
	}
	if _, ok := _c.mutation.Duration(); !ok {
		v := visitorlog.DefaultDuration
		_c.mutation.SetDuration(v)
	}
	if _, ok := _c.mutation.IsBounce(); !ok {
		v := visitorlog.DefaultIsBounce
		_c.mutation.SetIsBounce(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (_c *VisitorLogCreate) check() error {
	if _, ok := _c.mutation.CreatedAt(); !ok {
		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "VisitorLog.created_at"`)}
	}
	if _, ok := _c.mutation.VisitorID(); !ok {
		return &ValidationError{Name: "visitor_id", err: errors.New(`ent: missing required field "VisitorLog.visitor_id"`)}
	}
	if v, ok := _c.mutation.VisitorID(); ok {
		if err := visitorlog.VisitorIDValidator(v); err != nil {
			return &ValidationError{Name: "visitor_id", err: fmt.Errorf(`ent: validator failed for field "VisitorLog.visitor_id": %w`, err)}
		}
	}
	if v, ok := _c.mutation.SessionID(); ok {
		if err := visitorlog.SessionIDValidator(v); err != nil {
			return &ValidationError{Name: "session_id", err: fmt.Errorf(`ent: validator failed for field "VisitorLog.session_id": %w`, err)}
		}
	}
	if _, ok := _c.mutation.IPAddress(); !ok {
		return &ValidationError{Name: "ip_address", err: errors.New(`ent: missing required field "VisitorLog.ip_address"`)}
	}
	if v, ok := _c.mutation.IPAddress(); ok {
		if err := visitorlog.IPAddressValidator(v); err != nil {
			return &ValidationError{Name: "ip_address", err: fmt.Errorf(`ent: validator failed for field "VisitorLog.ip_address": %w`, err)}
		}
	}
	if v, ok := _c.mutation.UserAgent(); ok {
		if err := visitorlog.UserAgentValidator(v); err != nil {
			return &ValidationError{Name: "user_agent", err: fmt.Errorf(`ent: validator failed for field "VisitorLog.user_agent": %w`, err)}
		}
	}
	if v, ok := _c.mutation.Referer(); ok {
		if err := visitorlog.RefererValidator(v); err != nil {
			return &ValidationError{Name: "referer", err: fmt.Errorf(`ent: validator failed for field "VisitorLog.referer": %w`, err)}
		}
	}
	if _, ok := _c.mutation.URLPath(); !ok {
		return &ValidationError{Name: "url_path", err: errors.New(`ent: missing required field "VisitorLog.url_path"`)}
	}
	if v, ok := _c.mutation.URLPath(); ok {
		if err := visitorlog.URLPathValidator(v); err != nil {
			return &ValidationError{Name: "url_path", err: fmt.Errorf(`ent: validator failed for field "VisitorLog.url_path": %w`, err)}
		}
	}
	if v, ok := _c.mutation.Country(); ok {
		if err := visitorlog.CountryValidator(v); err != nil {
			return &ValidationError{Name: "country", err: fmt.Errorf(`ent: validator failed for field "VisitorLog.country": %w`, err)}
		}
	}
	if v, ok := _c.mutation.Region(); ok {
		if err := visitorlog.RegionValidator(v); err != nil {
			return &ValidationError{Name: "region", err: fmt.Errorf(`ent: validator failed for field "VisitorLog.region": %w`, err)}
		}
	}
	if v, ok := _c.mutation.City(); ok {
		if err := visitorlog.CityValidator(v); err != nil {
			return &ValidationError{Name: "city", err: fmt.Errorf(`ent: validator failed for field "VisitorLog.city": %w`, err)}
		}
	}
	if v, ok := _c.mutation.Browser(); ok {
		if err := visitorlog.BrowserValidator(v); err != nil {
			return &ValidationError{Name: "browser", err: fmt.Errorf(`ent: validator failed for field "VisitorLog.browser": %w`, err)}
		}
	}
	if v, ok := _c.mutation.Os(); ok {
		if err := visitorlog.OsValidator(v); err != nil {
			return &ValidationError{Name: "os", err: fmt.Errorf(`ent: validator failed for field "VisitorLog.os": %w`, err)}
		}
	}
	if v, ok := _c.mutation.Device(); ok {
		if err := visitorlog.DeviceValidator(v); err != nil {
			return &ValidationError{Name: "device", err: fmt.Errorf(`ent: validator failed for field "VisitorLog.device": %w`, err)}
		}
	}
	if _, ok := _c.mutation.Duration(); !ok {
		return &ValidationError{Name: "duration", err: errors.New(`ent: missing required field "VisitorLog.duration"`)}
	}
	if _, ok := _c.mutation.IsBounce(); !ok {
		return &ValidationError{Name: "is_bounce", err: errors.New(`ent: missing required field "VisitorLog.is_bounce"`)}
	}
	return nil
}

func (_c *VisitorLogCreate) sqlSave(ctx context.Context) (*VisitorLog, 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
	}
	if _spec.ID.Value != _node.ID {
		id := _spec.ID.Value.(int64)
		_node.ID = uint(id)
	}
	_c.mutation.id = &_node.ID
	_c.mutation.done = true
	return _node, nil
}

func (_c *VisitorLogCreate) createSpec() (*VisitorLog, *sqlgraph.CreateSpec) {
	var (
		_node = &VisitorLog{config: _c.config}
		_spec = sqlgraph.NewCreateSpec(visitorlog.Table, sqlgraph.NewFieldSpec(visitorlog.FieldID, field.TypeUint))
	)
	_spec.OnConflict = _c.conflict
	if id, ok := _c.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = id
	}
	if value, ok := _c.mutation.CreatedAt(); ok {
		_spec.SetField(visitorlog.FieldCreatedAt, field.TypeTime, value)
		_node.CreatedAt = value
	}
	if value, ok := _c.mutation.VisitorID(); ok {
		_spec.SetField(visitorlog.FieldVisitorID, field.TypeString, value)
		_node.VisitorID = value
	}
	if value, ok := _c.mutation.SessionID(); ok {
		_spec.SetField(visitorlog.FieldSessionID, field.TypeString, value)
		_node.SessionID = &value
	}
	if value, ok := _c.mutation.IPAddress(); ok {
		_spec.SetField(visitorlog.FieldIPAddress, field.TypeString, value)
		_node.IPAddress = value
	}
	if value, ok := _c.mutation.UserAgent(); ok {
		_spec.SetField(visitorlog.FieldUserAgent, field.TypeString, value)
		_node.UserAgent = &value
	}
	if value, ok := _c.mutation.Referer(); ok {
		_spec.SetField(visitorlog.FieldReferer, field.TypeString, value)
		_node.Referer = &value
	}
	if value, ok := _c.mutation.URLPath(); ok {
		_spec.SetField(visitorlog.FieldURLPath, field.TypeString, value)
		_node.URLPath = value
	}
	if value, ok := _c.mutation.Country(); ok {
		_spec.SetField(visitorlog.FieldCountry, field.TypeString, value)
		_node.Country = &value
	}
	if value, ok := _c.mutation.Region(); ok {
		_spec.SetField(visitorlog.FieldRegion, field.TypeString, value)
		_node.Region = &value
	}
	if value, ok := _c.mutation.City(); ok {
		_spec.SetField(visitorlog.FieldCity, field.TypeString, value)
		_node.City = &value
	}
	if value, ok := _c.mutation.Browser(); ok {
		_spec.SetField(visitorlog.FieldBrowser, field.TypeString, value)
		_node.Browser = &value
	}
	if value, ok := _c.mutation.Os(); ok {
		_spec.SetField(visitorlog.FieldOs, field.TypeString, value)
		_node.Os = &value
	}
	if value, ok := _c.mutation.Device(); ok {
		_spec.SetField(visitorlog.FieldDevice, field.TypeString, value)
		_node.Device = &value
	}
	if value, ok := _c.mutation.Duration(); ok {
		_spec.SetField(visitorlog.FieldDuration, field.TypeInt, value)
		_node.Duration = value
	}
	if value, ok := _c.mutation.IsBounce(); ok {
		_spec.SetField(visitorlog.FieldIsBounce, field.TypeBool, value)
		_node.IsBounce = value
	}
	return _node, _spec
}

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

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

type (
	// VisitorLogUpsertOne is the builder for "upsert"-ing
	//  one VisitorLog node.
	VisitorLogUpsertOne struct {
		create *VisitorLogCreate
	}

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

// SetVisitorID sets the "visitor_id" field.
func (u *VisitorLogUpsert) SetVisitorID(v string) *VisitorLogUpsert {
	u.Set(visitorlog.FieldVisitorID, v)
	return u
}

// UpdateVisitorID sets the "visitor_id" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateVisitorID() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldVisitorID)
	return u
}

// SetSessionID sets the "session_id" field.
func (u *VisitorLogUpsert) SetSessionID(v string) *VisitorLogUpsert {
	u.Set(visitorlog.FieldSessionID, v)
	return u
}

// UpdateSessionID sets the "session_id" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateSessionID() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldSessionID)
	return u
}

// ClearSessionID clears the value of the "session_id" field.
func (u *VisitorLogUpsert) ClearSessionID() *VisitorLogUpsert {
	u.SetNull(visitorlog.FieldSessionID)
	return u
}

// SetIPAddress sets the "ip_address" field.
func (u *VisitorLogUpsert) SetIPAddress(v string) *VisitorLogUpsert {
	u.Set(visitorlog.FieldIPAddress, v)
	return u
}

// UpdateIPAddress sets the "ip_address" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateIPAddress() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldIPAddress)
	return u
}

// SetUserAgent sets the "user_agent" field.
func (u *VisitorLogUpsert) SetUserAgent(v string) *VisitorLogUpsert {
	u.Set(visitorlog.FieldUserAgent, v)
	return u
}

// UpdateUserAgent sets the "user_agent" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateUserAgent() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldUserAgent)
	return u
}

// ClearUserAgent clears the value of the "user_agent" field.
func (u *VisitorLogUpsert) ClearUserAgent() *VisitorLogUpsert {
	u.SetNull(visitorlog.FieldUserAgent)
	return u
}

// SetReferer sets the "referer" field.
func (u *VisitorLogUpsert) SetReferer(v string) *VisitorLogUpsert {
	u.Set(visitorlog.FieldReferer, v)
	return u
}

// UpdateReferer sets the "referer" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateReferer() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldReferer)
	return u
}

// ClearReferer clears the value of the "referer" field.
func (u *VisitorLogUpsert) ClearReferer() *VisitorLogUpsert {
	u.SetNull(visitorlog.FieldReferer)
	return u
}

// SetURLPath sets the "url_path" field.
func (u *VisitorLogUpsert) SetURLPath(v string) *VisitorLogUpsert {
	u.Set(visitorlog.FieldURLPath, v)
	return u
}

// UpdateURLPath sets the "url_path" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateURLPath() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldURLPath)
	return u
}

// SetCountry sets the "country" field.
func (u *VisitorLogUpsert) SetCountry(v string) *VisitorLogUpsert {
	u.Set(visitorlog.FieldCountry, v)
	return u
}

// UpdateCountry sets the "country" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateCountry() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldCountry)
	return u
}

// ClearCountry clears the value of the "country" field.
func (u *VisitorLogUpsert) ClearCountry() *VisitorLogUpsert {
	u.SetNull(visitorlog.FieldCountry)
	return u
}

// SetRegion sets the "region" field.
func (u *VisitorLogUpsert) SetRegion(v string) *VisitorLogUpsert {
	u.Set(visitorlog.FieldRegion, v)
	return u
}

// UpdateRegion sets the "region" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateRegion() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldRegion)
	return u
}

// ClearRegion clears the value of the "region" field.
func (u *VisitorLogUpsert) ClearRegion() *VisitorLogUpsert {
	u.SetNull(visitorlog.FieldRegion)
	return u
}

// SetCity sets the "city" field.
func (u *VisitorLogUpsert) SetCity(v string) *VisitorLogUpsert {
	u.Set(visitorlog.FieldCity, v)
	return u
}

// UpdateCity sets the "city" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateCity() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldCity)
	return u
}

// ClearCity clears the value of the "city" field.
func (u *VisitorLogUpsert) ClearCity() *VisitorLogUpsert {
	u.SetNull(visitorlog.FieldCity)
	return u
}

// SetBrowser sets the "browser" field.
func (u *VisitorLogUpsert) SetBrowser(v string) *VisitorLogUpsert {
	u.Set(visitorlog.FieldBrowser, v)
	return u
}

// UpdateBrowser sets the "browser" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateBrowser() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldBrowser)
	return u
}

// ClearBrowser clears the value of the "browser" field.
func (u *VisitorLogUpsert) ClearBrowser() *VisitorLogUpsert {
	u.SetNull(visitorlog.FieldBrowser)
	return u
}

// SetOs sets the "os" field.
func (u *VisitorLogUpsert) SetOs(v string) *VisitorLogUpsert {
	u.Set(visitorlog.FieldOs, v)
	return u
}

// UpdateOs sets the "os" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateOs() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldOs)
	return u
}

// ClearOs clears the value of the "os" field.
func (u *VisitorLogUpsert) ClearOs() *VisitorLogUpsert {
	u.SetNull(visitorlog.FieldOs)
	return u
}

// SetDevice sets the "device" field.
func (u *VisitorLogUpsert) SetDevice(v string) *VisitorLogUpsert {
	u.Set(visitorlog.FieldDevice, v)
	return u
}

// UpdateDevice sets the "device" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateDevice() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldDevice)
	return u
}

// ClearDevice clears the value of the "device" field.
func (u *VisitorLogUpsert) ClearDevice() *VisitorLogUpsert {
	u.SetNull(visitorlog.FieldDevice)
	return u
}

// SetDuration sets the "duration" field.
func (u *VisitorLogUpsert) SetDuration(v int) *VisitorLogUpsert {
	u.Set(visitorlog.FieldDuration, v)
	return u
}

// UpdateDuration sets the "duration" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateDuration() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldDuration)
	return u
}

// AddDuration adds v to the "duration" field.
func (u *VisitorLogUpsert) AddDuration(v int) *VisitorLogUpsert {
	u.Add(visitorlog.FieldDuration, v)
	return u
}

// SetIsBounce sets the "is_bounce" field.
func (u *VisitorLogUpsert) SetIsBounce(v bool) *VisitorLogUpsert {
	u.Set(visitorlog.FieldIsBounce, v)
	return u
}

// UpdateIsBounce sets the "is_bounce" field to the value that was provided on create.
func (u *VisitorLogUpsert) UpdateIsBounce() *VisitorLogUpsert {
	u.SetExcluded(visitorlog.FieldIsBounce)
	return u
}

// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
// Using this option is equivalent to using:
//
//	client.VisitorLog.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(visitorlog.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *VisitorLogUpsertOne) UpdateNewValues() *VisitorLogUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		if _, exists := u.create.mutation.ID(); exists {
			s.SetIgnore(visitorlog.FieldID)
		}
		if _, exists := u.create.mutation.CreatedAt(); exists {
			s.SetIgnore(visitorlog.FieldCreatedAt)
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.VisitorLog.Create().
//	    OnConflict(sql.ResolveWithIgnore()).
//	    Exec(ctx)
func (u *VisitorLogUpsertOne) Ignore() *VisitorLogUpsertOne {
	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 *VisitorLogUpsertOne) DoNothing() *VisitorLogUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

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

// SetVisitorID sets the "visitor_id" field.
func (u *VisitorLogUpsertOne) SetVisitorID(v string) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetVisitorID(v)
	})
}

// UpdateVisitorID sets the "visitor_id" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateVisitorID() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateVisitorID()
	})
}

// SetSessionID sets the "session_id" field.
func (u *VisitorLogUpsertOne) SetSessionID(v string) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetSessionID(v)
	})
}

// UpdateSessionID sets the "session_id" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateSessionID() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateSessionID()
	})
}

// ClearSessionID clears the value of the "session_id" field.
func (u *VisitorLogUpsertOne) ClearSessionID() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearSessionID()
	})
}

// SetIPAddress sets the "ip_address" field.
func (u *VisitorLogUpsertOne) SetIPAddress(v string) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetIPAddress(v)
	})
}

// UpdateIPAddress sets the "ip_address" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateIPAddress() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateIPAddress()
	})
}

// SetUserAgent sets the "user_agent" field.
func (u *VisitorLogUpsertOne) SetUserAgent(v string) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetUserAgent(v)
	})
}

// UpdateUserAgent sets the "user_agent" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateUserAgent() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateUserAgent()
	})
}

// ClearUserAgent clears the value of the "user_agent" field.
func (u *VisitorLogUpsertOne) ClearUserAgent() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearUserAgent()
	})
}

// SetReferer sets the "referer" field.
func (u *VisitorLogUpsertOne) SetReferer(v string) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetReferer(v)
	})
}

// UpdateReferer sets the "referer" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateReferer() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateReferer()
	})
}

// ClearReferer clears the value of the "referer" field.
func (u *VisitorLogUpsertOne) ClearReferer() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearReferer()
	})
}

// SetURLPath sets the "url_path" field.
func (u *VisitorLogUpsertOne) SetURLPath(v string) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetURLPath(v)
	})
}

// UpdateURLPath sets the "url_path" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateURLPath() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateURLPath()
	})
}

// SetCountry sets the "country" field.
func (u *VisitorLogUpsertOne) SetCountry(v string) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetCountry(v)
	})
}

// UpdateCountry sets the "country" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateCountry() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateCountry()
	})
}

// ClearCountry clears the value of the "country" field.
func (u *VisitorLogUpsertOne) ClearCountry() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearCountry()
	})
}

// SetRegion sets the "region" field.
func (u *VisitorLogUpsertOne) SetRegion(v string) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetRegion(v)
	})
}

// UpdateRegion sets the "region" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateRegion() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateRegion()
	})
}

// ClearRegion clears the value of the "region" field.
func (u *VisitorLogUpsertOne) ClearRegion() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearRegion()
	})
}

// SetCity sets the "city" field.
func (u *VisitorLogUpsertOne) SetCity(v string) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetCity(v)
	})
}

// UpdateCity sets the "city" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateCity() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateCity()
	})
}

// ClearCity clears the value of the "city" field.
func (u *VisitorLogUpsertOne) ClearCity() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearCity()
	})
}

// SetBrowser sets the "browser" field.
func (u *VisitorLogUpsertOne) SetBrowser(v string) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetBrowser(v)
	})
}

// UpdateBrowser sets the "browser" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateBrowser() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateBrowser()
	})
}

// ClearBrowser clears the value of the "browser" field.
func (u *VisitorLogUpsertOne) ClearBrowser() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearBrowser()
	})
}

// SetOs sets the "os" field.
func (u *VisitorLogUpsertOne) SetOs(v string) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetOs(v)
	})
}

// UpdateOs sets the "os" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateOs() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateOs()
	})
}

// ClearOs clears the value of the "os" field.
func (u *VisitorLogUpsertOne) ClearOs() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearOs()
	})
}

// SetDevice sets the "device" field.
func (u *VisitorLogUpsertOne) SetDevice(v string) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetDevice(v)
	})
}

// UpdateDevice sets the "device" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateDevice() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateDevice()
	})
}

// ClearDevice clears the value of the "device" field.
func (u *VisitorLogUpsertOne) ClearDevice() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearDevice()
	})
}

// SetDuration sets the "duration" field.
func (u *VisitorLogUpsertOne) SetDuration(v int) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetDuration(v)
	})
}

// AddDuration adds v to the "duration" field.
func (u *VisitorLogUpsertOne) AddDuration(v int) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.AddDuration(v)
	})
}

// UpdateDuration sets the "duration" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateDuration() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateDuration()
	})
}

// SetIsBounce sets the "is_bounce" field.
func (u *VisitorLogUpsertOne) SetIsBounce(v bool) *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetIsBounce(v)
	})
}

// UpdateIsBounce sets the "is_bounce" field to the value that was provided on create.
func (u *VisitorLogUpsertOne) UpdateIsBounce() *VisitorLogUpsertOne {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateIsBounce()
	})
}

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

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

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

// Save creates the VisitorLog entities in the database.
func (_c *VisitorLogCreateBulk) Save(ctx context.Context) ([]*VisitorLog, error) {
	if _c.err != nil {
		return nil, _c.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
	nodes := make([]*VisitorLog, 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.(*VisitorLogMutation)
				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 && nodes[i].ID == 0 {
					id := specs[i].ID.Value.(int64)
					nodes[i].ID = uint(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 *VisitorLogCreateBulk) SaveX(ctx context.Context) []*VisitorLog {
	v, err := _c.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

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

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

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

// VisitorLogUpsertBulk is the builder for "upsert"-ing
// a bulk of VisitorLog nodes.
type VisitorLogUpsertBulk struct {
	create *VisitorLogCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.VisitorLog.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(visitorlog.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *VisitorLogUpsertBulk) UpdateNewValues() *VisitorLogUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		for _, b := range u.create.builders {
			if _, exists := b.mutation.ID(); exists {
				s.SetIgnore(visitorlog.FieldID)
			}
			if _, exists := b.mutation.CreatedAt(); exists {
				s.SetIgnore(visitorlog.FieldCreatedAt)
			}
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.VisitorLog.Create().
//		OnConflict(sql.ResolveWithIgnore()).
//		Exec(ctx)
func (u *VisitorLogUpsertBulk) Ignore() *VisitorLogUpsertBulk {
	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 *VisitorLogUpsertBulk) DoNothing() *VisitorLogUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

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

// SetVisitorID sets the "visitor_id" field.
func (u *VisitorLogUpsertBulk) SetVisitorID(v string) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetVisitorID(v)
	})
}

// UpdateVisitorID sets the "visitor_id" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateVisitorID() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateVisitorID()
	})
}

// SetSessionID sets the "session_id" field.
func (u *VisitorLogUpsertBulk) SetSessionID(v string) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetSessionID(v)
	})
}

// UpdateSessionID sets the "session_id" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateSessionID() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateSessionID()
	})
}

// ClearSessionID clears the value of the "session_id" field.
func (u *VisitorLogUpsertBulk) ClearSessionID() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearSessionID()
	})
}

// SetIPAddress sets the "ip_address" field.
func (u *VisitorLogUpsertBulk) SetIPAddress(v string) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetIPAddress(v)
	})
}

// UpdateIPAddress sets the "ip_address" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateIPAddress() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateIPAddress()
	})
}

// SetUserAgent sets the "user_agent" field.
func (u *VisitorLogUpsertBulk) SetUserAgent(v string) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetUserAgent(v)
	})
}

// UpdateUserAgent sets the "user_agent" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateUserAgent() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateUserAgent()
	})
}

// ClearUserAgent clears the value of the "user_agent" field.
func (u *VisitorLogUpsertBulk) ClearUserAgent() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearUserAgent()
	})
}

// SetReferer sets the "referer" field.
func (u *VisitorLogUpsertBulk) SetReferer(v string) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetReferer(v)
	})
}

// UpdateReferer sets the "referer" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateReferer() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateReferer()
	})
}

// ClearReferer clears the value of the "referer" field.
func (u *VisitorLogUpsertBulk) ClearReferer() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearReferer()
	})
}

// SetURLPath sets the "url_path" field.
func (u *VisitorLogUpsertBulk) SetURLPath(v string) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetURLPath(v)
	})
}

// UpdateURLPath sets the "url_path" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateURLPath() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateURLPath()
	})
}

// SetCountry sets the "country" field.
func (u *VisitorLogUpsertBulk) SetCountry(v string) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetCountry(v)
	})
}

// UpdateCountry sets the "country" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateCountry() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateCountry()
	})
}

// ClearCountry clears the value of the "country" field.
func (u *VisitorLogUpsertBulk) ClearCountry() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearCountry()
	})
}

// SetRegion sets the "region" field.
func (u *VisitorLogUpsertBulk) SetRegion(v string) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetRegion(v)
	})
}

// UpdateRegion sets the "region" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateRegion() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateRegion()
	})
}

// ClearRegion clears the value of the "region" field.
func (u *VisitorLogUpsertBulk) ClearRegion() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearRegion()
	})
}

// SetCity sets the "city" field.
func (u *VisitorLogUpsertBulk) SetCity(v string) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetCity(v)
	})
}

// UpdateCity sets the "city" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateCity() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateCity()
	})
}

// ClearCity clears the value of the "city" field.
func (u *VisitorLogUpsertBulk) ClearCity() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearCity()
	})
}

// SetBrowser sets the "browser" field.
func (u *VisitorLogUpsertBulk) SetBrowser(v string) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetBrowser(v)
	})
}

// UpdateBrowser sets the "browser" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateBrowser() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateBrowser()
	})
}

// ClearBrowser clears the value of the "browser" field.
func (u *VisitorLogUpsertBulk) ClearBrowser() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearBrowser()
	})
}

// SetOs sets the "os" field.
func (u *VisitorLogUpsertBulk) SetOs(v string) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetOs(v)
	})
}

// UpdateOs sets the "os" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateOs() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateOs()
	})
}

// ClearOs clears the value of the "os" field.
func (u *VisitorLogUpsertBulk) ClearOs() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearOs()
	})
}

// SetDevice sets the "device" field.
func (u *VisitorLogUpsertBulk) SetDevice(v string) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetDevice(v)
	})
}

// UpdateDevice sets the "device" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateDevice() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateDevice()
	})
}

// ClearDevice clears the value of the "device" field.
func (u *VisitorLogUpsertBulk) ClearDevice() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.ClearDevice()
	})
}

// SetDuration sets the "duration" field.
func (u *VisitorLogUpsertBulk) SetDuration(v int) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetDuration(v)
	})
}

// AddDuration adds v to the "duration" field.
func (u *VisitorLogUpsertBulk) AddDuration(v int) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.AddDuration(v)
	})
}

// UpdateDuration sets the "duration" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateDuration() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateDuration()
	})
}

// SetIsBounce sets the "is_bounce" field.
func (u *VisitorLogUpsertBulk) SetIsBounce(v bool) *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.SetIsBounce(v)
	})
}

// UpdateIsBounce sets the "is_bounce" field to the value that was provided on create.
func (u *VisitorLogUpsertBulk) UpdateIsBounce() *VisitorLogUpsertBulk {
	return u.Update(func(s *VisitorLogUpsert) {
		s.UpdateIsBounce()
	})
}

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

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