Files
MonkeyCode/backend/db/notifysendlog_create.go

858 lines
26 KiB
Go

// Code generated by ent, DO NOT EDIT.
package db
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/chaitin/MonkeyCode/backend/consts"
"github.com/chaitin/MonkeyCode/backend/db/notifysendlog"
"github.com/google/uuid"
)
// NotifySendLogCreate is the builder for creating a NotifySendLog entity.
type NotifySendLogCreate struct {
config
mutation *NotifySendLogMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetSubscriptionID sets the "subscription_id" field.
func (_c *NotifySendLogCreate) SetSubscriptionID(v uuid.UUID) *NotifySendLogCreate {
_c.mutation.SetSubscriptionID(v)
return _c
}
// SetChannelID sets the "channel_id" field.
func (_c *NotifySendLogCreate) SetChannelID(v uuid.UUID) *NotifySendLogCreate {
_c.mutation.SetChannelID(v)
return _c
}
// SetEventType sets the "event_type" field.
func (_c *NotifySendLogCreate) SetEventType(v consts.NotifyEventType) *NotifySendLogCreate {
_c.mutation.SetEventType(v)
return _c
}
// SetEventRefID sets the "event_ref_id" field.
func (_c *NotifySendLogCreate) SetEventRefID(v string) *NotifySendLogCreate {
_c.mutation.SetEventRefID(v)
return _c
}
// SetStatus sets the "status" field.
func (_c *NotifySendLogCreate) SetStatus(v consts.NotifySendStatus) *NotifySendLogCreate {
_c.mutation.SetStatus(v)
return _c
}
// SetError sets the "error" field.
func (_c *NotifySendLogCreate) SetError(v string) *NotifySendLogCreate {
_c.mutation.SetError(v)
return _c
}
// SetNillableError sets the "error" field if the given value is not nil.
func (_c *NotifySendLogCreate) SetNillableError(v *string) *NotifySendLogCreate {
if v != nil {
_c.SetError(*v)
}
return _c
}
// SetCreatedAt sets the "created_at" field.
func (_c *NotifySendLogCreate) SetCreatedAt(v time.Time) *NotifySendLogCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *NotifySendLogCreate) SetNillableCreatedAt(v *time.Time) *NotifySendLogCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// SetID sets the "id" field.
func (_c *NotifySendLogCreate) SetID(v uuid.UUID) *NotifySendLogCreate {
_c.mutation.SetID(v)
return _c
}
// Mutation returns the NotifySendLogMutation object of the builder.
func (_c *NotifySendLogCreate) Mutation() *NotifySendLogMutation {
return _c.mutation
}
// Save creates the NotifySendLog in the database.
func (_c *NotifySendLogCreate) Save(ctx context.Context) (*NotifySendLog, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *NotifySendLogCreate) SaveX(ctx context.Context) *NotifySendLog {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *NotifySendLogCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *NotifySendLogCreate) 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 *NotifySendLogCreate) defaults() {
if _, ok := _c.mutation.Error(); !ok {
v := notifysendlog.DefaultError
_c.mutation.SetError(v)
}
if _, ok := _c.mutation.CreatedAt(); !ok {
v := notifysendlog.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *NotifySendLogCreate) check() error {
if _, ok := _c.mutation.SubscriptionID(); !ok {
return &ValidationError{Name: "subscription_id", err: errors.New(`db: missing required field "NotifySendLog.subscription_id"`)}
}
if _, ok := _c.mutation.ChannelID(); !ok {
return &ValidationError{Name: "channel_id", err: errors.New(`db: missing required field "NotifySendLog.channel_id"`)}
}
if _, ok := _c.mutation.EventType(); !ok {
return &ValidationError{Name: "event_type", err: errors.New(`db: missing required field "NotifySendLog.event_type"`)}
}
if _, ok := _c.mutation.EventRefID(); !ok {
return &ValidationError{Name: "event_ref_id", err: errors.New(`db: missing required field "NotifySendLog.event_ref_id"`)}
}
if _, ok := _c.mutation.Status(); !ok {
return &ValidationError{Name: "status", err: errors.New(`db: missing required field "NotifySendLog.status"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "NotifySendLog.created_at"`)}
}
return nil
}
func (_c *NotifySendLogCreate) sqlSave(ctx context.Context) (*NotifySendLog, 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.(*uuid.UUID); 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 *NotifySendLogCreate) createSpec() (*NotifySendLog, *sqlgraph.CreateSpec) {
var (
_node = &NotifySendLog{config: _c.config}
_spec = sqlgraph.NewCreateSpec(notifysendlog.Table, sqlgraph.NewFieldSpec(notifysendlog.FieldID, field.TypeUUID))
)
_spec.OnConflict = _c.conflict
if id, ok := _c.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = &id
}
if value, ok := _c.mutation.SubscriptionID(); ok {
_spec.SetField(notifysendlog.FieldSubscriptionID, field.TypeUUID, value)
_node.SubscriptionID = value
}
if value, ok := _c.mutation.ChannelID(); ok {
_spec.SetField(notifysendlog.FieldChannelID, field.TypeUUID, value)
_node.ChannelID = value
}
if value, ok := _c.mutation.EventType(); ok {
_spec.SetField(notifysendlog.FieldEventType, field.TypeString, value)
_node.EventType = value
}
if value, ok := _c.mutation.EventRefID(); ok {
_spec.SetField(notifysendlog.FieldEventRefID, field.TypeString, value)
_node.EventRefID = value
}
if value, ok := _c.mutation.Status(); ok {
_spec.SetField(notifysendlog.FieldStatus, field.TypeString, value)
_node.Status = value
}
if value, ok := _c.mutation.Error(); ok {
_spec.SetField(notifysendlog.FieldError, field.TypeString, value)
_node.Error = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(notifysendlog.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.NotifySendLog.Create().
// SetSubscriptionID(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.NotifySendLogUpsert) {
// SetSubscriptionID(v+v).
// }).
// Exec(ctx)
func (_c *NotifySendLogCreate) OnConflict(opts ...sql.ConflictOption) *NotifySendLogUpsertOne {
_c.conflict = opts
return &NotifySendLogUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.NotifySendLog.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *NotifySendLogCreate) OnConflictColumns(columns ...string) *NotifySendLogUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &NotifySendLogUpsertOne{
create: _c,
}
}
type (
// NotifySendLogUpsertOne is the builder for "upsert"-ing
// one NotifySendLog node.
NotifySendLogUpsertOne struct {
create *NotifySendLogCreate
}
// NotifySendLogUpsert is the "OnConflict" setter.
NotifySendLogUpsert struct {
*sql.UpdateSet
}
)
// SetSubscriptionID sets the "subscription_id" field.
func (u *NotifySendLogUpsert) SetSubscriptionID(v uuid.UUID) *NotifySendLogUpsert {
u.Set(notifysendlog.FieldSubscriptionID, v)
return u
}
// UpdateSubscriptionID sets the "subscription_id" field to the value that was provided on create.
func (u *NotifySendLogUpsert) UpdateSubscriptionID() *NotifySendLogUpsert {
u.SetExcluded(notifysendlog.FieldSubscriptionID)
return u
}
// SetChannelID sets the "channel_id" field.
func (u *NotifySendLogUpsert) SetChannelID(v uuid.UUID) *NotifySendLogUpsert {
u.Set(notifysendlog.FieldChannelID, v)
return u
}
// UpdateChannelID sets the "channel_id" field to the value that was provided on create.
func (u *NotifySendLogUpsert) UpdateChannelID() *NotifySendLogUpsert {
u.SetExcluded(notifysendlog.FieldChannelID)
return u
}
// SetEventType sets the "event_type" field.
func (u *NotifySendLogUpsert) SetEventType(v consts.NotifyEventType) *NotifySendLogUpsert {
u.Set(notifysendlog.FieldEventType, v)
return u
}
// UpdateEventType sets the "event_type" field to the value that was provided on create.
func (u *NotifySendLogUpsert) UpdateEventType() *NotifySendLogUpsert {
u.SetExcluded(notifysendlog.FieldEventType)
return u
}
// SetEventRefID sets the "event_ref_id" field.
func (u *NotifySendLogUpsert) SetEventRefID(v string) *NotifySendLogUpsert {
u.Set(notifysendlog.FieldEventRefID, v)
return u
}
// UpdateEventRefID sets the "event_ref_id" field to the value that was provided on create.
func (u *NotifySendLogUpsert) UpdateEventRefID() *NotifySendLogUpsert {
u.SetExcluded(notifysendlog.FieldEventRefID)
return u
}
// SetStatus sets the "status" field.
func (u *NotifySendLogUpsert) SetStatus(v consts.NotifySendStatus) *NotifySendLogUpsert {
u.Set(notifysendlog.FieldStatus, v)
return u
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *NotifySendLogUpsert) UpdateStatus() *NotifySendLogUpsert {
u.SetExcluded(notifysendlog.FieldStatus)
return u
}
// SetError sets the "error" field.
func (u *NotifySendLogUpsert) SetError(v string) *NotifySendLogUpsert {
u.Set(notifysendlog.FieldError, v)
return u
}
// UpdateError sets the "error" field to the value that was provided on create.
func (u *NotifySendLogUpsert) UpdateError() *NotifySendLogUpsert {
u.SetExcluded(notifysendlog.FieldError)
return u
}
// ClearError clears the value of the "error" field.
func (u *NotifySendLogUpsert) ClearError() *NotifySendLogUpsert {
u.SetNull(notifysendlog.FieldError)
return u
}
// SetCreatedAt sets the "created_at" field.
func (u *NotifySendLogUpsert) SetCreatedAt(v time.Time) *NotifySendLogUpsert {
u.Set(notifysendlog.FieldCreatedAt, v)
return u
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *NotifySendLogUpsert) UpdateCreatedAt() *NotifySendLogUpsert {
u.SetExcluded(notifysendlog.FieldCreatedAt)
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.NotifySendLog.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// sql.ResolveWith(func(u *sql.UpdateSet) {
// u.SetIgnore(notifysendlog.FieldID)
// }),
// ).
// Exec(ctx)
func (u *NotifySendLogUpsertOne) UpdateNewValues() *NotifySendLogUpsertOne {
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(notifysendlog.FieldID)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.NotifySendLog.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *NotifySendLogUpsertOne) Ignore() *NotifySendLogUpsertOne {
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 *NotifySendLogUpsertOne) DoNothing() *NotifySendLogUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the NotifySendLogCreate.OnConflict
// documentation for more info.
func (u *NotifySendLogUpsertOne) Update(set func(*NotifySendLogUpsert)) *NotifySendLogUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&NotifySendLogUpsert{UpdateSet: update})
}))
return u
}
// SetSubscriptionID sets the "subscription_id" field.
func (u *NotifySendLogUpsertOne) SetSubscriptionID(v uuid.UUID) *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetSubscriptionID(v)
})
}
// UpdateSubscriptionID sets the "subscription_id" field to the value that was provided on create.
func (u *NotifySendLogUpsertOne) UpdateSubscriptionID() *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateSubscriptionID()
})
}
// SetChannelID sets the "channel_id" field.
func (u *NotifySendLogUpsertOne) SetChannelID(v uuid.UUID) *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetChannelID(v)
})
}
// UpdateChannelID sets the "channel_id" field to the value that was provided on create.
func (u *NotifySendLogUpsertOne) UpdateChannelID() *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateChannelID()
})
}
// SetEventType sets the "event_type" field.
func (u *NotifySendLogUpsertOne) SetEventType(v consts.NotifyEventType) *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetEventType(v)
})
}
// UpdateEventType sets the "event_type" field to the value that was provided on create.
func (u *NotifySendLogUpsertOne) UpdateEventType() *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateEventType()
})
}
// SetEventRefID sets the "event_ref_id" field.
func (u *NotifySendLogUpsertOne) SetEventRefID(v string) *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetEventRefID(v)
})
}
// UpdateEventRefID sets the "event_ref_id" field to the value that was provided on create.
func (u *NotifySendLogUpsertOne) UpdateEventRefID() *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateEventRefID()
})
}
// SetStatus sets the "status" field.
func (u *NotifySendLogUpsertOne) SetStatus(v consts.NotifySendStatus) *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *NotifySendLogUpsertOne) UpdateStatus() *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateStatus()
})
}
// SetError sets the "error" field.
func (u *NotifySendLogUpsertOne) SetError(v string) *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetError(v)
})
}
// UpdateError sets the "error" field to the value that was provided on create.
func (u *NotifySendLogUpsertOne) UpdateError() *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateError()
})
}
// ClearError clears the value of the "error" field.
func (u *NotifySendLogUpsertOne) ClearError() *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.ClearError()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *NotifySendLogUpsertOne) SetCreatedAt(v time.Time) *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *NotifySendLogUpsertOne) UpdateCreatedAt() *NotifySendLogUpsertOne {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateCreatedAt()
})
}
// Exec executes the query.
func (u *NotifySendLogUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("db: missing options for NotifySendLogCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *NotifySendLogUpsertOne) 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 *NotifySendLogUpsertOne) 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("db: NotifySendLogUpsertOne.ID is not supported by MySQL driver. Use NotifySendLogUpsertOne.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 *NotifySendLogUpsertOne) IDX(ctx context.Context) uuid.UUID {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// NotifySendLogCreateBulk is the builder for creating many NotifySendLog entities in bulk.
type NotifySendLogCreateBulk struct {
config
err error
builders []*NotifySendLogCreate
conflict []sql.ConflictOption
}
// Save creates the NotifySendLog entities in the database.
func (_c *NotifySendLogCreateBulk) Save(ctx context.Context) ([]*NotifySendLog, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*NotifySendLog, 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.(*NotifySendLogMutation)
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 *NotifySendLogCreateBulk) SaveX(ctx context.Context) []*NotifySendLog {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *NotifySendLogCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *NotifySendLogCreateBulk) 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.NotifySendLog.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.NotifySendLogUpsert) {
// SetSubscriptionID(v+v).
// }).
// Exec(ctx)
func (_c *NotifySendLogCreateBulk) OnConflict(opts ...sql.ConflictOption) *NotifySendLogUpsertBulk {
_c.conflict = opts
return &NotifySendLogUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.NotifySendLog.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *NotifySendLogCreateBulk) OnConflictColumns(columns ...string) *NotifySendLogUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &NotifySendLogUpsertBulk{
create: _c,
}
}
// NotifySendLogUpsertBulk is the builder for "upsert"-ing
// a bulk of NotifySendLog nodes.
type NotifySendLogUpsertBulk struct {
create *NotifySendLogCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.NotifySendLog.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// sql.ResolveWith(func(u *sql.UpdateSet) {
// u.SetIgnore(notifysendlog.FieldID)
// }),
// ).
// Exec(ctx)
func (u *NotifySendLogUpsertBulk) UpdateNewValues() *NotifySendLogUpsertBulk {
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(notifysendlog.FieldID)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.NotifySendLog.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *NotifySendLogUpsertBulk) Ignore() *NotifySendLogUpsertBulk {
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 *NotifySendLogUpsertBulk) DoNothing() *NotifySendLogUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the NotifySendLogCreateBulk.OnConflict
// documentation for more info.
func (u *NotifySendLogUpsertBulk) Update(set func(*NotifySendLogUpsert)) *NotifySendLogUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&NotifySendLogUpsert{UpdateSet: update})
}))
return u
}
// SetSubscriptionID sets the "subscription_id" field.
func (u *NotifySendLogUpsertBulk) SetSubscriptionID(v uuid.UUID) *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetSubscriptionID(v)
})
}
// UpdateSubscriptionID sets the "subscription_id" field to the value that was provided on create.
func (u *NotifySendLogUpsertBulk) UpdateSubscriptionID() *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateSubscriptionID()
})
}
// SetChannelID sets the "channel_id" field.
func (u *NotifySendLogUpsertBulk) SetChannelID(v uuid.UUID) *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetChannelID(v)
})
}
// UpdateChannelID sets the "channel_id" field to the value that was provided on create.
func (u *NotifySendLogUpsertBulk) UpdateChannelID() *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateChannelID()
})
}
// SetEventType sets the "event_type" field.
func (u *NotifySendLogUpsertBulk) SetEventType(v consts.NotifyEventType) *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetEventType(v)
})
}
// UpdateEventType sets the "event_type" field to the value that was provided on create.
func (u *NotifySendLogUpsertBulk) UpdateEventType() *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateEventType()
})
}
// SetEventRefID sets the "event_ref_id" field.
func (u *NotifySendLogUpsertBulk) SetEventRefID(v string) *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetEventRefID(v)
})
}
// UpdateEventRefID sets the "event_ref_id" field to the value that was provided on create.
func (u *NotifySendLogUpsertBulk) UpdateEventRefID() *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateEventRefID()
})
}
// SetStatus sets the "status" field.
func (u *NotifySendLogUpsertBulk) SetStatus(v consts.NotifySendStatus) *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *NotifySendLogUpsertBulk) UpdateStatus() *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateStatus()
})
}
// SetError sets the "error" field.
func (u *NotifySendLogUpsertBulk) SetError(v string) *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetError(v)
})
}
// UpdateError sets the "error" field to the value that was provided on create.
func (u *NotifySendLogUpsertBulk) UpdateError() *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateError()
})
}
// ClearError clears the value of the "error" field.
func (u *NotifySendLogUpsertBulk) ClearError() *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.ClearError()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *NotifySendLogUpsertBulk) SetCreatedAt(v time.Time) *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.SetCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *NotifySendLogUpsertBulk) UpdateCreatedAt() *NotifySendLogUpsertBulk {
return u.Update(func(s *NotifySendLogUpsert) {
s.UpdateCreatedAt()
})
}
// Exec executes the query.
func (u *NotifySendLogUpsertBulk) 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("db: OnConflict was set for builder %d. Set it on the NotifySendLogCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("db: missing options for NotifySendLogCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *NotifySendLogUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}