mirror of
https://github.com/Fishwaldo/mouthpiece.git
synced 2025-03-16 03:51:22 +00:00
1188 lines
34 KiB
Go
1188 lines
34 KiB
Go
/*
|
|
MIT License
|
|
|
|
Copyright (c) 2021 Justin Hammond
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
*/
|
|
|
|
// Code generated by entc, 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/Fishwaldo/mouthpiece/pkg/ent/dbapp"
|
|
"github.com/Fishwaldo/mouthpiece/pkg/ent/dbmessage"
|
|
"github.com/Fishwaldo/mouthpiece/pkg/ent/dbmessagefields"
|
|
"github.com/Fishwaldo/mouthpiece/pkg/ent/tenant"
|
|
"github.com/Fishwaldo/mouthpiece/pkg/interfaces"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// DbMessageCreate is the builder for creating a DbMessage entity.
|
|
type DbMessageCreate struct {
|
|
config
|
|
mutation *DbMessageMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetTenantID sets the "tenant_id" field.
|
|
func (dmc *DbMessageCreate) SetTenantID(i int) *DbMessageCreate {
|
|
dmc.mutation.SetTenantID(i)
|
|
return dmc
|
|
}
|
|
|
|
// SetAppData sets the "AppData" field.
|
|
func (dmc *DbMessageCreate) SetAppData(id interfaces.AppData) *DbMessageCreate {
|
|
dmc.mutation.SetAppData(id)
|
|
return dmc
|
|
}
|
|
|
|
// SetNillableAppData sets the "AppData" field if the given value is not nil.
|
|
func (dmc *DbMessageCreate) SetNillableAppData(id *interfaces.AppData) *DbMessageCreate {
|
|
if id != nil {
|
|
dmc.SetAppData(*id)
|
|
}
|
|
return dmc
|
|
}
|
|
|
|
// SetMessage sets the "Message" field.
|
|
func (dmc *DbMessageCreate) SetMessage(s string) *DbMessageCreate {
|
|
dmc.mutation.SetMessage(s)
|
|
return dmc
|
|
}
|
|
|
|
// SetShortMsg sets the "ShortMsg" field.
|
|
func (dmc *DbMessageCreate) SetShortMsg(s string) *DbMessageCreate {
|
|
dmc.mutation.SetShortMsg(s)
|
|
return dmc
|
|
}
|
|
|
|
// SetNillableShortMsg sets the "ShortMsg" field if the given value is not nil.
|
|
func (dmc *DbMessageCreate) SetNillableShortMsg(s *string) *DbMessageCreate {
|
|
if s != nil {
|
|
dmc.SetShortMsg(*s)
|
|
}
|
|
return dmc
|
|
}
|
|
|
|
// SetTopic sets the "Topic" field.
|
|
func (dmc *DbMessageCreate) SetTopic(s string) *DbMessageCreate {
|
|
dmc.mutation.SetTopic(s)
|
|
return dmc
|
|
}
|
|
|
|
// SetNillableTopic sets the "Topic" field if the given value is not nil.
|
|
func (dmc *DbMessageCreate) SetNillableTopic(s *string) *DbMessageCreate {
|
|
if s != nil {
|
|
dmc.SetTopic(*s)
|
|
}
|
|
return dmc
|
|
}
|
|
|
|
// SetSeverity sets the "Severity" field.
|
|
func (dmc *DbMessageCreate) SetSeverity(i int) *DbMessageCreate {
|
|
dmc.mutation.SetSeverity(i)
|
|
return dmc
|
|
}
|
|
|
|
// SetNillableSeverity sets the "Severity" field if the given value is not nil.
|
|
func (dmc *DbMessageCreate) SetNillableSeverity(i *int) *DbMessageCreate {
|
|
if i != nil {
|
|
dmc.SetSeverity(*i)
|
|
}
|
|
return dmc
|
|
}
|
|
|
|
// SetTimestamp sets the "Timestamp" field.
|
|
func (dmc *DbMessageCreate) SetTimestamp(t time.Time) *DbMessageCreate {
|
|
dmc.mutation.SetTimestamp(t)
|
|
return dmc
|
|
}
|
|
|
|
// SetNillableTimestamp sets the "Timestamp" field if the given value is not nil.
|
|
func (dmc *DbMessageCreate) SetNillableTimestamp(t *time.Time) *DbMessageCreate {
|
|
if t != nil {
|
|
dmc.SetTimestamp(*t)
|
|
}
|
|
return dmc
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (dmc *DbMessageCreate) SetID(u uuid.UUID) *DbMessageCreate {
|
|
dmc.mutation.SetID(u)
|
|
return dmc
|
|
}
|
|
|
|
// SetNillableID sets the "id" field if the given value is not nil.
|
|
func (dmc *DbMessageCreate) SetNillableID(u *uuid.UUID) *DbMessageCreate {
|
|
if u != nil {
|
|
dmc.SetID(*u)
|
|
}
|
|
return dmc
|
|
}
|
|
|
|
// SetTenant sets the "tenant" edge to the Tenant entity.
|
|
func (dmc *DbMessageCreate) SetTenant(t *Tenant) *DbMessageCreate {
|
|
return dmc.SetTenantID(t.ID)
|
|
}
|
|
|
|
// AddFieldIDs adds the "fields" edge to the DbMessageFields entity by IDs.
|
|
func (dmc *DbMessageCreate) AddFieldIDs(ids ...int) *DbMessageCreate {
|
|
dmc.mutation.AddFieldIDs(ids...)
|
|
return dmc
|
|
}
|
|
|
|
// AddFields adds the "fields" edges to the DbMessageFields entity.
|
|
func (dmc *DbMessageCreate) AddFields(d ...*DbMessageFields) *DbMessageCreate {
|
|
ids := make([]int, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return dmc.AddFieldIDs(ids...)
|
|
}
|
|
|
|
// SetAppID sets the "app" edge to the DbApp entity by ID.
|
|
func (dmc *DbMessageCreate) SetAppID(id int) *DbMessageCreate {
|
|
dmc.mutation.SetAppID(id)
|
|
return dmc
|
|
}
|
|
|
|
// SetApp sets the "app" edge to the DbApp entity.
|
|
func (dmc *DbMessageCreate) SetApp(d *DbApp) *DbMessageCreate {
|
|
return dmc.SetAppID(d.ID)
|
|
}
|
|
|
|
// Mutation returns the DbMessageMutation object of the builder.
|
|
func (dmc *DbMessageCreate) Mutation() *DbMessageMutation {
|
|
return dmc.mutation
|
|
}
|
|
|
|
// Save creates the DbMessage in the database.
|
|
func (dmc *DbMessageCreate) Save(ctx context.Context) (*DbMessage, error) {
|
|
var (
|
|
err error
|
|
node *DbMessage
|
|
)
|
|
if err := dmc.defaults(); err != nil {
|
|
return nil, err
|
|
}
|
|
if len(dmc.hooks) == 0 {
|
|
if err = dmc.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
node, err = dmc.sqlSave(ctx)
|
|
} else {
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*DbMessageMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
if err = dmc.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
dmc.mutation = mutation
|
|
if node, err = dmc.sqlSave(ctx); err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &node.ID
|
|
mutation.done = true
|
|
return node, err
|
|
})
|
|
for i := len(dmc.hooks) - 1; i >= 0; i-- {
|
|
if dmc.hooks[i] == nil {
|
|
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
|
}
|
|
mut = dmc.hooks[i](mut)
|
|
}
|
|
v, err := mut.Mutate(ctx, dmc.mutation)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
nv, ok := v.(*DbMessage)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected node type %T returned from DbMessageMutation", v)
|
|
}
|
|
node = nv
|
|
}
|
|
return node, err
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (dmc *DbMessageCreate) SaveX(ctx context.Context) *DbMessage {
|
|
v, err := dmc.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (dmc *DbMessageCreate) Exec(ctx context.Context) error {
|
|
_, err := dmc.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (dmc *DbMessageCreate) ExecX(ctx context.Context) {
|
|
if err := dmc.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (dmc *DbMessageCreate) defaults() error {
|
|
if _, ok := dmc.mutation.Severity(); !ok {
|
|
v := dbmessage.DefaultSeverity
|
|
dmc.mutation.SetSeverity(v)
|
|
}
|
|
if _, ok := dmc.mutation.Timestamp(); !ok {
|
|
v := dbmessage.DefaultTimestamp
|
|
dmc.mutation.SetTimestamp(v)
|
|
}
|
|
if _, ok := dmc.mutation.ID(); !ok {
|
|
if dbmessage.DefaultID == nil {
|
|
return fmt.Errorf("ent: uninitialized dbmessage.DefaultID (forgotten import ent/runtime?)")
|
|
}
|
|
v := dbmessage.DefaultID()
|
|
dmc.mutation.SetID(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (dmc *DbMessageCreate) check() error {
|
|
if _, ok := dmc.mutation.TenantID(); !ok {
|
|
return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "DbMessage.tenant_id"`)}
|
|
}
|
|
if _, ok := dmc.mutation.Message(); !ok {
|
|
return &ValidationError{Name: "Message", err: errors.New(`ent: missing required field "DbMessage.Message"`)}
|
|
}
|
|
if v, ok := dmc.mutation.Message(); ok {
|
|
if err := dbmessage.MessageValidator(v); err != nil {
|
|
return &ValidationError{Name: "Message", err: fmt.Errorf(`ent: validator failed for field "DbMessage.Message": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := dmc.mutation.Topic(); ok {
|
|
if err := dbmessage.TopicValidator(v); err != nil {
|
|
return &ValidationError{Name: "Topic", err: fmt.Errorf(`ent: validator failed for field "DbMessage.Topic": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := dmc.mutation.Severity(); ok {
|
|
if err := dbmessage.SeverityValidator(v); err != nil {
|
|
return &ValidationError{Name: "Severity", err: fmt.Errorf(`ent: validator failed for field "DbMessage.Severity": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := dmc.mutation.Timestamp(); !ok {
|
|
return &ValidationError{Name: "Timestamp", err: errors.New(`ent: missing required field "DbMessage.Timestamp"`)}
|
|
}
|
|
if _, ok := dmc.mutation.TenantID(); !ok {
|
|
return &ValidationError{Name: "tenant", err: errors.New(`ent: missing required edge "DbMessage.tenant"`)}
|
|
}
|
|
if _, ok := dmc.mutation.AppID(); !ok {
|
|
return &ValidationError{Name: "app", err: errors.New(`ent: missing required edge "DbMessage.app"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (dmc *DbMessageCreate) sqlSave(ctx context.Context) (*DbMessage, error) {
|
|
_node, _spec := dmc.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, dmc.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
|
|
}
|
|
}
|
|
return _node, nil
|
|
}
|
|
|
|
func (dmc *DbMessageCreate) createSpec() (*DbMessage, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &DbMessage{config: dmc.config}
|
|
_spec = &sqlgraph.CreateSpec{
|
|
Table: dbmessage.Table,
|
|
ID: &sqlgraph.FieldSpec{
|
|
Type: field.TypeUUID,
|
|
Column: dbmessage.FieldID,
|
|
},
|
|
}
|
|
)
|
|
_spec.OnConflict = dmc.conflict
|
|
if id, ok := dmc.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = &id
|
|
}
|
|
if value, ok := dmc.mutation.AppData(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeJSON,
|
|
Value: value,
|
|
Column: dbmessage.FieldAppData,
|
|
})
|
|
_node.AppData = value
|
|
}
|
|
if value, ok := dmc.mutation.Message(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: dbmessage.FieldMessage,
|
|
})
|
|
_node.Message = value
|
|
}
|
|
if value, ok := dmc.mutation.ShortMsg(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: dbmessage.FieldShortMsg,
|
|
})
|
|
_node.ShortMsg = &value
|
|
}
|
|
if value, ok := dmc.mutation.Topic(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: dbmessage.FieldTopic,
|
|
})
|
|
_node.Topic = &value
|
|
}
|
|
if value, ok := dmc.mutation.Severity(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: dbmessage.FieldSeverity,
|
|
})
|
|
_node.Severity = value
|
|
}
|
|
if value, ok := dmc.mutation.Timestamp(); ok {
|
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
|
Type: field.TypeTime,
|
|
Value: value,
|
|
Column: dbmessage.FieldTimestamp,
|
|
})
|
|
_node.Timestamp = value
|
|
}
|
|
if nodes := dmc.mutation.TenantIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: dbmessage.TenantTable,
|
|
Columns: []string{dbmessage.TenantColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: tenant.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.TenantID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := dmc.mutation.FieldsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dbmessage.FieldsTable,
|
|
Columns: []string{dbmessage.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: dbmessagefields.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := dmc.mutation.AppIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: dbmessage.AppTable,
|
|
Columns: []string{dbmessage.AppColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: dbapp.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.db_app_messages = &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.DbMessage.Create().
|
|
// SetTenantID(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.DbMessageUpsert) {
|
|
// SetTenantID(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (dmc *DbMessageCreate) OnConflict(opts ...sql.ConflictOption) *DbMessageUpsertOne {
|
|
dmc.conflict = opts
|
|
return &DbMessageUpsertOne{
|
|
create: dmc,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.DbMessage.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (dmc *DbMessageCreate) OnConflictColumns(columns ...string) *DbMessageUpsertOne {
|
|
dmc.conflict = append(dmc.conflict, sql.ConflictColumns(columns...))
|
|
return &DbMessageUpsertOne{
|
|
create: dmc,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// DbMessageUpsertOne is the builder for "upsert"-ing
|
|
// one DbMessage node.
|
|
DbMessageUpsertOne struct {
|
|
create *DbMessageCreate
|
|
}
|
|
|
|
// DbMessageUpsert is the "OnConflict" setter.
|
|
DbMessageUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetTenantID sets the "tenant_id" field.
|
|
func (u *DbMessageUpsert) SetTenantID(v int) *DbMessageUpsert {
|
|
u.Set(dbmessage.FieldTenantID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTenantID sets the "tenant_id" field to the value that was provided on create.
|
|
func (u *DbMessageUpsert) UpdateTenantID() *DbMessageUpsert {
|
|
u.SetExcluded(dbmessage.FieldTenantID)
|
|
return u
|
|
}
|
|
|
|
// SetAppData sets the "AppData" field.
|
|
func (u *DbMessageUpsert) SetAppData(v interfaces.AppData) *DbMessageUpsert {
|
|
u.Set(dbmessage.FieldAppData, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateAppData sets the "AppData" field to the value that was provided on create.
|
|
func (u *DbMessageUpsert) UpdateAppData() *DbMessageUpsert {
|
|
u.SetExcluded(dbmessage.FieldAppData)
|
|
return u
|
|
}
|
|
|
|
// ClearAppData clears the value of the "AppData" field.
|
|
func (u *DbMessageUpsert) ClearAppData() *DbMessageUpsert {
|
|
u.SetNull(dbmessage.FieldAppData)
|
|
return u
|
|
}
|
|
|
|
// SetMessage sets the "Message" field.
|
|
func (u *DbMessageUpsert) SetMessage(v string) *DbMessageUpsert {
|
|
u.Set(dbmessage.FieldMessage, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateMessage sets the "Message" field to the value that was provided on create.
|
|
func (u *DbMessageUpsert) UpdateMessage() *DbMessageUpsert {
|
|
u.SetExcluded(dbmessage.FieldMessage)
|
|
return u
|
|
}
|
|
|
|
// SetShortMsg sets the "ShortMsg" field.
|
|
func (u *DbMessageUpsert) SetShortMsg(v string) *DbMessageUpsert {
|
|
u.Set(dbmessage.FieldShortMsg, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateShortMsg sets the "ShortMsg" field to the value that was provided on create.
|
|
func (u *DbMessageUpsert) UpdateShortMsg() *DbMessageUpsert {
|
|
u.SetExcluded(dbmessage.FieldShortMsg)
|
|
return u
|
|
}
|
|
|
|
// ClearShortMsg clears the value of the "ShortMsg" field.
|
|
func (u *DbMessageUpsert) ClearShortMsg() *DbMessageUpsert {
|
|
u.SetNull(dbmessage.FieldShortMsg)
|
|
return u
|
|
}
|
|
|
|
// SetTopic sets the "Topic" field.
|
|
func (u *DbMessageUpsert) SetTopic(v string) *DbMessageUpsert {
|
|
u.Set(dbmessage.FieldTopic, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTopic sets the "Topic" field to the value that was provided on create.
|
|
func (u *DbMessageUpsert) UpdateTopic() *DbMessageUpsert {
|
|
u.SetExcluded(dbmessage.FieldTopic)
|
|
return u
|
|
}
|
|
|
|
// ClearTopic clears the value of the "Topic" field.
|
|
func (u *DbMessageUpsert) ClearTopic() *DbMessageUpsert {
|
|
u.SetNull(dbmessage.FieldTopic)
|
|
return u
|
|
}
|
|
|
|
// SetSeverity sets the "Severity" field.
|
|
func (u *DbMessageUpsert) SetSeverity(v int) *DbMessageUpsert {
|
|
u.Set(dbmessage.FieldSeverity, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateSeverity sets the "Severity" field to the value that was provided on create.
|
|
func (u *DbMessageUpsert) UpdateSeverity() *DbMessageUpsert {
|
|
u.SetExcluded(dbmessage.FieldSeverity)
|
|
return u
|
|
}
|
|
|
|
// AddSeverity adds v to the "Severity" field.
|
|
func (u *DbMessageUpsert) AddSeverity(v int) *DbMessageUpsert {
|
|
u.Add(dbmessage.FieldSeverity, v)
|
|
return u
|
|
}
|
|
|
|
// ClearSeverity clears the value of the "Severity" field.
|
|
func (u *DbMessageUpsert) ClearSeverity() *DbMessageUpsert {
|
|
u.SetNull(dbmessage.FieldSeverity)
|
|
return u
|
|
}
|
|
|
|
// SetTimestamp sets the "Timestamp" field.
|
|
func (u *DbMessageUpsert) SetTimestamp(v time.Time) *DbMessageUpsert {
|
|
u.Set(dbmessage.FieldTimestamp, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTimestamp sets the "Timestamp" field to the value that was provided on create.
|
|
func (u *DbMessageUpsert) UpdateTimestamp() *DbMessageUpsert {
|
|
u.SetExcluded(dbmessage.FieldTimestamp)
|
|
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.DbMessage.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(dbmessage.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *DbMessageUpsertOne) UpdateNewValues() *DbMessageUpsertOne {
|
|
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(dbmessage.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.DbMessage.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *DbMessageUpsertOne) Ignore() *DbMessageUpsertOne {
|
|
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 *DbMessageUpsertOne) DoNothing() *DbMessageUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the DbMessageCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *DbMessageUpsertOne) Update(set func(*DbMessageUpsert)) *DbMessageUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&DbMessageUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetTenantID sets the "tenant_id" field.
|
|
func (u *DbMessageUpsertOne) SetTenantID(v int) *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetTenantID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTenantID sets the "tenant_id" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertOne) UpdateTenantID() *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateTenantID()
|
|
})
|
|
}
|
|
|
|
// SetAppData sets the "AppData" field.
|
|
func (u *DbMessageUpsertOne) SetAppData(v interfaces.AppData) *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetAppData(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAppData sets the "AppData" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertOne) UpdateAppData() *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateAppData()
|
|
})
|
|
}
|
|
|
|
// ClearAppData clears the value of the "AppData" field.
|
|
func (u *DbMessageUpsertOne) ClearAppData() *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.ClearAppData()
|
|
})
|
|
}
|
|
|
|
// SetMessage sets the "Message" field.
|
|
func (u *DbMessageUpsertOne) SetMessage(v string) *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetMessage(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMessage sets the "Message" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertOne) UpdateMessage() *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateMessage()
|
|
})
|
|
}
|
|
|
|
// SetShortMsg sets the "ShortMsg" field.
|
|
func (u *DbMessageUpsertOne) SetShortMsg(v string) *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetShortMsg(v)
|
|
})
|
|
}
|
|
|
|
// UpdateShortMsg sets the "ShortMsg" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertOne) UpdateShortMsg() *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateShortMsg()
|
|
})
|
|
}
|
|
|
|
// ClearShortMsg clears the value of the "ShortMsg" field.
|
|
func (u *DbMessageUpsertOne) ClearShortMsg() *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.ClearShortMsg()
|
|
})
|
|
}
|
|
|
|
// SetTopic sets the "Topic" field.
|
|
func (u *DbMessageUpsertOne) SetTopic(v string) *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetTopic(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTopic sets the "Topic" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertOne) UpdateTopic() *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateTopic()
|
|
})
|
|
}
|
|
|
|
// ClearTopic clears the value of the "Topic" field.
|
|
func (u *DbMessageUpsertOne) ClearTopic() *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.ClearTopic()
|
|
})
|
|
}
|
|
|
|
// SetSeverity sets the "Severity" field.
|
|
func (u *DbMessageUpsertOne) SetSeverity(v int) *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetSeverity(v)
|
|
})
|
|
}
|
|
|
|
// AddSeverity adds v to the "Severity" field.
|
|
func (u *DbMessageUpsertOne) AddSeverity(v int) *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.AddSeverity(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSeverity sets the "Severity" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertOne) UpdateSeverity() *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateSeverity()
|
|
})
|
|
}
|
|
|
|
// ClearSeverity clears the value of the "Severity" field.
|
|
func (u *DbMessageUpsertOne) ClearSeverity() *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.ClearSeverity()
|
|
})
|
|
}
|
|
|
|
// SetTimestamp sets the "Timestamp" field.
|
|
func (u *DbMessageUpsertOne) SetTimestamp(v time.Time) *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetTimestamp(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTimestamp sets the "Timestamp" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertOne) UpdateTimestamp() *DbMessageUpsertOne {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateTimestamp()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *DbMessageUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for DbMessageCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *DbMessageUpsertOne) 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 *DbMessageUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) {
|
|
if u.create.driver.Dialect() == dialect.MySQL {
|
|
// In case of "ON CONFLICT", there is no way to get back non-numeric ID
|
|
// fields from the database since MySQL does not support the RETURNING clause.
|
|
return id, errors.New("ent: DbMessageUpsertOne.ID is not supported by MySQL driver. Use DbMessageUpsertOne.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 *DbMessageUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
func (dmc *DbMessageCreate) SetDbMessageFromStruct(input *DbMessage) *DbMessageCreate {
|
|
|
|
dmc.SetTenantID(input.TenantID)
|
|
|
|
dmc.SetAppData(input.AppData)
|
|
|
|
dmc.SetMessage(input.Message)
|
|
|
|
if input.ShortMsg != nil {
|
|
dmc.SetShortMsg(*input.ShortMsg)
|
|
}
|
|
|
|
if input.Topic != nil {
|
|
dmc.SetTopic(*input.Topic)
|
|
}
|
|
|
|
dmc.SetSeverity(input.Severity)
|
|
|
|
dmc.SetTimestamp(input.Timestamp)
|
|
|
|
return dmc
|
|
}
|
|
|
|
// DbMessageCreateBulk is the builder for creating many DbMessage entities in bulk.
|
|
type DbMessageCreateBulk struct {
|
|
config
|
|
builders []*DbMessageCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the DbMessage entities in the database.
|
|
func (dmcb *DbMessageCreateBulk) Save(ctx context.Context) ([]*DbMessage, error) {
|
|
specs := make([]*sqlgraph.CreateSpec, len(dmcb.builders))
|
|
nodes := make([]*DbMessage, len(dmcb.builders))
|
|
mutators := make([]Mutator, len(dmcb.builders))
|
|
for i := range dmcb.builders {
|
|
func(i int, root context.Context) {
|
|
builder := dmcb.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*DbMessageMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
if err := builder.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
builder.mutation = mutation
|
|
nodes[i], specs[i] = builder.createSpec()
|
|
var err error
|
|
if i < len(mutators)-1 {
|
|
_, err = mutators[i+1].Mutate(root, dmcb.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
spec.OnConflict = dmcb.conflict
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, dmcb.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, dmcb.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (dmcb *DbMessageCreateBulk) SaveX(ctx context.Context) []*DbMessage {
|
|
v, err := dmcb.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (dmcb *DbMessageCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := dmcb.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (dmcb *DbMessageCreateBulk) ExecX(ctx context.Context) {
|
|
if err := dmcb.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.DbMessage.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.DbMessageUpsert) {
|
|
// SetTenantID(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (dmcb *DbMessageCreateBulk) OnConflict(opts ...sql.ConflictOption) *DbMessageUpsertBulk {
|
|
dmcb.conflict = opts
|
|
return &DbMessageUpsertBulk{
|
|
create: dmcb,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.DbMessage.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (dmcb *DbMessageCreateBulk) OnConflictColumns(columns ...string) *DbMessageUpsertBulk {
|
|
dmcb.conflict = append(dmcb.conflict, sql.ConflictColumns(columns...))
|
|
return &DbMessageUpsertBulk{
|
|
create: dmcb,
|
|
}
|
|
}
|
|
|
|
// DbMessageUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of DbMessage nodes.
|
|
type DbMessageUpsertBulk struct {
|
|
create *DbMessageCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.DbMessage.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(dbmessage.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *DbMessageUpsertBulk) UpdateNewValues() *DbMessageUpsertBulk {
|
|
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(dbmessage.FieldID)
|
|
return
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.DbMessage.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *DbMessageUpsertBulk) Ignore() *DbMessageUpsertBulk {
|
|
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 *DbMessageUpsertBulk) DoNothing() *DbMessageUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the DbMessageCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *DbMessageUpsertBulk) Update(set func(*DbMessageUpsert)) *DbMessageUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&DbMessageUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetTenantID sets the "tenant_id" field.
|
|
func (u *DbMessageUpsertBulk) SetTenantID(v int) *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetTenantID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTenantID sets the "tenant_id" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertBulk) UpdateTenantID() *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateTenantID()
|
|
})
|
|
}
|
|
|
|
// SetAppData sets the "AppData" field.
|
|
func (u *DbMessageUpsertBulk) SetAppData(v interfaces.AppData) *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetAppData(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAppData sets the "AppData" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertBulk) UpdateAppData() *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateAppData()
|
|
})
|
|
}
|
|
|
|
// ClearAppData clears the value of the "AppData" field.
|
|
func (u *DbMessageUpsertBulk) ClearAppData() *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.ClearAppData()
|
|
})
|
|
}
|
|
|
|
// SetMessage sets the "Message" field.
|
|
func (u *DbMessageUpsertBulk) SetMessage(v string) *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetMessage(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMessage sets the "Message" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertBulk) UpdateMessage() *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateMessage()
|
|
})
|
|
}
|
|
|
|
// SetShortMsg sets the "ShortMsg" field.
|
|
func (u *DbMessageUpsertBulk) SetShortMsg(v string) *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetShortMsg(v)
|
|
})
|
|
}
|
|
|
|
// UpdateShortMsg sets the "ShortMsg" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertBulk) UpdateShortMsg() *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateShortMsg()
|
|
})
|
|
}
|
|
|
|
// ClearShortMsg clears the value of the "ShortMsg" field.
|
|
func (u *DbMessageUpsertBulk) ClearShortMsg() *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.ClearShortMsg()
|
|
})
|
|
}
|
|
|
|
// SetTopic sets the "Topic" field.
|
|
func (u *DbMessageUpsertBulk) SetTopic(v string) *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetTopic(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTopic sets the "Topic" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertBulk) UpdateTopic() *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateTopic()
|
|
})
|
|
}
|
|
|
|
// ClearTopic clears the value of the "Topic" field.
|
|
func (u *DbMessageUpsertBulk) ClearTopic() *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.ClearTopic()
|
|
})
|
|
}
|
|
|
|
// SetSeverity sets the "Severity" field.
|
|
func (u *DbMessageUpsertBulk) SetSeverity(v int) *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetSeverity(v)
|
|
})
|
|
}
|
|
|
|
// AddSeverity adds v to the "Severity" field.
|
|
func (u *DbMessageUpsertBulk) AddSeverity(v int) *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.AddSeverity(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSeverity sets the "Severity" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertBulk) UpdateSeverity() *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateSeverity()
|
|
})
|
|
}
|
|
|
|
// ClearSeverity clears the value of the "Severity" field.
|
|
func (u *DbMessageUpsertBulk) ClearSeverity() *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.ClearSeverity()
|
|
})
|
|
}
|
|
|
|
// SetTimestamp sets the "Timestamp" field.
|
|
func (u *DbMessageUpsertBulk) SetTimestamp(v time.Time) *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.SetTimestamp(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTimestamp sets the "Timestamp" field to the value that was provided on create.
|
|
func (u *DbMessageUpsertBulk) UpdateTimestamp() *DbMessageUpsertBulk {
|
|
return u.Update(func(s *DbMessageUpsert) {
|
|
s.UpdateTimestamp()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *DbMessageUpsertBulk) Exec(ctx context.Context) error {
|
|
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 DbMessageCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for DbMessageCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *DbMessageUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|