mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
1199 lines
36 KiB
Go
1199 lines
36 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/notifychannel"
|
|
"github.com/chaitin/MonkeyCode/backend/db/notifysubscription"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// NotifyChannelCreate is the builder for creating a NotifyChannel entity.
|
|
type NotifyChannelCreate struct {
|
|
config
|
|
mutation *NotifyChannelMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_c *NotifyChannelCreate) SetDeletedAt(v time.Time) *NotifyChannelCreate {
|
|
_c.mutation.SetDeletedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_c *NotifyChannelCreate) SetNillableDeletedAt(v *time.Time) *NotifyChannelCreate {
|
|
if v != nil {
|
|
_c.SetDeletedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetOwnerID sets the "owner_id" field.
|
|
func (_c *NotifyChannelCreate) SetOwnerID(v uuid.UUID) *NotifyChannelCreate {
|
|
_c.mutation.SetOwnerID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetOwnerType sets the "owner_type" field.
|
|
func (_c *NotifyChannelCreate) SetOwnerType(v consts.NotifyOwnerType) *NotifyChannelCreate {
|
|
_c.mutation.SetOwnerType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableOwnerType sets the "owner_type" field if the given value is not nil.
|
|
func (_c *NotifyChannelCreate) SetNillableOwnerType(v *consts.NotifyOwnerType) *NotifyChannelCreate {
|
|
if v != nil {
|
|
_c.SetOwnerType(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_c *NotifyChannelCreate) SetName(v string) *NotifyChannelCreate {
|
|
_c.mutation.SetName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetKind sets the "kind" field.
|
|
func (_c *NotifyChannelCreate) SetKind(v consts.NotifyChannelKind) *NotifyChannelCreate {
|
|
_c.mutation.SetKind(v)
|
|
return _c
|
|
}
|
|
|
|
// SetWebhookURL sets the "webhook_url" field.
|
|
func (_c *NotifyChannelCreate) SetWebhookURL(v string) *NotifyChannelCreate {
|
|
_c.mutation.SetWebhookURL(v)
|
|
return _c
|
|
}
|
|
|
|
// SetSecret sets the "secret" field.
|
|
func (_c *NotifyChannelCreate) SetSecret(v string) *NotifyChannelCreate {
|
|
_c.mutation.SetSecret(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableSecret sets the "secret" field if the given value is not nil.
|
|
func (_c *NotifyChannelCreate) SetNillableSecret(v *string) *NotifyChannelCreate {
|
|
if v != nil {
|
|
_c.SetSecret(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetHeaders sets the "headers" field.
|
|
func (_c *NotifyChannelCreate) SetHeaders(v map[string]string) *NotifyChannelCreate {
|
|
_c.mutation.SetHeaders(v)
|
|
return _c
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (_c *NotifyChannelCreate) SetEnabled(v bool) *NotifyChannelCreate {
|
|
_c.mutation.SetEnabled(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
|
|
func (_c *NotifyChannelCreate) SetNillableEnabled(v *bool) *NotifyChannelCreate {
|
|
if v != nil {
|
|
_c.SetEnabled(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *NotifyChannelCreate) SetCreatedAt(v time.Time) *NotifyChannelCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *NotifyChannelCreate) SetNillableCreatedAt(v *time.Time) *NotifyChannelCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *NotifyChannelCreate) SetUpdatedAt(v time.Time) *NotifyChannelCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *NotifyChannelCreate) SetNillableUpdatedAt(v *time.Time) *NotifyChannelCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *NotifyChannelCreate) SetID(v uuid.UUID) *NotifyChannelCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// AddSubscriptionIDs adds the "subscriptions" edge to the NotifySubscription entity by IDs.
|
|
func (_c *NotifyChannelCreate) AddSubscriptionIDs(ids ...uuid.UUID) *NotifyChannelCreate {
|
|
_c.mutation.AddSubscriptionIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddSubscriptions adds the "subscriptions" edges to the NotifySubscription entity.
|
|
func (_c *NotifyChannelCreate) AddSubscriptions(v ...*NotifySubscription) *NotifyChannelCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddSubscriptionIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the NotifyChannelMutation object of the builder.
|
|
func (_c *NotifyChannelCreate) Mutation() *NotifyChannelMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the NotifyChannel in the database.
|
|
func (_c *NotifyChannelCreate) Save(ctx context.Context) (*NotifyChannel, error) {
|
|
if err := _c.defaults(); err != nil {
|
|
return nil, err
|
|
}
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *NotifyChannelCreate) SaveX(ctx context.Context) *NotifyChannel {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *NotifyChannelCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *NotifyChannelCreate) 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 *NotifyChannelCreate) defaults() error {
|
|
if _, ok := _c.mutation.OwnerType(); !ok {
|
|
v := notifychannel.DefaultOwnerType
|
|
_c.mutation.SetOwnerType(v)
|
|
}
|
|
if _, ok := _c.mutation.Secret(); !ok {
|
|
v := notifychannel.DefaultSecret
|
|
_c.mutation.SetSecret(v)
|
|
}
|
|
if _, ok := _c.mutation.Enabled(); !ok {
|
|
v := notifychannel.DefaultEnabled
|
|
_c.mutation.SetEnabled(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
if notifychannel.DefaultCreatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized notifychannel.DefaultCreatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := notifychannel.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
if notifychannel.DefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized notifychannel.DefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := notifychannel.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *NotifyChannelCreate) check() error {
|
|
if _, ok := _c.mutation.OwnerID(); !ok {
|
|
return &ValidationError{Name: "owner_id", err: errors.New(`db: missing required field "NotifyChannel.owner_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.OwnerType(); !ok {
|
|
return &ValidationError{Name: "owner_type", err: errors.New(`db: missing required field "NotifyChannel.owner_type"`)}
|
|
}
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
return &ValidationError{Name: "name", err: errors.New(`db: missing required field "NotifyChannel.name"`)}
|
|
}
|
|
if v, ok := _c.mutation.Name(); ok {
|
|
if err := notifychannel.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "NotifyChannel.name": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Kind(); !ok {
|
|
return &ValidationError{Name: "kind", err: errors.New(`db: missing required field "NotifyChannel.kind"`)}
|
|
}
|
|
if _, ok := _c.mutation.WebhookURL(); !ok {
|
|
return &ValidationError{Name: "webhook_url", err: errors.New(`db: missing required field "NotifyChannel.webhook_url"`)}
|
|
}
|
|
if v, ok := _c.mutation.WebhookURL(); ok {
|
|
if err := notifychannel.WebhookURLValidator(v); err != nil {
|
|
return &ValidationError{Name: "webhook_url", err: fmt.Errorf(`db: validator failed for field "NotifyChannel.webhook_url": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Enabled(); !ok {
|
|
return &ValidationError{Name: "enabled", err: errors.New(`db: missing required field "NotifyChannel.enabled"`)}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "NotifyChannel.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "NotifyChannel.updated_at"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *NotifyChannelCreate) sqlSave(ctx context.Context) (*NotifyChannel, 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 *NotifyChannelCreate) createSpec() (*NotifyChannel, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &NotifyChannel{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(notifychannel.Table, sqlgraph.NewFieldSpec(notifychannel.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.DeletedAt(); ok {
|
|
_spec.SetField(notifychannel.FieldDeletedAt, field.TypeTime, value)
|
|
_node.DeletedAt = value
|
|
}
|
|
if value, ok := _c.mutation.OwnerID(); ok {
|
|
_spec.SetField(notifychannel.FieldOwnerID, field.TypeUUID, value)
|
|
_node.OwnerID = value
|
|
}
|
|
if value, ok := _c.mutation.OwnerType(); ok {
|
|
_spec.SetField(notifychannel.FieldOwnerType, field.TypeString, value)
|
|
_node.OwnerType = value
|
|
}
|
|
if value, ok := _c.mutation.Name(); ok {
|
|
_spec.SetField(notifychannel.FieldName, field.TypeString, value)
|
|
_node.Name = value
|
|
}
|
|
if value, ok := _c.mutation.Kind(); ok {
|
|
_spec.SetField(notifychannel.FieldKind, field.TypeString, value)
|
|
_node.Kind = value
|
|
}
|
|
if value, ok := _c.mutation.WebhookURL(); ok {
|
|
_spec.SetField(notifychannel.FieldWebhookURL, field.TypeString, value)
|
|
_node.WebhookURL = value
|
|
}
|
|
if value, ok := _c.mutation.Secret(); ok {
|
|
_spec.SetField(notifychannel.FieldSecret, field.TypeString, value)
|
|
_node.Secret = value
|
|
}
|
|
if value, ok := _c.mutation.Headers(); ok {
|
|
_spec.SetField(notifychannel.FieldHeaders, field.TypeJSON, value)
|
|
_node.Headers = value
|
|
}
|
|
if value, ok := _c.mutation.Enabled(); ok {
|
|
_spec.SetField(notifychannel.FieldEnabled, field.TypeBool, value)
|
|
_node.Enabled = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(notifychannel.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(notifychannel.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if nodes := _c.mutation.SubscriptionsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: notifychannel.SubscriptionsTable,
|
|
Columns: []string{notifychannel.SubscriptionsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(notifysubscription.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
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.NotifyChannel.Create().
|
|
// SetDeletedAt(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.NotifyChannelUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *NotifyChannelCreate) OnConflict(opts ...sql.ConflictOption) *NotifyChannelUpsertOne {
|
|
_c.conflict = opts
|
|
return &NotifyChannelUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.NotifyChannel.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *NotifyChannelCreate) OnConflictColumns(columns ...string) *NotifyChannelUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &NotifyChannelUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// NotifyChannelUpsertOne is the builder for "upsert"-ing
|
|
// one NotifyChannel node.
|
|
NotifyChannelUpsertOne struct {
|
|
create *NotifyChannelCreate
|
|
}
|
|
|
|
// NotifyChannelUpsert is the "OnConflict" setter.
|
|
NotifyChannelUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *NotifyChannelUpsert) SetDeletedAt(v time.Time) *NotifyChannelUpsert {
|
|
u.Set(notifychannel.FieldDeletedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsert) UpdateDeletedAt() *NotifyChannelUpsert {
|
|
u.SetExcluded(notifychannel.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *NotifyChannelUpsert) ClearDeletedAt() *NotifyChannelUpsert {
|
|
u.SetNull(notifychannel.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// SetOwnerID sets the "owner_id" field.
|
|
func (u *NotifyChannelUpsert) SetOwnerID(v uuid.UUID) *NotifyChannelUpsert {
|
|
u.Set(notifychannel.FieldOwnerID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateOwnerID sets the "owner_id" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsert) UpdateOwnerID() *NotifyChannelUpsert {
|
|
u.SetExcluded(notifychannel.FieldOwnerID)
|
|
return u
|
|
}
|
|
|
|
// SetOwnerType sets the "owner_type" field.
|
|
func (u *NotifyChannelUpsert) SetOwnerType(v consts.NotifyOwnerType) *NotifyChannelUpsert {
|
|
u.Set(notifychannel.FieldOwnerType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateOwnerType sets the "owner_type" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsert) UpdateOwnerType() *NotifyChannelUpsert {
|
|
u.SetExcluded(notifychannel.FieldOwnerType)
|
|
return u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *NotifyChannelUpsert) SetName(v string) *NotifyChannelUpsert {
|
|
u.Set(notifychannel.FieldName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsert) UpdateName() *NotifyChannelUpsert {
|
|
u.SetExcluded(notifychannel.FieldName)
|
|
return u
|
|
}
|
|
|
|
// SetKind sets the "kind" field.
|
|
func (u *NotifyChannelUpsert) SetKind(v consts.NotifyChannelKind) *NotifyChannelUpsert {
|
|
u.Set(notifychannel.FieldKind, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateKind sets the "kind" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsert) UpdateKind() *NotifyChannelUpsert {
|
|
u.SetExcluded(notifychannel.FieldKind)
|
|
return u
|
|
}
|
|
|
|
// SetWebhookURL sets the "webhook_url" field.
|
|
func (u *NotifyChannelUpsert) SetWebhookURL(v string) *NotifyChannelUpsert {
|
|
u.Set(notifychannel.FieldWebhookURL, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateWebhookURL sets the "webhook_url" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsert) UpdateWebhookURL() *NotifyChannelUpsert {
|
|
u.SetExcluded(notifychannel.FieldWebhookURL)
|
|
return u
|
|
}
|
|
|
|
// SetSecret sets the "secret" field.
|
|
func (u *NotifyChannelUpsert) SetSecret(v string) *NotifyChannelUpsert {
|
|
u.Set(notifychannel.FieldSecret, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateSecret sets the "secret" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsert) UpdateSecret() *NotifyChannelUpsert {
|
|
u.SetExcluded(notifychannel.FieldSecret)
|
|
return u
|
|
}
|
|
|
|
// ClearSecret clears the value of the "secret" field.
|
|
func (u *NotifyChannelUpsert) ClearSecret() *NotifyChannelUpsert {
|
|
u.SetNull(notifychannel.FieldSecret)
|
|
return u
|
|
}
|
|
|
|
// SetHeaders sets the "headers" field.
|
|
func (u *NotifyChannelUpsert) SetHeaders(v map[string]string) *NotifyChannelUpsert {
|
|
u.Set(notifychannel.FieldHeaders, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateHeaders sets the "headers" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsert) UpdateHeaders() *NotifyChannelUpsert {
|
|
u.SetExcluded(notifychannel.FieldHeaders)
|
|
return u
|
|
}
|
|
|
|
// ClearHeaders clears the value of the "headers" field.
|
|
func (u *NotifyChannelUpsert) ClearHeaders() *NotifyChannelUpsert {
|
|
u.SetNull(notifychannel.FieldHeaders)
|
|
return u
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (u *NotifyChannelUpsert) SetEnabled(v bool) *NotifyChannelUpsert {
|
|
u.Set(notifychannel.FieldEnabled, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateEnabled sets the "enabled" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsert) UpdateEnabled() *NotifyChannelUpsert {
|
|
u.SetExcluded(notifychannel.FieldEnabled)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *NotifyChannelUpsert) SetCreatedAt(v time.Time) *NotifyChannelUpsert {
|
|
u.Set(notifychannel.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsert) UpdateCreatedAt() *NotifyChannelUpsert {
|
|
u.SetExcluded(notifychannel.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *NotifyChannelUpsert) SetUpdatedAt(v time.Time) *NotifyChannelUpsert {
|
|
u.Set(notifychannel.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsert) UpdateUpdatedAt() *NotifyChannelUpsert {
|
|
u.SetExcluded(notifychannel.FieldUpdatedAt)
|
|
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.NotifyChannel.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(notifychannel.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *NotifyChannelUpsertOne) UpdateNewValues() *NotifyChannelUpsertOne {
|
|
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(notifychannel.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.NotifyChannel.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *NotifyChannelUpsertOne) Ignore() *NotifyChannelUpsertOne {
|
|
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 *NotifyChannelUpsertOne) DoNothing() *NotifyChannelUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the NotifyChannelCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *NotifyChannelUpsertOne) Update(set func(*NotifyChannelUpsert)) *NotifyChannelUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&NotifyChannelUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *NotifyChannelUpsertOne) SetDeletedAt(v time.Time) *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertOne) UpdateDeletedAt() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *NotifyChannelUpsertOne) ClearDeletedAt() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetOwnerID sets the "owner_id" field.
|
|
func (u *NotifyChannelUpsertOne) SetOwnerID(v uuid.UUID) *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetOwnerID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOwnerID sets the "owner_id" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertOne) UpdateOwnerID() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateOwnerID()
|
|
})
|
|
}
|
|
|
|
// SetOwnerType sets the "owner_type" field.
|
|
func (u *NotifyChannelUpsertOne) SetOwnerType(v consts.NotifyOwnerType) *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetOwnerType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOwnerType sets the "owner_type" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertOne) UpdateOwnerType() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateOwnerType()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *NotifyChannelUpsertOne) SetName(v string) *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertOne) UpdateName() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetKind sets the "kind" field.
|
|
func (u *NotifyChannelUpsertOne) SetKind(v consts.NotifyChannelKind) *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetKind(v)
|
|
})
|
|
}
|
|
|
|
// UpdateKind sets the "kind" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertOne) UpdateKind() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateKind()
|
|
})
|
|
}
|
|
|
|
// SetWebhookURL sets the "webhook_url" field.
|
|
func (u *NotifyChannelUpsertOne) SetWebhookURL(v string) *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetWebhookURL(v)
|
|
})
|
|
}
|
|
|
|
// UpdateWebhookURL sets the "webhook_url" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertOne) UpdateWebhookURL() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateWebhookURL()
|
|
})
|
|
}
|
|
|
|
// SetSecret sets the "secret" field.
|
|
func (u *NotifyChannelUpsertOne) SetSecret(v string) *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetSecret(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSecret sets the "secret" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertOne) UpdateSecret() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateSecret()
|
|
})
|
|
}
|
|
|
|
// ClearSecret clears the value of the "secret" field.
|
|
func (u *NotifyChannelUpsertOne) ClearSecret() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.ClearSecret()
|
|
})
|
|
}
|
|
|
|
// SetHeaders sets the "headers" field.
|
|
func (u *NotifyChannelUpsertOne) SetHeaders(v map[string]string) *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetHeaders(v)
|
|
})
|
|
}
|
|
|
|
// UpdateHeaders sets the "headers" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertOne) UpdateHeaders() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateHeaders()
|
|
})
|
|
}
|
|
|
|
// ClearHeaders clears the value of the "headers" field.
|
|
func (u *NotifyChannelUpsertOne) ClearHeaders() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.ClearHeaders()
|
|
})
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (u *NotifyChannelUpsertOne) SetEnabled(v bool) *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetEnabled(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEnabled sets the "enabled" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertOne) UpdateEnabled() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateEnabled()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *NotifyChannelUpsertOne) SetCreatedAt(v time.Time) *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertOne) UpdateCreatedAt() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *NotifyChannelUpsertOne) SetUpdatedAt(v time.Time) *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertOne) UpdateUpdatedAt() *NotifyChannelUpsertOne {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *NotifyChannelUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for NotifyChannelCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *NotifyChannelUpsertOne) 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 *NotifyChannelUpsertOne) 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: NotifyChannelUpsertOne.ID is not supported by MySQL driver. Use NotifyChannelUpsertOne.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 *NotifyChannelUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// NotifyChannelCreateBulk is the builder for creating many NotifyChannel entities in bulk.
|
|
type NotifyChannelCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*NotifyChannelCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the NotifyChannel entities in the database.
|
|
func (_c *NotifyChannelCreateBulk) Save(ctx context.Context) ([]*NotifyChannel, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*NotifyChannel, 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.(*NotifyChannelMutation)
|
|
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 *NotifyChannelCreateBulk) SaveX(ctx context.Context) []*NotifyChannel {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *NotifyChannelCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *NotifyChannelCreateBulk) 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.NotifyChannel.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.NotifyChannelUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *NotifyChannelCreateBulk) OnConflict(opts ...sql.ConflictOption) *NotifyChannelUpsertBulk {
|
|
_c.conflict = opts
|
|
return &NotifyChannelUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.NotifyChannel.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *NotifyChannelCreateBulk) OnConflictColumns(columns ...string) *NotifyChannelUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &NotifyChannelUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// NotifyChannelUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of NotifyChannel nodes.
|
|
type NotifyChannelUpsertBulk struct {
|
|
create *NotifyChannelCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.NotifyChannel.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(notifychannel.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *NotifyChannelUpsertBulk) UpdateNewValues() *NotifyChannelUpsertBulk {
|
|
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(notifychannel.FieldID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.NotifyChannel.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *NotifyChannelUpsertBulk) Ignore() *NotifyChannelUpsertBulk {
|
|
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 *NotifyChannelUpsertBulk) DoNothing() *NotifyChannelUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the NotifyChannelCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *NotifyChannelUpsertBulk) Update(set func(*NotifyChannelUpsert)) *NotifyChannelUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&NotifyChannelUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *NotifyChannelUpsertBulk) SetDeletedAt(v time.Time) *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertBulk) UpdateDeletedAt() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *NotifyChannelUpsertBulk) ClearDeletedAt() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetOwnerID sets the "owner_id" field.
|
|
func (u *NotifyChannelUpsertBulk) SetOwnerID(v uuid.UUID) *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetOwnerID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOwnerID sets the "owner_id" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertBulk) UpdateOwnerID() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateOwnerID()
|
|
})
|
|
}
|
|
|
|
// SetOwnerType sets the "owner_type" field.
|
|
func (u *NotifyChannelUpsertBulk) SetOwnerType(v consts.NotifyOwnerType) *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetOwnerType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOwnerType sets the "owner_type" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertBulk) UpdateOwnerType() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateOwnerType()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *NotifyChannelUpsertBulk) SetName(v string) *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertBulk) UpdateName() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetKind sets the "kind" field.
|
|
func (u *NotifyChannelUpsertBulk) SetKind(v consts.NotifyChannelKind) *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetKind(v)
|
|
})
|
|
}
|
|
|
|
// UpdateKind sets the "kind" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertBulk) UpdateKind() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateKind()
|
|
})
|
|
}
|
|
|
|
// SetWebhookURL sets the "webhook_url" field.
|
|
func (u *NotifyChannelUpsertBulk) SetWebhookURL(v string) *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetWebhookURL(v)
|
|
})
|
|
}
|
|
|
|
// UpdateWebhookURL sets the "webhook_url" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertBulk) UpdateWebhookURL() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateWebhookURL()
|
|
})
|
|
}
|
|
|
|
// SetSecret sets the "secret" field.
|
|
func (u *NotifyChannelUpsertBulk) SetSecret(v string) *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetSecret(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSecret sets the "secret" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertBulk) UpdateSecret() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateSecret()
|
|
})
|
|
}
|
|
|
|
// ClearSecret clears the value of the "secret" field.
|
|
func (u *NotifyChannelUpsertBulk) ClearSecret() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.ClearSecret()
|
|
})
|
|
}
|
|
|
|
// SetHeaders sets the "headers" field.
|
|
func (u *NotifyChannelUpsertBulk) SetHeaders(v map[string]string) *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetHeaders(v)
|
|
})
|
|
}
|
|
|
|
// UpdateHeaders sets the "headers" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertBulk) UpdateHeaders() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateHeaders()
|
|
})
|
|
}
|
|
|
|
// ClearHeaders clears the value of the "headers" field.
|
|
func (u *NotifyChannelUpsertBulk) ClearHeaders() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.ClearHeaders()
|
|
})
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (u *NotifyChannelUpsertBulk) SetEnabled(v bool) *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetEnabled(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEnabled sets the "enabled" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertBulk) UpdateEnabled() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateEnabled()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *NotifyChannelUpsertBulk) SetCreatedAt(v time.Time) *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertBulk) UpdateCreatedAt() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *NotifyChannelUpsertBulk) SetUpdatedAt(v time.Time) *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *NotifyChannelUpsertBulk) UpdateUpdatedAt() *NotifyChannelUpsertBulk {
|
|
return u.Update(func(s *NotifyChannelUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *NotifyChannelUpsertBulk) 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 NotifyChannelCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for NotifyChannelCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *NotifyChannelUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|