// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"time"

	"entgo.io/ent/dialect"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/google/uuid"
	"github.com/lightsparkdev/spark/so/ent/signingnonce"
)

// SigningNonceCreate is the builder for creating a SigningNonce entity.
type SigningNonceCreate struct {
	config
	mutation *SigningNonceMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetCreateTime sets the "create_time" field.
func (snc *SigningNonceCreate) SetCreateTime(t time.Time) *SigningNonceCreate {
	snc.mutation.SetCreateTime(t)
	return snc
}

// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
func (snc *SigningNonceCreate) SetNillableCreateTime(t *time.Time) *SigningNonceCreate {
	if t != nil {
		snc.SetCreateTime(*t)
	}
	return snc
}

// SetUpdateTime sets the "update_time" field.
func (snc *SigningNonceCreate) SetUpdateTime(t time.Time) *SigningNonceCreate {
	snc.mutation.SetUpdateTime(t)
	return snc
}

// SetNillableUpdateTime sets the "update_time" field if the given value is not nil.
func (snc *SigningNonceCreate) SetNillableUpdateTime(t *time.Time) *SigningNonceCreate {
	if t != nil {
		snc.SetUpdateTime(*t)
	}
	return snc
}

// SetNonce sets the "nonce" field.
func (snc *SigningNonceCreate) SetNonce(b []byte) *SigningNonceCreate {
	snc.mutation.SetNonce(b)
	return snc
}

// SetNonceCommitment sets the "nonce_commitment" field.
func (snc *SigningNonceCreate) SetNonceCommitment(b []byte) *SigningNonceCreate {
	snc.mutation.SetNonceCommitment(b)
	return snc
}

// SetMessage sets the "message" field.
func (snc *SigningNonceCreate) SetMessage(b []byte) *SigningNonceCreate {
	snc.mutation.SetMessage(b)
	return snc
}

// SetRetryFingerprint sets the "retry_fingerprint" field.
func (snc *SigningNonceCreate) SetRetryFingerprint(b []byte) *SigningNonceCreate {
	snc.mutation.SetRetryFingerprint(b)
	return snc
}

// SetID sets the "id" field.
func (snc *SigningNonceCreate) SetID(u uuid.UUID) *SigningNonceCreate {
	snc.mutation.SetID(u)
	return snc
}

// SetNillableID sets the "id" field if the given value is not nil.
func (snc *SigningNonceCreate) SetNillableID(u *uuid.UUID) *SigningNonceCreate {
	if u != nil {
		snc.SetID(*u)
	}
	return snc
}

// Mutation returns the SigningNonceMutation object of the builder.
func (snc *SigningNonceCreate) Mutation() *SigningNonceMutation {
	return snc.mutation
}

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

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

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

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

// defaults sets the default values of the builder before save.
func (snc *SigningNonceCreate) defaults() {
	if _, ok := snc.mutation.CreateTime(); !ok {
		v := signingnonce.DefaultCreateTime()
		snc.mutation.SetCreateTime(v)
	}
	if _, ok := snc.mutation.UpdateTime(); !ok {
		v := signingnonce.DefaultUpdateTime()
		snc.mutation.SetUpdateTime(v)
	}
	if _, ok := snc.mutation.ID(); !ok {
		v := signingnonce.DefaultID()
		snc.mutation.SetID(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (snc *SigningNonceCreate) check() error {
	if _, ok := snc.mutation.CreateTime(); !ok {
		return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "SigningNonce.create_time"`)}
	}
	if _, ok := snc.mutation.UpdateTime(); !ok {
		return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "SigningNonce.update_time"`)}
	}
	if _, ok := snc.mutation.Nonce(); !ok {
		return &ValidationError{Name: "nonce", err: errors.New(`ent: missing required field "SigningNonce.nonce"`)}
	}
	if _, ok := snc.mutation.NonceCommitment(); !ok {
		return &ValidationError{Name: "nonce_commitment", err: errors.New(`ent: missing required field "SigningNonce.nonce_commitment"`)}
	}
	return nil
}

func (snc *SigningNonceCreate) sqlSave(ctx context.Context) (*SigningNonce, error) {
	if err := snc.check(); err != nil {
		return nil, err
	}
	_node, _spec := snc.createSpec()
	if err := sqlgraph.CreateNode(ctx, snc.driver, _spec); err != nil {
		if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	if _spec.ID.Value != nil {
		if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
			_node.ID = *id
		} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
			return nil, err
		}
	}
	snc.mutation.id = &_node.ID
	snc.mutation.done = true
	return _node, nil
}

func (snc *SigningNonceCreate) createSpec() (*SigningNonce, *sqlgraph.CreateSpec) {
	var (
		_node = &SigningNonce{config: snc.config}
		_spec = sqlgraph.NewCreateSpec(signingnonce.Table, sqlgraph.NewFieldSpec(signingnonce.FieldID, field.TypeUUID))
	)
	_spec.OnConflict = snc.conflict
	if id, ok := snc.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = &id
	}
	if value, ok := snc.mutation.CreateTime(); ok {
		_spec.SetField(signingnonce.FieldCreateTime, field.TypeTime, value)
		_node.CreateTime = value
	}
	if value, ok := snc.mutation.UpdateTime(); ok {
		_spec.SetField(signingnonce.FieldUpdateTime, field.TypeTime, value)
		_node.UpdateTime = value
	}
	if value, ok := snc.mutation.Nonce(); ok {
		_spec.SetField(signingnonce.FieldNonce, field.TypeBytes, value)
		_node.Nonce = value
	}
	if value, ok := snc.mutation.NonceCommitment(); ok {
		_spec.SetField(signingnonce.FieldNonceCommitment, field.TypeBytes, value)
		_node.NonceCommitment = value
	}
	if value, ok := snc.mutation.Message(); ok {
		_spec.SetField(signingnonce.FieldMessage, field.TypeBytes, value)
		_node.Message = value
	}
	if value, ok := snc.mutation.RetryFingerprint(); ok {
		_spec.SetField(signingnonce.FieldRetryFingerprint, field.TypeBytes, value)
		_node.RetryFingerprint = value
	}
	return _node, _spec
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.SigningNonce.Create().
//		SetCreateTime(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.SigningNonceUpsert) {
//			SetCreateTime(v+v).
//		}).
//		Exec(ctx)
func (snc *SigningNonceCreate) OnConflict(opts ...sql.ConflictOption) *SigningNonceUpsertOne {
	snc.conflict = opts
	return &SigningNonceUpsertOne{
		create: snc,
	}
}

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

type (
	// SigningNonceUpsertOne is the builder for "upsert"-ing
	//  one SigningNonce node.
	SigningNonceUpsertOne struct {
		create *SigningNonceCreate
	}

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

// SetUpdateTime sets the "update_time" field.
func (u *SigningNonceUpsert) SetUpdateTime(v time.Time) *SigningNonceUpsert {
	u.Set(signingnonce.FieldUpdateTime, v)
	return u
}

// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
func (u *SigningNonceUpsert) UpdateUpdateTime() *SigningNonceUpsert {
	u.SetExcluded(signingnonce.FieldUpdateTime)
	return u
}

// SetMessage sets the "message" field.
func (u *SigningNonceUpsert) SetMessage(v []byte) *SigningNonceUpsert {
	u.Set(signingnonce.FieldMessage, v)
	return u
}

// UpdateMessage sets the "message" field to the value that was provided on create.
func (u *SigningNonceUpsert) UpdateMessage() *SigningNonceUpsert {
	u.SetExcluded(signingnonce.FieldMessage)
	return u
}

// ClearMessage clears the value of the "message" field.
func (u *SigningNonceUpsert) ClearMessage() *SigningNonceUpsert {
	u.SetNull(signingnonce.FieldMessage)
	return u
}

// SetRetryFingerprint sets the "retry_fingerprint" field.
func (u *SigningNonceUpsert) SetRetryFingerprint(v []byte) *SigningNonceUpsert {
	u.Set(signingnonce.FieldRetryFingerprint, v)
	return u
}

// UpdateRetryFingerprint sets the "retry_fingerprint" field to the value that was provided on create.
func (u *SigningNonceUpsert) UpdateRetryFingerprint() *SigningNonceUpsert {
	u.SetExcluded(signingnonce.FieldRetryFingerprint)
	return u
}

// ClearRetryFingerprint clears the value of the "retry_fingerprint" field.
func (u *SigningNonceUpsert) ClearRetryFingerprint() *SigningNonceUpsert {
	u.SetNull(signingnonce.FieldRetryFingerprint)
	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.SigningNonce.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(signingnonce.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *SigningNonceUpsertOne) UpdateNewValues() *SigningNonceUpsertOne {
	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(signingnonce.FieldID)
		}
		if _, exists := u.create.mutation.CreateTime(); exists {
			s.SetIgnore(signingnonce.FieldCreateTime)
		}
		if _, exists := u.create.mutation.Nonce(); exists {
			s.SetIgnore(signingnonce.FieldNonce)
		}
		if _, exists := u.create.mutation.NonceCommitment(); exists {
			s.SetIgnore(signingnonce.FieldNonceCommitment)
		}
	}))
	return u
}

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

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

// SetUpdateTime sets the "update_time" field.
func (u *SigningNonceUpsertOne) SetUpdateTime(v time.Time) *SigningNonceUpsertOne {
	return u.Update(func(s *SigningNonceUpsert) {
		s.SetUpdateTime(v)
	})
}

// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
func (u *SigningNonceUpsertOne) UpdateUpdateTime() *SigningNonceUpsertOne {
	return u.Update(func(s *SigningNonceUpsert) {
		s.UpdateUpdateTime()
	})
}

// SetMessage sets the "message" field.
func (u *SigningNonceUpsertOne) SetMessage(v []byte) *SigningNonceUpsertOne {
	return u.Update(func(s *SigningNonceUpsert) {
		s.SetMessage(v)
	})
}

// UpdateMessage sets the "message" field to the value that was provided on create.
func (u *SigningNonceUpsertOne) UpdateMessage() *SigningNonceUpsertOne {
	return u.Update(func(s *SigningNonceUpsert) {
		s.UpdateMessage()
	})
}

// ClearMessage clears the value of the "message" field.
func (u *SigningNonceUpsertOne) ClearMessage() *SigningNonceUpsertOne {
	return u.Update(func(s *SigningNonceUpsert) {
		s.ClearMessage()
	})
}

// SetRetryFingerprint sets the "retry_fingerprint" field.
func (u *SigningNonceUpsertOne) SetRetryFingerprint(v []byte) *SigningNonceUpsertOne {
	return u.Update(func(s *SigningNonceUpsert) {
		s.SetRetryFingerprint(v)
	})
}

// UpdateRetryFingerprint sets the "retry_fingerprint" field to the value that was provided on create.
func (u *SigningNonceUpsertOne) UpdateRetryFingerprint() *SigningNonceUpsertOne {
	return u.Update(func(s *SigningNonceUpsert) {
		s.UpdateRetryFingerprint()
	})
}

// ClearRetryFingerprint clears the value of the "retry_fingerprint" field.
func (u *SigningNonceUpsertOne) ClearRetryFingerprint() *SigningNonceUpsertOne {
	return u.Update(func(s *SigningNonceUpsert) {
		s.ClearRetryFingerprint()
	})
}

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

// ExecX is like Exec, but panics if an error occurs.
func (u *SigningNonceUpsertOne) 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 *SigningNonceUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) {
	if u.create.driver.Dialect() == dialect.MySQL {
		// In case of "ON CONFLICT", there is no way to get back non-numeric ID
		// fields from the database since MySQL does not support the RETURNING clause.
		return id, errors.New("ent: SigningNonceUpsertOne.ID is not supported by MySQL driver. Use SigningNonceUpsertOne.Exec instead")
	}
	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 *SigningNonceUpsertOne) IDX(ctx context.Context) uuid.UUID {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

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

// Save creates the SigningNonce entities in the database.
func (sncb *SigningNonceCreateBulk) Save(ctx context.Context) ([]*SigningNonce, error) {
	if sncb.err != nil {
		return nil, sncb.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(sncb.builders))
	nodes := make([]*SigningNonce, len(sncb.builders))
	mutators := make([]Mutator, len(sncb.builders))
	for i := range sncb.builders {
		func(i int, root context.Context) {
			builder := sncb.builders[i]
			builder.defaults()
			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
				mutation, ok := m.(*SigningNonceMutation)
				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, sncb.builders[i+1].mutation)
				} else {
					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
					spec.OnConflict = sncb.conflict
					// Invoke the actual operation on the latest mutation in the chain.
					if err = sqlgraph.BatchCreate(ctx, sncb.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
				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, sncb.builders[0].mutation); err != nil {
			return nil, err
		}
	}
	return nodes, nil
}

// SaveX is like Save, but panics if an error occurs.
func (sncb *SigningNonceCreateBulk) SaveX(ctx context.Context) []*SigningNonce {
	v, err := sncb.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

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

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

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.SigningNonce.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.SigningNonceUpsert) {
//			SetCreateTime(v+v).
//		}).
//		Exec(ctx)
func (sncb *SigningNonceCreateBulk) OnConflict(opts ...sql.ConflictOption) *SigningNonceUpsertBulk {
	sncb.conflict = opts
	return &SigningNonceUpsertBulk{
		create: sncb,
	}
}

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

// SigningNonceUpsertBulk is the builder for "upsert"-ing
// a bulk of SigningNonce nodes.
type SigningNonceUpsertBulk struct {
	create *SigningNonceCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.SigningNonce.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(signingnonce.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *SigningNonceUpsertBulk) UpdateNewValues() *SigningNonceUpsertBulk {
	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(signingnonce.FieldID)
			}
			if _, exists := b.mutation.CreateTime(); exists {
				s.SetIgnore(signingnonce.FieldCreateTime)
			}
			if _, exists := b.mutation.Nonce(); exists {
				s.SetIgnore(signingnonce.FieldNonce)
			}
			if _, exists := b.mutation.NonceCommitment(); exists {
				s.SetIgnore(signingnonce.FieldNonceCommitment)
			}
		}
	}))
	return u
}

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

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

// SetUpdateTime sets the "update_time" field.
func (u *SigningNonceUpsertBulk) SetUpdateTime(v time.Time) *SigningNonceUpsertBulk {
	return u.Update(func(s *SigningNonceUpsert) {
		s.SetUpdateTime(v)
	})
}

// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
func (u *SigningNonceUpsertBulk) UpdateUpdateTime() *SigningNonceUpsertBulk {
	return u.Update(func(s *SigningNonceUpsert) {
		s.UpdateUpdateTime()
	})
}

// SetMessage sets the "message" field.
func (u *SigningNonceUpsertBulk) SetMessage(v []byte) *SigningNonceUpsertBulk {
	return u.Update(func(s *SigningNonceUpsert) {
		s.SetMessage(v)
	})
}

// UpdateMessage sets the "message" field to the value that was provided on create.
func (u *SigningNonceUpsertBulk) UpdateMessage() *SigningNonceUpsertBulk {
	return u.Update(func(s *SigningNonceUpsert) {
		s.UpdateMessage()
	})
}

// ClearMessage clears the value of the "message" field.
func (u *SigningNonceUpsertBulk) ClearMessage() *SigningNonceUpsertBulk {
	return u.Update(func(s *SigningNonceUpsert) {
		s.ClearMessage()
	})
}

// SetRetryFingerprint sets the "retry_fingerprint" field.
func (u *SigningNonceUpsertBulk) SetRetryFingerprint(v []byte) *SigningNonceUpsertBulk {
	return u.Update(func(s *SigningNonceUpsert) {
		s.SetRetryFingerprint(v)
	})
}

// UpdateRetryFingerprint sets the "retry_fingerprint" field to the value that was provided on create.
func (u *SigningNonceUpsertBulk) UpdateRetryFingerprint() *SigningNonceUpsertBulk {
	return u.Update(func(s *SigningNonceUpsert) {
		s.UpdateRetryFingerprint()
	})
}

// ClearRetryFingerprint clears the value of the "retry_fingerprint" field.
func (u *SigningNonceUpsertBulk) ClearRetryFingerprint() *SigningNonceUpsertBulk {
	return u.Update(func(s *SigningNonceUpsert) {
		s.ClearRetryFingerprint()
	})
}

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

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