Files
yokowu 34320f9ed5 feat(phase6): 添加 gitbot/gittask 实体 schema 和 migration
- 新增 git_bots, git_bot_users, git_bot_tasks, project_git_bots 表
- 添加 user, host, project 到 gitbot 的关联边
- 使用 soft delete 和 created_at 游标
2026-03-19 18:14:53 +08:00

1872 lines
49 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/db/gitbot"
"github.com/chaitin/MonkeyCode/backend/db/host"
"github.com/chaitin/MonkeyCode/backend/db/teamgroup"
"github.com/chaitin/MonkeyCode/backend/db/teamgrouphost"
"github.com/chaitin/MonkeyCode/backend/db/user"
"github.com/chaitin/MonkeyCode/backend/db/virtualmachine"
"github.com/google/uuid"
)
// HostCreate is the builder for creating a Host entity.
type HostCreate struct {
config
mutation *HostMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetDeletedAt sets the "deleted_at" field.
func (_c *HostCreate) SetDeletedAt(v time.Time) *HostCreate {
_c.mutation.SetDeletedAt(v)
return _c
}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_c *HostCreate) SetNillableDeletedAt(v *time.Time) *HostCreate {
if v != nil {
_c.SetDeletedAt(*v)
}
return _c
}
// SetUserID sets the "user_id" field.
func (_c *HostCreate) SetUserID(v uuid.UUID) *HostCreate {
_c.mutation.SetUserID(v)
return _c
}
// SetHostname sets the "hostname" field.
func (_c *HostCreate) SetHostname(v string) *HostCreate {
_c.mutation.SetHostname(v)
return _c
}
// SetNillableHostname sets the "hostname" field if the given value is not nil.
func (_c *HostCreate) SetNillableHostname(v *string) *HostCreate {
if v != nil {
_c.SetHostname(*v)
}
return _c
}
// SetArch sets the "arch" field.
func (_c *HostCreate) SetArch(v string) *HostCreate {
_c.mutation.SetArch(v)
return _c
}
// SetNillableArch sets the "arch" field if the given value is not nil.
func (_c *HostCreate) SetNillableArch(v *string) *HostCreate {
if v != nil {
_c.SetArch(*v)
}
return _c
}
// SetCores sets the "cores" field.
func (_c *HostCreate) SetCores(v int) *HostCreate {
_c.mutation.SetCores(v)
return _c
}
// SetNillableCores sets the "cores" field if the given value is not nil.
func (_c *HostCreate) SetNillableCores(v *int) *HostCreate {
if v != nil {
_c.SetCores(*v)
}
return _c
}
// SetWeight sets the "weight" field.
func (_c *HostCreate) SetWeight(v int) *HostCreate {
_c.mutation.SetWeight(v)
return _c
}
// SetNillableWeight sets the "weight" field if the given value is not nil.
func (_c *HostCreate) SetNillableWeight(v *int) *HostCreate {
if v != nil {
_c.SetWeight(*v)
}
return _c
}
// SetMemory sets the "memory" field.
func (_c *HostCreate) SetMemory(v int64) *HostCreate {
_c.mutation.SetMemory(v)
return _c
}
// SetNillableMemory sets the "memory" field if the given value is not nil.
func (_c *HostCreate) SetNillableMemory(v *int64) *HostCreate {
if v != nil {
_c.SetMemory(*v)
}
return _c
}
// SetDisk sets the "disk" field.
func (_c *HostCreate) SetDisk(v int64) *HostCreate {
_c.mutation.SetDisk(v)
return _c
}
// SetNillableDisk sets the "disk" field if the given value is not nil.
func (_c *HostCreate) SetNillableDisk(v *int64) *HostCreate {
if v != nil {
_c.SetDisk(*v)
}
return _c
}
// SetOs sets the "os" field.
func (_c *HostCreate) SetOs(v string) *HostCreate {
_c.mutation.SetOs(v)
return _c
}
// SetNillableOs sets the "os" field if the given value is not nil.
func (_c *HostCreate) SetNillableOs(v *string) *HostCreate {
if v != nil {
_c.SetOs(*v)
}
return _c
}
// SetExternalIP sets the "external_ip" field.
func (_c *HostCreate) SetExternalIP(v string) *HostCreate {
_c.mutation.SetExternalIP(v)
return _c
}
// SetNillableExternalIP sets the "external_ip" field if the given value is not nil.
func (_c *HostCreate) SetNillableExternalIP(v *string) *HostCreate {
if v != nil {
_c.SetExternalIP(*v)
}
return _c
}
// SetInternalIP sets the "internal_ip" field.
func (_c *HostCreate) SetInternalIP(v string) *HostCreate {
_c.mutation.SetInternalIP(v)
return _c
}
// SetNillableInternalIP sets the "internal_ip" field if the given value is not nil.
func (_c *HostCreate) SetNillableInternalIP(v *string) *HostCreate {
if v != nil {
_c.SetInternalIP(*v)
}
return _c
}
// SetVersion sets the "version" field.
func (_c *HostCreate) SetVersion(v string) *HostCreate {
_c.mutation.SetVersion(v)
return _c
}
// SetNillableVersion sets the "version" field if the given value is not nil.
func (_c *HostCreate) SetNillableVersion(v *string) *HostCreate {
if v != nil {
_c.SetVersion(*v)
}
return _c
}
// SetMachineID sets the "machine_id" field.
func (_c *HostCreate) SetMachineID(v string) *HostCreate {
_c.mutation.SetMachineID(v)
return _c
}
// SetNillableMachineID sets the "machine_id" field if the given value is not nil.
func (_c *HostCreate) SetNillableMachineID(v *string) *HostCreate {
if v != nil {
_c.SetMachineID(*v)
}
return _c
}
// SetRemark sets the "remark" field.
func (_c *HostCreate) SetRemark(v string) *HostCreate {
_c.mutation.SetRemark(v)
return _c
}
// SetNillableRemark sets the "remark" field if the given value is not nil.
func (_c *HostCreate) SetNillableRemark(v *string) *HostCreate {
if v != nil {
_c.SetRemark(*v)
}
return _c
}
// SetCreatedAt sets the "created_at" field.
func (_c *HostCreate) SetCreatedAt(v time.Time) *HostCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *HostCreate) SetNillableCreatedAt(v *time.Time) *HostCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// SetUpdatedAt sets the "updated_at" field.
func (_c *HostCreate) SetUpdatedAt(v time.Time) *HostCreate {
_c.mutation.SetUpdatedAt(v)
return _c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *HostCreate) SetNillableUpdatedAt(v *time.Time) *HostCreate {
if v != nil {
_c.SetUpdatedAt(*v)
}
return _c
}
// SetID sets the "id" field.
func (_c *HostCreate) SetID(v string) *HostCreate {
_c.mutation.SetID(v)
return _c
}
// AddVMIDs adds the "vms" edge to the VirtualMachine entity by IDs.
func (_c *HostCreate) AddVMIDs(ids ...string) *HostCreate {
_c.mutation.AddVMIDs(ids...)
return _c
}
// AddVms adds the "vms" edges to the VirtualMachine entity.
func (_c *HostCreate) AddVms(v ...*VirtualMachine) *HostCreate {
ids := make([]string, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddVMIDs(ids...)
}
// SetUser sets the "user" edge to the User entity.
func (_c *HostCreate) SetUser(v *User) *HostCreate {
return _c.SetUserID(v.ID)
}
// AddGroupIDs adds the "groups" edge to the TeamGroup entity by IDs.
func (_c *HostCreate) AddGroupIDs(ids ...uuid.UUID) *HostCreate {
_c.mutation.AddGroupIDs(ids...)
return _c
}
// AddGroups adds the "groups" edges to the TeamGroup entity.
func (_c *HostCreate) AddGroups(v ...*TeamGroup) *HostCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddGroupIDs(ids...)
}
// AddGitBotIDs adds the "git_bots" edge to the GitBot entity by IDs.
func (_c *HostCreate) AddGitBotIDs(ids ...uuid.UUID) *HostCreate {
_c.mutation.AddGitBotIDs(ids...)
return _c
}
// AddGitBots adds the "git_bots" edges to the GitBot entity.
func (_c *HostCreate) AddGitBots(v ...*GitBot) *HostCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddGitBotIDs(ids...)
}
// AddTeamGroupHostIDs adds the "team_group_hosts" edge to the TeamGroupHost entity by IDs.
func (_c *HostCreate) AddTeamGroupHostIDs(ids ...uuid.UUID) *HostCreate {
_c.mutation.AddTeamGroupHostIDs(ids...)
return _c
}
// AddTeamGroupHosts adds the "team_group_hosts" edges to the TeamGroupHost entity.
func (_c *HostCreate) AddTeamGroupHosts(v ...*TeamGroupHost) *HostCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddTeamGroupHostIDs(ids...)
}
// Mutation returns the HostMutation object of the builder.
func (_c *HostCreate) Mutation() *HostMutation {
return _c.mutation
}
// Save creates the Host in the database.
func (_c *HostCreate) Save(ctx context.Context) (*Host, 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 *HostCreate) SaveX(ctx context.Context) *Host {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *HostCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *HostCreate) 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 *HostCreate) defaults() error {
if _, ok := _c.mutation.Weight(); !ok {
v := host.DefaultWeight
_c.mutation.SetWeight(v)
}
if _, ok := _c.mutation.CreatedAt(); !ok {
if host.DefaultCreatedAt == nil {
return fmt.Errorf("db: uninitialized host.DefaultCreatedAt (forgotten import db/runtime?)")
}
v := host.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
if host.DefaultUpdatedAt == nil {
return fmt.Errorf("db: uninitialized host.DefaultUpdatedAt (forgotten import db/runtime?)")
}
v := host.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
return nil
}
// check runs all checks and user-defined validators on the builder.
func (_c *HostCreate) check() error {
if _, ok := _c.mutation.UserID(); !ok {
return &ValidationError{Name: "user_id", err: errors.New(`db: missing required field "Host.user_id"`)}
}
if _, ok := _c.mutation.Weight(); !ok {
return &ValidationError{Name: "weight", err: errors.New(`db: missing required field "Host.weight"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "Host.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "Host.updated_at"`)}
}
if len(_c.mutation.UserIDs()) == 0 {
return &ValidationError{Name: "user", err: errors.New(`db: missing required edge "Host.user"`)}
}
return nil
}
func (_c *HostCreate) sqlSave(ctx context.Context) (*Host, 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.(string); ok {
_node.ID = id
} else {
return nil, fmt.Errorf("unexpected Host.ID type: %T", _spec.ID.Value)
}
}
_c.mutation.id = &_node.ID
_c.mutation.done = true
return _node, nil
}
func (_c *HostCreate) createSpec() (*Host, *sqlgraph.CreateSpec) {
var (
_node = &Host{config: _c.config}
_spec = sqlgraph.NewCreateSpec(host.Table, sqlgraph.NewFieldSpec(host.FieldID, field.TypeString))
)
_spec.OnConflict = _c.conflict
if id, ok := _c.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := _c.mutation.DeletedAt(); ok {
_spec.SetField(host.FieldDeletedAt, field.TypeTime, value)
_node.DeletedAt = value
}
if value, ok := _c.mutation.Hostname(); ok {
_spec.SetField(host.FieldHostname, field.TypeString, value)
_node.Hostname = value
}
if value, ok := _c.mutation.Arch(); ok {
_spec.SetField(host.FieldArch, field.TypeString, value)
_node.Arch = value
}
if value, ok := _c.mutation.Cores(); ok {
_spec.SetField(host.FieldCores, field.TypeInt, value)
_node.Cores = value
}
if value, ok := _c.mutation.Weight(); ok {
_spec.SetField(host.FieldWeight, field.TypeInt, value)
_node.Weight = value
}
if value, ok := _c.mutation.Memory(); ok {
_spec.SetField(host.FieldMemory, field.TypeInt64, value)
_node.Memory = value
}
if value, ok := _c.mutation.Disk(); ok {
_spec.SetField(host.FieldDisk, field.TypeInt64, value)
_node.Disk = value
}
if value, ok := _c.mutation.Os(); ok {
_spec.SetField(host.FieldOs, field.TypeString, value)
_node.Os = value
}
if value, ok := _c.mutation.ExternalIP(); ok {
_spec.SetField(host.FieldExternalIP, field.TypeString, value)
_node.ExternalIP = value
}
if value, ok := _c.mutation.InternalIP(); ok {
_spec.SetField(host.FieldInternalIP, field.TypeString, value)
_node.InternalIP = value
}
if value, ok := _c.mutation.Version(); ok {
_spec.SetField(host.FieldVersion, field.TypeString, value)
_node.Version = value
}
if value, ok := _c.mutation.MachineID(); ok {
_spec.SetField(host.FieldMachineID, field.TypeString, value)
_node.MachineID = value
}
if value, ok := _c.mutation.Remark(); ok {
_spec.SetField(host.FieldRemark, field.TypeString, value)
_node.Remark = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(host.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.UpdatedAt(); ok {
_spec.SetField(host.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if nodes := _c.mutation.VmsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: host.VmsTable,
Columns: []string{host.VmsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: host.UserTable,
Columns: []string{host.UserColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.UserID = nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.GroupsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: true,
Table: host.GroupsTable,
Columns: host.GroupsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
createE := &TeamGroupHostCreate{config: _c.config, mutation: newTeamGroupHostMutation(_c.config, OpCreate)}
createE.defaults()
_, specE := createE.createSpec()
edge.Target.Fields = specE.Fields
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.GitBotsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: host.GitBotsTable,
Columns: []string{host.GitBotsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(gitbot.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.TeamGroupHostsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: true,
Table: host.TeamGroupHostsTable,
Columns: []string{host.TeamGroupHostsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(teamgrouphost.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.Host.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.HostUpsert) {
// SetDeletedAt(v+v).
// }).
// Exec(ctx)
func (_c *HostCreate) OnConflict(opts ...sql.ConflictOption) *HostUpsertOne {
_c.conflict = opts
return &HostUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.Host.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *HostCreate) OnConflictColumns(columns ...string) *HostUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &HostUpsertOne{
create: _c,
}
}
type (
// HostUpsertOne is the builder for "upsert"-ing
// one Host node.
HostUpsertOne struct {
create *HostCreate
}
// HostUpsert is the "OnConflict" setter.
HostUpsert struct {
*sql.UpdateSet
}
)
// SetDeletedAt sets the "deleted_at" field.
func (u *HostUpsert) SetDeletedAt(v time.Time) *HostUpsert {
u.Set(host.FieldDeletedAt, v)
return u
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *HostUpsert) UpdateDeletedAt() *HostUpsert {
u.SetExcluded(host.FieldDeletedAt)
return u
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *HostUpsert) ClearDeletedAt() *HostUpsert {
u.SetNull(host.FieldDeletedAt)
return u
}
// SetUserID sets the "user_id" field.
func (u *HostUpsert) SetUserID(v uuid.UUID) *HostUpsert {
u.Set(host.FieldUserID, v)
return u
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *HostUpsert) UpdateUserID() *HostUpsert {
u.SetExcluded(host.FieldUserID)
return u
}
// SetHostname sets the "hostname" field.
func (u *HostUpsert) SetHostname(v string) *HostUpsert {
u.Set(host.FieldHostname, v)
return u
}
// UpdateHostname sets the "hostname" field to the value that was provided on create.
func (u *HostUpsert) UpdateHostname() *HostUpsert {
u.SetExcluded(host.FieldHostname)
return u
}
// ClearHostname clears the value of the "hostname" field.
func (u *HostUpsert) ClearHostname() *HostUpsert {
u.SetNull(host.FieldHostname)
return u
}
// SetArch sets the "arch" field.
func (u *HostUpsert) SetArch(v string) *HostUpsert {
u.Set(host.FieldArch, v)
return u
}
// UpdateArch sets the "arch" field to the value that was provided on create.
func (u *HostUpsert) UpdateArch() *HostUpsert {
u.SetExcluded(host.FieldArch)
return u
}
// ClearArch clears the value of the "arch" field.
func (u *HostUpsert) ClearArch() *HostUpsert {
u.SetNull(host.FieldArch)
return u
}
// SetCores sets the "cores" field.
func (u *HostUpsert) SetCores(v int) *HostUpsert {
u.Set(host.FieldCores, v)
return u
}
// UpdateCores sets the "cores" field to the value that was provided on create.
func (u *HostUpsert) UpdateCores() *HostUpsert {
u.SetExcluded(host.FieldCores)
return u
}
// AddCores adds v to the "cores" field.
func (u *HostUpsert) AddCores(v int) *HostUpsert {
u.Add(host.FieldCores, v)
return u
}
// ClearCores clears the value of the "cores" field.
func (u *HostUpsert) ClearCores() *HostUpsert {
u.SetNull(host.FieldCores)
return u
}
// SetWeight sets the "weight" field.
func (u *HostUpsert) SetWeight(v int) *HostUpsert {
u.Set(host.FieldWeight, v)
return u
}
// UpdateWeight sets the "weight" field to the value that was provided on create.
func (u *HostUpsert) UpdateWeight() *HostUpsert {
u.SetExcluded(host.FieldWeight)
return u
}
// AddWeight adds v to the "weight" field.
func (u *HostUpsert) AddWeight(v int) *HostUpsert {
u.Add(host.FieldWeight, v)
return u
}
// SetMemory sets the "memory" field.
func (u *HostUpsert) SetMemory(v int64) *HostUpsert {
u.Set(host.FieldMemory, v)
return u
}
// UpdateMemory sets the "memory" field to the value that was provided on create.
func (u *HostUpsert) UpdateMemory() *HostUpsert {
u.SetExcluded(host.FieldMemory)
return u
}
// AddMemory adds v to the "memory" field.
func (u *HostUpsert) AddMemory(v int64) *HostUpsert {
u.Add(host.FieldMemory, v)
return u
}
// ClearMemory clears the value of the "memory" field.
func (u *HostUpsert) ClearMemory() *HostUpsert {
u.SetNull(host.FieldMemory)
return u
}
// SetDisk sets the "disk" field.
func (u *HostUpsert) SetDisk(v int64) *HostUpsert {
u.Set(host.FieldDisk, v)
return u
}
// UpdateDisk sets the "disk" field to the value that was provided on create.
func (u *HostUpsert) UpdateDisk() *HostUpsert {
u.SetExcluded(host.FieldDisk)
return u
}
// AddDisk adds v to the "disk" field.
func (u *HostUpsert) AddDisk(v int64) *HostUpsert {
u.Add(host.FieldDisk, v)
return u
}
// ClearDisk clears the value of the "disk" field.
func (u *HostUpsert) ClearDisk() *HostUpsert {
u.SetNull(host.FieldDisk)
return u
}
// SetOs sets the "os" field.
func (u *HostUpsert) SetOs(v string) *HostUpsert {
u.Set(host.FieldOs, v)
return u
}
// UpdateOs sets the "os" field to the value that was provided on create.
func (u *HostUpsert) UpdateOs() *HostUpsert {
u.SetExcluded(host.FieldOs)
return u
}
// ClearOs clears the value of the "os" field.
func (u *HostUpsert) ClearOs() *HostUpsert {
u.SetNull(host.FieldOs)
return u
}
// SetExternalIP sets the "external_ip" field.
func (u *HostUpsert) SetExternalIP(v string) *HostUpsert {
u.Set(host.FieldExternalIP, v)
return u
}
// UpdateExternalIP sets the "external_ip" field to the value that was provided on create.
func (u *HostUpsert) UpdateExternalIP() *HostUpsert {
u.SetExcluded(host.FieldExternalIP)
return u
}
// ClearExternalIP clears the value of the "external_ip" field.
func (u *HostUpsert) ClearExternalIP() *HostUpsert {
u.SetNull(host.FieldExternalIP)
return u
}
// SetInternalIP sets the "internal_ip" field.
func (u *HostUpsert) SetInternalIP(v string) *HostUpsert {
u.Set(host.FieldInternalIP, v)
return u
}
// UpdateInternalIP sets the "internal_ip" field to the value that was provided on create.
func (u *HostUpsert) UpdateInternalIP() *HostUpsert {
u.SetExcluded(host.FieldInternalIP)
return u
}
// ClearInternalIP clears the value of the "internal_ip" field.
func (u *HostUpsert) ClearInternalIP() *HostUpsert {
u.SetNull(host.FieldInternalIP)
return u
}
// SetVersion sets the "version" field.
func (u *HostUpsert) SetVersion(v string) *HostUpsert {
u.Set(host.FieldVersion, v)
return u
}
// UpdateVersion sets the "version" field to the value that was provided on create.
func (u *HostUpsert) UpdateVersion() *HostUpsert {
u.SetExcluded(host.FieldVersion)
return u
}
// ClearVersion clears the value of the "version" field.
func (u *HostUpsert) ClearVersion() *HostUpsert {
u.SetNull(host.FieldVersion)
return u
}
// SetMachineID sets the "machine_id" field.
func (u *HostUpsert) SetMachineID(v string) *HostUpsert {
u.Set(host.FieldMachineID, v)
return u
}
// UpdateMachineID sets the "machine_id" field to the value that was provided on create.
func (u *HostUpsert) UpdateMachineID() *HostUpsert {
u.SetExcluded(host.FieldMachineID)
return u
}
// ClearMachineID clears the value of the "machine_id" field.
func (u *HostUpsert) ClearMachineID() *HostUpsert {
u.SetNull(host.FieldMachineID)
return u
}
// SetRemark sets the "remark" field.
func (u *HostUpsert) SetRemark(v string) *HostUpsert {
u.Set(host.FieldRemark, v)
return u
}
// UpdateRemark sets the "remark" field to the value that was provided on create.
func (u *HostUpsert) UpdateRemark() *HostUpsert {
u.SetExcluded(host.FieldRemark)
return u
}
// ClearRemark clears the value of the "remark" field.
func (u *HostUpsert) ClearRemark() *HostUpsert {
u.SetNull(host.FieldRemark)
return u
}
// SetCreatedAt sets the "created_at" field.
func (u *HostUpsert) SetCreatedAt(v time.Time) *HostUpsert {
u.Set(host.FieldCreatedAt, v)
return u
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *HostUpsert) UpdateCreatedAt() *HostUpsert {
u.SetExcluded(host.FieldCreatedAt)
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *HostUpsert) SetUpdatedAt(v time.Time) *HostUpsert {
u.Set(host.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *HostUpsert) UpdateUpdatedAt() *HostUpsert {
u.SetExcluded(host.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.Host.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// sql.ResolveWith(func(u *sql.UpdateSet) {
// u.SetIgnore(host.FieldID)
// }),
// ).
// Exec(ctx)
func (u *HostUpsertOne) UpdateNewValues() *HostUpsertOne {
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(host.FieldID)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.Host.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *HostUpsertOne) Ignore() *HostUpsertOne {
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 *HostUpsertOne) DoNothing() *HostUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the HostCreate.OnConflict
// documentation for more info.
func (u *HostUpsertOne) Update(set func(*HostUpsert)) *HostUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&HostUpsert{UpdateSet: update})
}))
return u
}
// SetDeletedAt sets the "deleted_at" field.
func (u *HostUpsertOne) SetDeletedAt(v time.Time) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetDeletedAt(v)
})
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateDeletedAt() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateDeletedAt()
})
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *HostUpsertOne) ClearDeletedAt() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.ClearDeletedAt()
})
}
// SetUserID sets the "user_id" field.
func (u *HostUpsertOne) SetUserID(v uuid.UUID) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetUserID(v)
})
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateUserID() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateUserID()
})
}
// SetHostname sets the "hostname" field.
func (u *HostUpsertOne) SetHostname(v string) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetHostname(v)
})
}
// UpdateHostname sets the "hostname" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateHostname() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateHostname()
})
}
// ClearHostname clears the value of the "hostname" field.
func (u *HostUpsertOne) ClearHostname() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.ClearHostname()
})
}
// SetArch sets the "arch" field.
func (u *HostUpsertOne) SetArch(v string) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetArch(v)
})
}
// UpdateArch sets the "arch" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateArch() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateArch()
})
}
// ClearArch clears the value of the "arch" field.
func (u *HostUpsertOne) ClearArch() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.ClearArch()
})
}
// SetCores sets the "cores" field.
func (u *HostUpsertOne) SetCores(v int) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetCores(v)
})
}
// AddCores adds v to the "cores" field.
func (u *HostUpsertOne) AddCores(v int) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.AddCores(v)
})
}
// UpdateCores sets the "cores" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateCores() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateCores()
})
}
// ClearCores clears the value of the "cores" field.
func (u *HostUpsertOne) ClearCores() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.ClearCores()
})
}
// SetWeight sets the "weight" field.
func (u *HostUpsertOne) SetWeight(v int) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetWeight(v)
})
}
// AddWeight adds v to the "weight" field.
func (u *HostUpsertOne) AddWeight(v int) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.AddWeight(v)
})
}
// UpdateWeight sets the "weight" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateWeight() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateWeight()
})
}
// SetMemory sets the "memory" field.
func (u *HostUpsertOne) SetMemory(v int64) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetMemory(v)
})
}
// AddMemory adds v to the "memory" field.
func (u *HostUpsertOne) AddMemory(v int64) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.AddMemory(v)
})
}
// UpdateMemory sets the "memory" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateMemory() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateMemory()
})
}
// ClearMemory clears the value of the "memory" field.
func (u *HostUpsertOne) ClearMemory() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.ClearMemory()
})
}
// SetDisk sets the "disk" field.
func (u *HostUpsertOne) SetDisk(v int64) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetDisk(v)
})
}
// AddDisk adds v to the "disk" field.
func (u *HostUpsertOne) AddDisk(v int64) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.AddDisk(v)
})
}
// UpdateDisk sets the "disk" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateDisk() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateDisk()
})
}
// ClearDisk clears the value of the "disk" field.
func (u *HostUpsertOne) ClearDisk() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.ClearDisk()
})
}
// SetOs sets the "os" field.
func (u *HostUpsertOne) SetOs(v string) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetOs(v)
})
}
// UpdateOs sets the "os" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateOs() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateOs()
})
}
// ClearOs clears the value of the "os" field.
func (u *HostUpsertOne) ClearOs() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.ClearOs()
})
}
// SetExternalIP sets the "external_ip" field.
func (u *HostUpsertOne) SetExternalIP(v string) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetExternalIP(v)
})
}
// UpdateExternalIP sets the "external_ip" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateExternalIP() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateExternalIP()
})
}
// ClearExternalIP clears the value of the "external_ip" field.
func (u *HostUpsertOne) ClearExternalIP() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.ClearExternalIP()
})
}
// SetInternalIP sets the "internal_ip" field.
func (u *HostUpsertOne) SetInternalIP(v string) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetInternalIP(v)
})
}
// UpdateInternalIP sets the "internal_ip" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateInternalIP() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateInternalIP()
})
}
// ClearInternalIP clears the value of the "internal_ip" field.
func (u *HostUpsertOne) ClearInternalIP() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.ClearInternalIP()
})
}
// SetVersion sets the "version" field.
func (u *HostUpsertOne) SetVersion(v string) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetVersion(v)
})
}
// UpdateVersion sets the "version" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateVersion() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateVersion()
})
}
// ClearVersion clears the value of the "version" field.
func (u *HostUpsertOne) ClearVersion() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.ClearVersion()
})
}
// SetMachineID sets the "machine_id" field.
func (u *HostUpsertOne) SetMachineID(v string) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetMachineID(v)
})
}
// UpdateMachineID sets the "machine_id" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateMachineID() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateMachineID()
})
}
// ClearMachineID clears the value of the "machine_id" field.
func (u *HostUpsertOne) ClearMachineID() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.ClearMachineID()
})
}
// SetRemark sets the "remark" field.
func (u *HostUpsertOne) SetRemark(v string) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetRemark(v)
})
}
// UpdateRemark sets the "remark" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateRemark() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateRemark()
})
}
// ClearRemark clears the value of the "remark" field.
func (u *HostUpsertOne) ClearRemark() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.ClearRemark()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *HostUpsertOne) SetCreatedAt(v time.Time) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateCreatedAt() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateCreatedAt()
})
}
// SetUpdatedAt sets the "updated_at" field.
func (u *HostUpsertOne) SetUpdatedAt(v time.Time) *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *HostUpsertOne) UpdateUpdatedAt() *HostUpsertOne {
return u.Update(func(s *HostUpsert) {
s.UpdateUpdatedAt()
})
}
// Exec executes the query.
func (u *HostUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("db: missing options for HostCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *HostUpsertOne) 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 *HostUpsertOne) ID(ctx context.Context) (id string, 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: HostUpsertOne.ID is not supported by MySQL driver. Use HostUpsertOne.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 *HostUpsertOne) IDX(ctx context.Context) string {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// HostCreateBulk is the builder for creating many Host entities in bulk.
type HostCreateBulk struct {
config
err error
builders []*HostCreate
conflict []sql.ConflictOption
}
// Save creates the Host entities in the database.
func (_c *HostCreateBulk) Save(ctx context.Context) ([]*Host, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*Host, 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.(*HostMutation)
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 *HostCreateBulk) SaveX(ctx context.Context) []*Host {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *HostCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *HostCreateBulk) 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.Host.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.HostUpsert) {
// SetDeletedAt(v+v).
// }).
// Exec(ctx)
func (_c *HostCreateBulk) OnConflict(opts ...sql.ConflictOption) *HostUpsertBulk {
_c.conflict = opts
return &HostUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.Host.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *HostCreateBulk) OnConflictColumns(columns ...string) *HostUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &HostUpsertBulk{
create: _c,
}
}
// HostUpsertBulk is the builder for "upsert"-ing
// a bulk of Host nodes.
type HostUpsertBulk struct {
create *HostCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.Host.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// sql.ResolveWith(func(u *sql.UpdateSet) {
// u.SetIgnore(host.FieldID)
// }),
// ).
// Exec(ctx)
func (u *HostUpsertBulk) UpdateNewValues() *HostUpsertBulk {
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(host.FieldID)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.Host.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *HostUpsertBulk) Ignore() *HostUpsertBulk {
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 *HostUpsertBulk) DoNothing() *HostUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the HostCreateBulk.OnConflict
// documentation for more info.
func (u *HostUpsertBulk) Update(set func(*HostUpsert)) *HostUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&HostUpsert{UpdateSet: update})
}))
return u
}
// SetDeletedAt sets the "deleted_at" field.
func (u *HostUpsertBulk) SetDeletedAt(v time.Time) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetDeletedAt(v)
})
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateDeletedAt() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateDeletedAt()
})
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *HostUpsertBulk) ClearDeletedAt() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.ClearDeletedAt()
})
}
// SetUserID sets the "user_id" field.
func (u *HostUpsertBulk) SetUserID(v uuid.UUID) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetUserID(v)
})
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateUserID() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateUserID()
})
}
// SetHostname sets the "hostname" field.
func (u *HostUpsertBulk) SetHostname(v string) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetHostname(v)
})
}
// UpdateHostname sets the "hostname" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateHostname() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateHostname()
})
}
// ClearHostname clears the value of the "hostname" field.
func (u *HostUpsertBulk) ClearHostname() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.ClearHostname()
})
}
// SetArch sets the "arch" field.
func (u *HostUpsertBulk) SetArch(v string) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetArch(v)
})
}
// UpdateArch sets the "arch" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateArch() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateArch()
})
}
// ClearArch clears the value of the "arch" field.
func (u *HostUpsertBulk) ClearArch() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.ClearArch()
})
}
// SetCores sets the "cores" field.
func (u *HostUpsertBulk) SetCores(v int) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetCores(v)
})
}
// AddCores adds v to the "cores" field.
func (u *HostUpsertBulk) AddCores(v int) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.AddCores(v)
})
}
// UpdateCores sets the "cores" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateCores() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateCores()
})
}
// ClearCores clears the value of the "cores" field.
func (u *HostUpsertBulk) ClearCores() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.ClearCores()
})
}
// SetWeight sets the "weight" field.
func (u *HostUpsertBulk) SetWeight(v int) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetWeight(v)
})
}
// AddWeight adds v to the "weight" field.
func (u *HostUpsertBulk) AddWeight(v int) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.AddWeight(v)
})
}
// UpdateWeight sets the "weight" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateWeight() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateWeight()
})
}
// SetMemory sets the "memory" field.
func (u *HostUpsertBulk) SetMemory(v int64) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetMemory(v)
})
}
// AddMemory adds v to the "memory" field.
func (u *HostUpsertBulk) AddMemory(v int64) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.AddMemory(v)
})
}
// UpdateMemory sets the "memory" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateMemory() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateMemory()
})
}
// ClearMemory clears the value of the "memory" field.
func (u *HostUpsertBulk) ClearMemory() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.ClearMemory()
})
}
// SetDisk sets the "disk" field.
func (u *HostUpsertBulk) SetDisk(v int64) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetDisk(v)
})
}
// AddDisk adds v to the "disk" field.
func (u *HostUpsertBulk) AddDisk(v int64) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.AddDisk(v)
})
}
// UpdateDisk sets the "disk" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateDisk() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateDisk()
})
}
// ClearDisk clears the value of the "disk" field.
func (u *HostUpsertBulk) ClearDisk() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.ClearDisk()
})
}
// SetOs sets the "os" field.
func (u *HostUpsertBulk) SetOs(v string) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetOs(v)
})
}
// UpdateOs sets the "os" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateOs() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateOs()
})
}
// ClearOs clears the value of the "os" field.
func (u *HostUpsertBulk) ClearOs() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.ClearOs()
})
}
// SetExternalIP sets the "external_ip" field.
func (u *HostUpsertBulk) SetExternalIP(v string) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetExternalIP(v)
})
}
// UpdateExternalIP sets the "external_ip" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateExternalIP() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateExternalIP()
})
}
// ClearExternalIP clears the value of the "external_ip" field.
func (u *HostUpsertBulk) ClearExternalIP() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.ClearExternalIP()
})
}
// SetInternalIP sets the "internal_ip" field.
func (u *HostUpsertBulk) SetInternalIP(v string) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetInternalIP(v)
})
}
// UpdateInternalIP sets the "internal_ip" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateInternalIP() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateInternalIP()
})
}
// ClearInternalIP clears the value of the "internal_ip" field.
func (u *HostUpsertBulk) ClearInternalIP() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.ClearInternalIP()
})
}
// SetVersion sets the "version" field.
func (u *HostUpsertBulk) SetVersion(v string) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetVersion(v)
})
}
// UpdateVersion sets the "version" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateVersion() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateVersion()
})
}
// ClearVersion clears the value of the "version" field.
func (u *HostUpsertBulk) ClearVersion() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.ClearVersion()
})
}
// SetMachineID sets the "machine_id" field.
func (u *HostUpsertBulk) SetMachineID(v string) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetMachineID(v)
})
}
// UpdateMachineID sets the "machine_id" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateMachineID() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateMachineID()
})
}
// ClearMachineID clears the value of the "machine_id" field.
func (u *HostUpsertBulk) ClearMachineID() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.ClearMachineID()
})
}
// SetRemark sets the "remark" field.
func (u *HostUpsertBulk) SetRemark(v string) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetRemark(v)
})
}
// UpdateRemark sets the "remark" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateRemark() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateRemark()
})
}
// ClearRemark clears the value of the "remark" field.
func (u *HostUpsertBulk) ClearRemark() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.ClearRemark()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *HostUpsertBulk) SetCreatedAt(v time.Time) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateCreatedAt() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateCreatedAt()
})
}
// SetUpdatedAt sets the "updated_at" field.
func (u *HostUpsertBulk) SetUpdatedAt(v time.Time) *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *HostUpsertBulk) UpdateUpdatedAt() *HostUpsertBulk {
return u.Update(func(s *HostUpsert) {
s.UpdateUpdatedAt()
})
}
// Exec executes the query.
func (u *HostUpsertBulk) 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 HostCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("db: missing options for HostCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *HostUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}