You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudreve/ent/ssobinding_create.go

801 lines
23 KiB

// 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/cloudreve/Cloudreve/v4/ent/ssobinding"
"github.com/cloudreve/Cloudreve/v4/ent/user"
)
// SsoBindingCreate is the builder for creating a SsoBinding entity.
type SsoBindingCreate struct {
config
mutation *SsoBindingMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetCreatedAt sets the "created_at" field.
func (sbc *SsoBindingCreate) SetCreatedAt(t time.Time) *SsoBindingCreate {
sbc.mutation.SetCreatedAt(t)
return sbc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (sbc *SsoBindingCreate) SetNillableCreatedAt(t *time.Time) *SsoBindingCreate {
if t != nil {
sbc.SetCreatedAt(*t)
}
return sbc
}
// SetUpdatedAt sets the "updated_at" field.
func (sbc *SsoBindingCreate) SetUpdatedAt(t time.Time) *SsoBindingCreate {
sbc.mutation.SetUpdatedAt(t)
return sbc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (sbc *SsoBindingCreate) SetNillableUpdatedAt(t *time.Time) *SsoBindingCreate {
if t != nil {
sbc.SetUpdatedAt(*t)
}
return sbc
}
// SetDeletedAt sets the "deleted_at" field.
func (sbc *SsoBindingCreate) SetDeletedAt(t time.Time) *SsoBindingCreate {
sbc.mutation.SetDeletedAt(t)
return sbc
}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (sbc *SsoBindingCreate) SetNillableDeletedAt(t *time.Time) *SsoBindingCreate {
if t != nil {
sbc.SetDeletedAt(*t)
}
return sbc
}
// SetProvider sets the "provider" field.
func (sbc *SsoBindingCreate) SetProvider(s string) *SsoBindingCreate {
sbc.mutation.SetProvider(s)
return sbc
}
// SetSubject sets the "subject" field.
func (sbc *SsoBindingCreate) SetSubject(s string) *SsoBindingCreate {
sbc.mutation.SetSubject(s)
return sbc
}
// SetUserID sets the "user_id" field.
func (sbc *SsoBindingCreate) SetUserID(i int) *SsoBindingCreate {
sbc.mutation.SetUserID(i)
return sbc
}
// SetUser sets the "user" edge to the User entity.
func (sbc *SsoBindingCreate) SetUser(u *User) *SsoBindingCreate {
return sbc.SetUserID(u.ID)
}
// Mutation returns the SsoBindingMutation object of the builder.
func (sbc *SsoBindingCreate) Mutation() *SsoBindingMutation {
return sbc.mutation
}
// Save creates the SsoBinding in the database.
func (sbc *SsoBindingCreate) Save(ctx context.Context) (*SsoBinding, error) {
if err := sbc.defaults(); err != nil {
return nil, err
}
return withHooks(ctx, sbc.sqlSave, sbc.mutation, sbc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (sbc *SsoBindingCreate) SaveX(ctx context.Context) *SsoBinding {
v, err := sbc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sbc *SsoBindingCreate) Exec(ctx context.Context) error {
_, err := sbc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sbc *SsoBindingCreate) ExecX(ctx context.Context) {
if err := sbc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sbc *SsoBindingCreate) defaults() error {
if _, ok := sbc.mutation.CreatedAt(); !ok {
if ssobinding.DefaultCreatedAt == nil {
return fmt.Errorf("ent: uninitialized ssobinding.DefaultCreatedAt (forgotten import ent/runtime?)")
}
v := ssobinding.DefaultCreatedAt()
sbc.mutation.SetCreatedAt(v)
}
if _, ok := sbc.mutation.UpdatedAt(); !ok {
if ssobinding.DefaultUpdatedAt == nil {
return fmt.Errorf("ent: uninitialized ssobinding.DefaultUpdatedAt (forgotten import ent/runtime?)")
}
v := ssobinding.DefaultUpdatedAt()
sbc.mutation.SetUpdatedAt(v)
}
return nil
}
// check runs all checks and user-defined validators on the builder.
func (sbc *SsoBindingCreate) check() error {
if _, ok := sbc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "SsoBinding.created_at"`)}
}
if _, ok := sbc.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "SsoBinding.updated_at"`)}
}
if _, ok := sbc.mutation.Provider(); !ok {
return &ValidationError{Name: "provider", err: errors.New(`ent: missing required field "SsoBinding.provider"`)}
}
if v, ok := sbc.mutation.Provider(); ok {
if err := ssobinding.ProviderValidator(v); err != nil {
return &ValidationError{Name: "provider", err: fmt.Errorf(`ent: validator failed for field "SsoBinding.provider": %w`, err)}
}
}
if _, ok := sbc.mutation.Subject(); !ok {
return &ValidationError{Name: "subject", err: errors.New(`ent: missing required field "SsoBinding.subject"`)}
}
if v, ok := sbc.mutation.Subject(); ok {
if err := ssobinding.SubjectValidator(v); err != nil {
return &ValidationError{Name: "subject", err: fmt.Errorf(`ent: validator failed for field "SsoBinding.subject": %w`, err)}
}
}
if _, ok := sbc.mutation.UserID(); !ok {
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "SsoBinding.user_id"`)}
}
if _, ok := sbc.mutation.UserID(); !ok {
return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "SsoBinding.user"`)}
}
return nil
}
func (sbc *SsoBindingCreate) sqlSave(ctx context.Context) (*SsoBinding, error) {
if err := sbc.check(); err != nil {
return nil, err
}
_node, _spec := sbc.createSpec()
if err := sqlgraph.CreateNode(ctx, sbc.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)
sbc.mutation.id = &_node.ID
sbc.mutation.done = true
return _node, nil
}
func (sbc *SsoBindingCreate) createSpec() (*SsoBinding, *sqlgraph.CreateSpec) {
var (
_node = &SsoBinding{config: sbc.config}
_spec = sqlgraph.NewCreateSpec(ssobinding.Table, sqlgraph.NewFieldSpec(ssobinding.FieldID, field.TypeInt))
)
if id, ok := sbc.mutation.ID(); ok {
_node.ID = id
id64 := int64(id)
_spec.ID.Value = id64
}
_spec.OnConflict = sbc.conflict
if value, ok := sbc.mutation.CreatedAt(); ok {
_spec.SetField(ssobinding.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := sbc.mutation.UpdatedAt(); ok {
_spec.SetField(ssobinding.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := sbc.mutation.DeletedAt(); ok {
_spec.SetField(ssobinding.FieldDeletedAt, field.TypeTime, value)
_node.DeletedAt = &value
}
if value, ok := sbc.mutation.Provider(); ok {
_spec.SetField(ssobinding.FieldProvider, field.TypeString, value)
_node.Provider = value
}
if value, ok := sbc.mutation.Subject(); ok {
_spec.SetField(ssobinding.FieldSubject, field.TypeString, value)
_node.Subject = value
}
if nodes := sbc.mutation.UserIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: ssobinding.UserTable,
Columns: []string{ssobinding.UserColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.UserID = nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.SsoBinding.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.SsoBindingUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (sbc *SsoBindingCreate) OnConflict(opts ...sql.ConflictOption) *SsoBindingUpsertOne {
sbc.conflict = opts
return &SsoBindingUpsertOne{
create: sbc,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.SsoBinding.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (sbc *SsoBindingCreate) OnConflictColumns(columns ...string) *SsoBindingUpsertOne {
sbc.conflict = append(sbc.conflict, sql.ConflictColumns(columns...))
return &SsoBindingUpsertOne{
create: sbc,
}
}
type (
// SsoBindingUpsertOne is the builder for "upsert"-ing
// one SsoBinding node.
SsoBindingUpsertOne struct {
create *SsoBindingCreate
}
// SsoBindingUpsert is the "OnConflict" setter.
SsoBindingUpsert struct {
*sql.UpdateSet
}
)
// SetUpdatedAt sets the "updated_at" field.
func (u *SsoBindingUpsert) SetUpdatedAt(v time.Time) *SsoBindingUpsert {
u.Set(ssobinding.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *SsoBindingUpsert) UpdateUpdatedAt() *SsoBindingUpsert {
u.SetExcluded(ssobinding.FieldUpdatedAt)
return u
}
// SetDeletedAt sets the "deleted_at" field.
func (u *SsoBindingUpsert) SetDeletedAt(v time.Time) *SsoBindingUpsert {
u.Set(ssobinding.FieldDeletedAt, v)
return u
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *SsoBindingUpsert) UpdateDeletedAt() *SsoBindingUpsert {
u.SetExcluded(ssobinding.FieldDeletedAt)
return u
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *SsoBindingUpsert) ClearDeletedAt() *SsoBindingUpsert {
u.SetNull(ssobinding.FieldDeletedAt)
return u
}
// SetProvider sets the "provider" field.
func (u *SsoBindingUpsert) SetProvider(v string) *SsoBindingUpsert {
u.Set(ssobinding.FieldProvider, v)
return u
}
// UpdateProvider sets the "provider" field to the value that was provided on create.
func (u *SsoBindingUpsert) UpdateProvider() *SsoBindingUpsert {
u.SetExcluded(ssobinding.FieldProvider)
return u
}
// SetSubject sets the "subject" field.
func (u *SsoBindingUpsert) SetSubject(v string) *SsoBindingUpsert {
u.Set(ssobinding.FieldSubject, v)
return u
}
// UpdateSubject sets the "subject" field to the value that was provided on create.
func (u *SsoBindingUpsert) UpdateSubject() *SsoBindingUpsert {
u.SetExcluded(ssobinding.FieldSubject)
return u
}
// SetUserID sets the "user_id" field.
func (u *SsoBindingUpsert) SetUserID(v int) *SsoBindingUpsert {
u.Set(ssobinding.FieldUserID, v)
return u
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *SsoBindingUpsert) UpdateUserID() *SsoBindingUpsert {
u.SetExcluded(ssobinding.FieldUserID)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.SsoBinding.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *SsoBindingUpsertOne) UpdateNewValues() *SsoBindingUpsertOne {
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.CreatedAt(); exists {
s.SetIgnore(ssobinding.FieldCreatedAt)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.SsoBinding.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *SsoBindingUpsertOne) Ignore() *SsoBindingUpsertOne {
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 *SsoBindingUpsertOne) DoNothing() *SsoBindingUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the SsoBindingCreate.OnConflict
// documentation for more info.
func (u *SsoBindingUpsertOne) Update(set func(*SsoBindingUpsert)) *SsoBindingUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&SsoBindingUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *SsoBindingUpsertOne) SetUpdatedAt(v time.Time) *SsoBindingUpsertOne {
return u.Update(func(s *SsoBindingUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *SsoBindingUpsertOne) UpdateUpdatedAt() *SsoBindingUpsertOne {
return u.Update(func(s *SsoBindingUpsert) {
s.UpdateUpdatedAt()
})
}
// SetDeletedAt sets the "deleted_at" field.
func (u *SsoBindingUpsertOne) SetDeletedAt(v time.Time) *SsoBindingUpsertOne {
return u.Update(func(s *SsoBindingUpsert) {
s.SetDeletedAt(v)
})
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *SsoBindingUpsertOne) UpdateDeletedAt() *SsoBindingUpsertOne {
return u.Update(func(s *SsoBindingUpsert) {
s.UpdateDeletedAt()
})
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *SsoBindingUpsertOne) ClearDeletedAt() *SsoBindingUpsertOne {
return u.Update(func(s *SsoBindingUpsert) {
s.ClearDeletedAt()
})
}
// SetProvider sets the "provider" field.
func (u *SsoBindingUpsertOne) SetProvider(v string) *SsoBindingUpsertOne {
return u.Update(func(s *SsoBindingUpsert) {
s.SetProvider(v)
})
}
// UpdateProvider sets the "provider" field to the value that was provided on create.
func (u *SsoBindingUpsertOne) UpdateProvider() *SsoBindingUpsertOne {
return u.Update(func(s *SsoBindingUpsert) {
s.UpdateProvider()
})
}
// SetSubject sets the "subject" field.
func (u *SsoBindingUpsertOne) SetSubject(v string) *SsoBindingUpsertOne {
return u.Update(func(s *SsoBindingUpsert) {
s.SetSubject(v)
})
}
// UpdateSubject sets the "subject" field to the value that was provided on create.
func (u *SsoBindingUpsertOne) UpdateSubject() *SsoBindingUpsertOne {
return u.Update(func(s *SsoBindingUpsert) {
s.UpdateSubject()
})
}
// SetUserID sets the "user_id" field.
func (u *SsoBindingUpsertOne) SetUserID(v int) *SsoBindingUpsertOne {
return u.Update(func(s *SsoBindingUpsert) {
s.SetUserID(v)
})
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *SsoBindingUpsertOne) UpdateUserID() *SsoBindingUpsertOne {
return u.Update(func(s *SsoBindingUpsert) {
s.UpdateUserID()
})
}
// Exec executes the query.
func (u *SsoBindingUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for SsoBindingCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *SsoBindingUpsertOne) 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 *SsoBindingUpsertOne) 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 *SsoBindingUpsertOne) IDX(ctx context.Context) int {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
func (m *SsoBindingCreate) SetRawID(t int) *SsoBindingCreate {
m.mutation.SetRawID(t)
return m
}
// SsoBindingCreateBulk is the builder for creating many SsoBinding entities in bulk.
type SsoBindingCreateBulk struct {
config
err error
builders []*SsoBindingCreate
conflict []sql.ConflictOption
}
// Save creates the SsoBinding entities in the database.
func (sbcb *SsoBindingCreateBulk) Save(ctx context.Context) ([]*SsoBinding, error) {
if sbcb.err != nil {
return nil, sbcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(sbcb.builders))
nodes := make([]*SsoBinding, len(sbcb.builders))
mutators := make([]Mutator, len(sbcb.builders))
for i := range sbcb.builders {
func(i int, root context.Context) {
builder := sbcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*SsoBindingMutation)
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, sbcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = sbcb.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, sbcb.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, sbcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (sbcb *SsoBindingCreateBulk) SaveX(ctx context.Context) []*SsoBinding {
v, err := sbcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sbcb *SsoBindingCreateBulk) Exec(ctx context.Context) error {
_, err := sbcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sbcb *SsoBindingCreateBulk) ExecX(ctx context.Context) {
if err := sbcb.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.SsoBinding.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.SsoBindingUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (sbcb *SsoBindingCreateBulk) OnConflict(opts ...sql.ConflictOption) *SsoBindingUpsertBulk {
sbcb.conflict = opts
return &SsoBindingUpsertBulk{
create: sbcb,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.SsoBinding.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (sbcb *SsoBindingCreateBulk) OnConflictColumns(columns ...string) *SsoBindingUpsertBulk {
sbcb.conflict = append(sbcb.conflict, sql.ConflictColumns(columns...))
return &SsoBindingUpsertBulk{
create: sbcb,
}
}
// SsoBindingUpsertBulk is the builder for "upsert"-ing
// a bulk of SsoBinding nodes.
type SsoBindingUpsertBulk struct {
create *SsoBindingCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.SsoBinding.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *SsoBindingUpsertBulk) UpdateNewValues() *SsoBindingUpsertBulk {
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.CreatedAt(); exists {
s.SetIgnore(ssobinding.FieldCreatedAt)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.SsoBinding.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *SsoBindingUpsertBulk) Ignore() *SsoBindingUpsertBulk {
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 *SsoBindingUpsertBulk) DoNothing() *SsoBindingUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the SsoBindingCreateBulk.OnConflict
// documentation for more info.
func (u *SsoBindingUpsertBulk) Update(set func(*SsoBindingUpsert)) *SsoBindingUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&SsoBindingUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *SsoBindingUpsertBulk) SetUpdatedAt(v time.Time) *SsoBindingUpsertBulk {
return u.Update(func(s *SsoBindingUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *SsoBindingUpsertBulk) UpdateUpdatedAt() *SsoBindingUpsertBulk {
return u.Update(func(s *SsoBindingUpsert) {
s.UpdateUpdatedAt()
})
}
// SetDeletedAt sets the "deleted_at" field.
func (u *SsoBindingUpsertBulk) SetDeletedAt(v time.Time) *SsoBindingUpsertBulk {
return u.Update(func(s *SsoBindingUpsert) {
s.SetDeletedAt(v)
})
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *SsoBindingUpsertBulk) UpdateDeletedAt() *SsoBindingUpsertBulk {
return u.Update(func(s *SsoBindingUpsert) {
s.UpdateDeletedAt()
})
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *SsoBindingUpsertBulk) ClearDeletedAt() *SsoBindingUpsertBulk {
return u.Update(func(s *SsoBindingUpsert) {
s.ClearDeletedAt()
})
}
// SetProvider sets the "provider" field.
func (u *SsoBindingUpsertBulk) SetProvider(v string) *SsoBindingUpsertBulk {
return u.Update(func(s *SsoBindingUpsert) {
s.SetProvider(v)
})
}
// UpdateProvider sets the "provider" field to the value that was provided on create.
func (u *SsoBindingUpsertBulk) UpdateProvider() *SsoBindingUpsertBulk {
return u.Update(func(s *SsoBindingUpsert) {
s.UpdateProvider()
})
}
// SetSubject sets the "subject" field.
func (u *SsoBindingUpsertBulk) SetSubject(v string) *SsoBindingUpsertBulk {
return u.Update(func(s *SsoBindingUpsert) {
s.SetSubject(v)
})
}
// UpdateSubject sets the "subject" field to the value that was provided on create.
func (u *SsoBindingUpsertBulk) UpdateSubject() *SsoBindingUpsertBulk {
return u.Update(func(s *SsoBindingUpsert) {
s.UpdateSubject()
})
}
// SetUserID sets the "user_id" field.
func (u *SsoBindingUpsertBulk) SetUserID(v int) *SsoBindingUpsertBulk {
return u.Update(func(s *SsoBindingUpsert) {
s.SetUserID(v)
})
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *SsoBindingUpsertBulk) UpdateUserID() *SsoBindingUpsertBulk {
return u.Update(func(s *SsoBindingUpsert) {
s.UpdateUserID()
})
}
// Exec executes the query.
func (u *SsoBindingUpsertBulk) 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 SsoBindingCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for SsoBindingCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *SsoBindingUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}