invitation_create.go•24.7 kB
// 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/Southclaws/storyden/internal/ent/account"
"github.com/Southclaws/storyden/internal/ent/invitation"
"github.com/rs/xid"
)
// InvitationCreate is the builder for creating a Invitation entity.
type InvitationCreate struct {
config
mutation *InvitationMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetCreatedAt sets the "created_at" field.
func (_c *InvitationCreate) SetCreatedAt(v time.Time) *InvitationCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *InvitationCreate) SetNillableCreatedAt(v *time.Time) *InvitationCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// SetUpdatedAt sets the "updated_at" field.
func (_c *InvitationCreate) SetUpdatedAt(v time.Time) *InvitationCreate {
_c.mutation.SetUpdatedAt(v)
return _c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *InvitationCreate) SetNillableUpdatedAt(v *time.Time) *InvitationCreate {
if v != nil {
_c.SetUpdatedAt(*v)
}
return _c
}
// SetDeletedAt sets the "deleted_at" field.
func (_c *InvitationCreate) SetDeletedAt(v time.Time) *InvitationCreate {
_c.mutation.SetDeletedAt(v)
return _c
}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_c *InvitationCreate) SetNillableDeletedAt(v *time.Time) *InvitationCreate {
if v != nil {
_c.SetDeletedAt(*v)
}
return _c
}
// SetMessage sets the "message" field.
func (_c *InvitationCreate) SetMessage(v string) *InvitationCreate {
_c.mutation.SetMessage(v)
return _c
}
// SetNillableMessage sets the "message" field if the given value is not nil.
func (_c *InvitationCreate) SetNillableMessage(v *string) *InvitationCreate {
if v != nil {
_c.SetMessage(*v)
}
return _c
}
// SetCreatorAccountID sets the "creator_account_id" field.
func (_c *InvitationCreate) SetCreatorAccountID(v xid.ID) *InvitationCreate {
_c.mutation.SetCreatorAccountID(v)
return _c
}
// SetID sets the "id" field.
func (_c *InvitationCreate) SetID(v xid.ID) *InvitationCreate {
_c.mutation.SetID(v)
return _c
}
// SetNillableID sets the "id" field if the given value is not nil.
func (_c *InvitationCreate) SetNillableID(v *xid.ID) *InvitationCreate {
if v != nil {
_c.SetID(*v)
}
return _c
}
// SetCreatorID sets the "creator" edge to the Account entity by ID.
func (_c *InvitationCreate) SetCreatorID(id xid.ID) *InvitationCreate {
_c.mutation.SetCreatorID(id)
return _c
}
// SetCreator sets the "creator" edge to the Account entity.
func (_c *InvitationCreate) SetCreator(v *Account) *InvitationCreate {
return _c.SetCreatorID(v.ID)
}
// AddInvitedIDs adds the "invited" edge to the Account entity by IDs.
func (_c *InvitationCreate) AddInvitedIDs(ids ...xid.ID) *InvitationCreate {
_c.mutation.AddInvitedIDs(ids...)
return _c
}
// AddInvited adds the "invited" edges to the Account entity.
func (_c *InvitationCreate) AddInvited(v ...*Account) *InvitationCreate {
ids := make([]xid.ID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddInvitedIDs(ids...)
}
// Mutation returns the InvitationMutation object of the builder.
func (_c *InvitationCreate) Mutation() *InvitationMutation {
return _c.mutation
}
// Save creates the Invitation in the database.
func (_c *InvitationCreate) Save(ctx context.Context) (*Invitation, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *InvitationCreate) SaveX(ctx context.Context) *Invitation {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *InvitationCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *InvitationCreate) 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 *InvitationCreate) defaults() {
if _, ok := _c.mutation.CreatedAt(); !ok {
v := invitation.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
v := invitation.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
if _, ok := _c.mutation.ID(); !ok {
v := invitation.DefaultID()
_c.mutation.SetID(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *InvitationCreate) check() error {
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Invitation.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Invitation.updated_at"`)}
}
if _, ok := _c.mutation.CreatorAccountID(); !ok {
return &ValidationError{Name: "creator_account_id", err: errors.New(`ent: missing required field "Invitation.creator_account_id"`)}
}
if v, ok := _c.mutation.ID(); ok {
if err := invitation.IDValidator(v.String()); err != nil {
return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Invitation.id": %w`, err)}
}
}
if len(_c.mutation.CreatorIDs()) == 0 {
return &ValidationError{Name: "creator", err: errors.New(`ent: missing required edge "Invitation.creator"`)}
}
return nil
}
func (_c *InvitationCreate) sqlSave(ctx context.Context) (*Invitation, 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 != nil {
if id, ok := _spec.ID.Value.(*xid.ID); ok {
_node.ID = *id
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
return nil, err
}
}
_c.mutation.id = &_node.ID
_c.mutation.done = true
return _node, nil
}
func (_c *InvitationCreate) createSpec() (*Invitation, *sqlgraph.CreateSpec) {
var (
_node = &Invitation{config: _c.config}
_spec = sqlgraph.NewCreateSpec(invitation.Table, sqlgraph.NewFieldSpec(invitation.FieldID, field.TypeString))
)
_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(invitation.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.UpdatedAt(); ok {
_spec.SetField(invitation.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := _c.mutation.DeletedAt(); ok {
_spec.SetField(invitation.FieldDeletedAt, field.TypeTime, value)
_node.DeletedAt = &value
}
if value, ok := _c.mutation.Message(); ok {
_spec.SetField(invitation.FieldMessage, field.TypeString, value)
_node.Message = &value
}
if nodes := _c.mutation.CreatorIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: invitation.CreatorTable,
Columns: []string{invitation.CreatorColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.CreatorAccountID = nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.InvitedIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: invitation.InvitedTable,
Columns: []string{invitation.InvitedColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_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.Invitation.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.InvitationUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (_c *InvitationCreate) OnConflict(opts ...sql.ConflictOption) *InvitationUpsertOne {
_c.conflict = opts
return &InvitationUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.Invitation.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *InvitationCreate) OnConflictColumns(columns ...string) *InvitationUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &InvitationUpsertOne{
create: _c,
}
}
type (
// InvitationUpsertOne is the builder for "upsert"-ing
// one Invitation node.
InvitationUpsertOne struct {
create *InvitationCreate
}
// InvitationUpsert is the "OnConflict" setter.
InvitationUpsert struct {
*sql.UpdateSet
}
)
// SetUpdatedAt sets the "updated_at" field.
func (u *InvitationUpsert) SetUpdatedAt(v time.Time) *InvitationUpsert {
u.Set(invitation.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *InvitationUpsert) UpdateUpdatedAt() *InvitationUpsert {
u.SetExcluded(invitation.FieldUpdatedAt)
return u
}
// SetDeletedAt sets the "deleted_at" field.
func (u *InvitationUpsert) SetDeletedAt(v time.Time) *InvitationUpsert {
u.Set(invitation.FieldDeletedAt, v)
return u
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *InvitationUpsert) UpdateDeletedAt() *InvitationUpsert {
u.SetExcluded(invitation.FieldDeletedAt)
return u
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *InvitationUpsert) ClearDeletedAt() *InvitationUpsert {
u.SetNull(invitation.FieldDeletedAt)
return u
}
// SetMessage sets the "message" field.
func (u *InvitationUpsert) SetMessage(v string) *InvitationUpsert {
u.Set(invitation.FieldMessage, v)
return u
}
// UpdateMessage sets the "message" field to the value that was provided on create.
func (u *InvitationUpsert) UpdateMessage() *InvitationUpsert {
u.SetExcluded(invitation.FieldMessage)
return u
}
// ClearMessage clears the value of the "message" field.
func (u *InvitationUpsert) ClearMessage() *InvitationUpsert {
u.SetNull(invitation.FieldMessage)
return u
}
// SetCreatorAccountID sets the "creator_account_id" field.
func (u *InvitationUpsert) SetCreatorAccountID(v xid.ID) *InvitationUpsert {
u.Set(invitation.FieldCreatorAccountID, v)
return u
}
// UpdateCreatorAccountID sets the "creator_account_id" field to the value that was provided on create.
func (u *InvitationUpsert) UpdateCreatorAccountID() *InvitationUpsert {
u.SetExcluded(invitation.FieldCreatorAccountID)
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.Invitation.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// sql.ResolveWith(func(u *sql.UpdateSet) {
// u.SetIgnore(invitation.FieldID)
// }),
// ).
// Exec(ctx)
func (u *InvitationUpsertOne) UpdateNewValues() *InvitationUpsertOne {
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(invitation.FieldID)
}
if _, exists := u.create.mutation.CreatedAt(); exists {
s.SetIgnore(invitation.FieldCreatedAt)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.Invitation.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *InvitationUpsertOne) Ignore() *InvitationUpsertOne {
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 *InvitationUpsertOne) DoNothing() *InvitationUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the InvitationCreate.OnConflict
// documentation for more info.
func (u *InvitationUpsertOne) Update(set func(*InvitationUpsert)) *InvitationUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&InvitationUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *InvitationUpsertOne) SetUpdatedAt(v time.Time) *InvitationUpsertOne {
return u.Update(func(s *InvitationUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *InvitationUpsertOne) UpdateUpdatedAt() *InvitationUpsertOne {
return u.Update(func(s *InvitationUpsert) {
s.UpdateUpdatedAt()
})
}
// SetDeletedAt sets the "deleted_at" field.
func (u *InvitationUpsertOne) SetDeletedAt(v time.Time) *InvitationUpsertOne {
return u.Update(func(s *InvitationUpsert) {
s.SetDeletedAt(v)
})
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *InvitationUpsertOne) UpdateDeletedAt() *InvitationUpsertOne {
return u.Update(func(s *InvitationUpsert) {
s.UpdateDeletedAt()
})
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *InvitationUpsertOne) ClearDeletedAt() *InvitationUpsertOne {
return u.Update(func(s *InvitationUpsert) {
s.ClearDeletedAt()
})
}
// SetMessage sets the "message" field.
func (u *InvitationUpsertOne) SetMessage(v string) *InvitationUpsertOne {
return u.Update(func(s *InvitationUpsert) {
s.SetMessage(v)
})
}
// UpdateMessage sets the "message" field to the value that was provided on create.
func (u *InvitationUpsertOne) UpdateMessage() *InvitationUpsertOne {
return u.Update(func(s *InvitationUpsert) {
s.UpdateMessage()
})
}
// ClearMessage clears the value of the "message" field.
func (u *InvitationUpsertOne) ClearMessage() *InvitationUpsertOne {
return u.Update(func(s *InvitationUpsert) {
s.ClearMessage()
})
}
// SetCreatorAccountID sets the "creator_account_id" field.
func (u *InvitationUpsertOne) SetCreatorAccountID(v xid.ID) *InvitationUpsertOne {
return u.Update(func(s *InvitationUpsert) {
s.SetCreatorAccountID(v)
})
}
// UpdateCreatorAccountID sets the "creator_account_id" field to the value that was provided on create.
func (u *InvitationUpsertOne) UpdateCreatorAccountID() *InvitationUpsertOne {
return u.Update(func(s *InvitationUpsert) {
s.UpdateCreatorAccountID()
})
}
// Exec executes the query.
func (u *InvitationUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for InvitationCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *InvitationUpsertOne) 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 *InvitationUpsertOne) ID(ctx context.Context) (id xid.ID, 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: InvitationUpsertOne.ID is not supported by MySQL driver. Use InvitationUpsertOne.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 *InvitationUpsertOne) IDX(ctx context.Context) xid.ID {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// InvitationCreateBulk is the builder for creating many Invitation entities in bulk.
type InvitationCreateBulk struct {
config
err error
builders []*InvitationCreate
conflict []sql.ConflictOption
}
// Save creates the Invitation entities in the database.
func (_c *InvitationCreateBulk) Save(ctx context.Context) ([]*Invitation, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*Invitation, 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.(*InvitationMutation)
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
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 *InvitationCreateBulk) SaveX(ctx context.Context) []*Invitation {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *InvitationCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *InvitationCreateBulk) 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.Invitation.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.InvitationUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (_c *InvitationCreateBulk) OnConflict(opts ...sql.ConflictOption) *InvitationUpsertBulk {
_c.conflict = opts
return &InvitationUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.Invitation.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *InvitationCreateBulk) OnConflictColumns(columns ...string) *InvitationUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &InvitationUpsertBulk{
create: _c,
}
}
// InvitationUpsertBulk is the builder for "upsert"-ing
// a bulk of Invitation nodes.
type InvitationUpsertBulk struct {
create *InvitationCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.Invitation.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// sql.ResolveWith(func(u *sql.UpdateSet) {
// u.SetIgnore(invitation.FieldID)
// }),
// ).
// Exec(ctx)
func (u *InvitationUpsertBulk) UpdateNewValues() *InvitationUpsertBulk {
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(invitation.FieldID)
}
if _, exists := b.mutation.CreatedAt(); exists {
s.SetIgnore(invitation.FieldCreatedAt)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.Invitation.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *InvitationUpsertBulk) Ignore() *InvitationUpsertBulk {
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 *InvitationUpsertBulk) DoNothing() *InvitationUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the InvitationCreateBulk.OnConflict
// documentation for more info.
func (u *InvitationUpsertBulk) Update(set func(*InvitationUpsert)) *InvitationUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&InvitationUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *InvitationUpsertBulk) SetUpdatedAt(v time.Time) *InvitationUpsertBulk {
return u.Update(func(s *InvitationUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *InvitationUpsertBulk) UpdateUpdatedAt() *InvitationUpsertBulk {
return u.Update(func(s *InvitationUpsert) {
s.UpdateUpdatedAt()
})
}
// SetDeletedAt sets the "deleted_at" field.
func (u *InvitationUpsertBulk) SetDeletedAt(v time.Time) *InvitationUpsertBulk {
return u.Update(func(s *InvitationUpsert) {
s.SetDeletedAt(v)
})
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *InvitationUpsertBulk) UpdateDeletedAt() *InvitationUpsertBulk {
return u.Update(func(s *InvitationUpsert) {
s.UpdateDeletedAt()
})
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *InvitationUpsertBulk) ClearDeletedAt() *InvitationUpsertBulk {
return u.Update(func(s *InvitationUpsert) {
s.ClearDeletedAt()
})
}
// SetMessage sets the "message" field.
func (u *InvitationUpsertBulk) SetMessage(v string) *InvitationUpsertBulk {
return u.Update(func(s *InvitationUpsert) {
s.SetMessage(v)
})
}
// UpdateMessage sets the "message" field to the value that was provided on create.
func (u *InvitationUpsertBulk) UpdateMessage() *InvitationUpsertBulk {
return u.Update(func(s *InvitationUpsert) {
s.UpdateMessage()
})
}
// ClearMessage clears the value of the "message" field.
func (u *InvitationUpsertBulk) ClearMessage() *InvitationUpsertBulk {
return u.Update(func(s *InvitationUpsert) {
s.ClearMessage()
})
}
// SetCreatorAccountID sets the "creator_account_id" field.
func (u *InvitationUpsertBulk) SetCreatorAccountID(v xid.ID) *InvitationUpsertBulk {
return u.Update(func(s *InvitationUpsert) {
s.SetCreatorAccountID(v)
})
}
// UpdateCreatorAccountID sets the "creator_account_id" field to the value that was provided on create.
func (u *InvitationUpsertBulk) UpdateCreatorAccountID() *InvitationUpsertBulk {
return u.Update(func(s *InvitationUpsert) {
s.UpdateCreatorAccountID()
})
}
// Exec executes the query.
func (u *InvitationUpsertBulk) 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 InvitationCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for InvitationCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *InvitationUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}