mirror of
https://github.com/holos-run/holos.git
synced 2026-03-20 01:04:59 +00:00
This patch refactors the API to be resource-oriented around one service per resource type. PlatformService, OrganizationService, UserService, etc... Validation is improved to use CEL rules provided by [protovalidate][1]. Place holders for FieldMask and other best practices are added, but are unimplemented as per [API Best Practices][2]. The intent is to set us up well for copying and pasting solid existing examples as we add features. With this patch the server and web app client are both updated to use the refactored API, however the following are not working: 1. Update the model. 2. Field Masks. [1]: https://buf.build/bufbuild/protovalidate [2]: https://protobuf.dev/programming-guides/api/
1161 lines
33 KiB
Go
1161 lines
33 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect"
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/gofrs/uuid"
|
|
"github.com/holos-run/holos/internal/ent/organization"
|
|
"github.com/holos-run/holos/internal/ent/platform"
|
|
"github.com/holos-run/holos/internal/ent/user"
|
|
storage "github.com/holos-run/holos/service/gen/holos/storage/v1alpha1"
|
|
)
|
|
|
|
// PlatformCreate is the builder for creating a Platform entity.
|
|
type PlatformCreate struct {
|
|
config
|
|
mutation *PlatformMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (pc *PlatformCreate) SetCreatedAt(t time.Time) *PlatformCreate {
|
|
pc.mutation.SetCreatedAt(t)
|
|
return pc
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (pc *PlatformCreate) SetNillableCreatedAt(t *time.Time) *PlatformCreate {
|
|
if t != nil {
|
|
pc.SetCreatedAt(*t)
|
|
}
|
|
return pc
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (pc *PlatformCreate) SetUpdatedAt(t time.Time) *PlatformCreate {
|
|
pc.mutation.SetUpdatedAt(t)
|
|
return pc
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (pc *PlatformCreate) SetNillableUpdatedAt(t *time.Time) *PlatformCreate {
|
|
if t != nil {
|
|
pc.SetUpdatedAt(*t)
|
|
}
|
|
return pc
|
|
}
|
|
|
|
// SetCreatedByID sets the "created_by_id" field.
|
|
func (pc *PlatformCreate) SetCreatedByID(u uuid.UUID) *PlatformCreate {
|
|
pc.mutation.SetCreatedByID(u)
|
|
return pc
|
|
}
|
|
|
|
// SetUpdatedByID sets the "updated_by_id" field.
|
|
func (pc *PlatformCreate) SetUpdatedByID(u uuid.UUID) *PlatformCreate {
|
|
pc.mutation.SetUpdatedByID(u)
|
|
return pc
|
|
}
|
|
|
|
// SetOrgID sets the "org_id" field.
|
|
func (pc *PlatformCreate) SetOrgID(u uuid.UUID) *PlatformCreate {
|
|
pc.mutation.SetOrgID(u)
|
|
return pc
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (pc *PlatformCreate) SetName(s string) *PlatformCreate {
|
|
pc.mutation.SetName(s)
|
|
return pc
|
|
}
|
|
|
|
// SetDisplayName sets the "display_name" field.
|
|
func (pc *PlatformCreate) SetDisplayName(s string) *PlatformCreate {
|
|
pc.mutation.SetDisplayName(s)
|
|
return pc
|
|
}
|
|
|
|
// SetForm sets the "form" field.
|
|
func (pc *PlatformCreate) SetForm(s *storage.Form) *PlatformCreate {
|
|
pc.mutation.SetForm(s)
|
|
return pc
|
|
}
|
|
|
|
// SetModel sets the "model" field.
|
|
func (pc *PlatformCreate) SetModel(s *storage.Model) *PlatformCreate {
|
|
pc.mutation.SetModel(s)
|
|
return pc
|
|
}
|
|
|
|
// SetCue sets the "cue" field.
|
|
func (pc *PlatformCreate) SetCue(b []byte) *PlatformCreate {
|
|
pc.mutation.SetCue(b)
|
|
return pc
|
|
}
|
|
|
|
// SetCueDefinition sets the "cue_definition" field.
|
|
func (pc *PlatformCreate) SetCueDefinition(s string) *PlatformCreate {
|
|
pc.mutation.SetCueDefinition(s)
|
|
return pc
|
|
}
|
|
|
|
// SetNillableCueDefinition sets the "cue_definition" field if the given value is not nil.
|
|
func (pc *PlatformCreate) SetNillableCueDefinition(s *string) *PlatformCreate {
|
|
if s != nil {
|
|
pc.SetCueDefinition(*s)
|
|
}
|
|
return pc
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (pc *PlatformCreate) SetID(u uuid.UUID) *PlatformCreate {
|
|
pc.mutation.SetID(u)
|
|
return pc
|
|
}
|
|
|
|
// SetNillableID sets the "id" field if the given value is not nil.
|
|
func (pc *PlatformCreate) SetNillableID(u *uuid.UUID) *PlatformCreate {
|
|
if u != nil {
|
|
pc.SetID(*u)
|
|
}
|
|
return pc
|
|
}
|
|
|
|
// SetCreatorID sets the "creator" edge to the User entity by ID.
|
|
func (pc *PlatformCreate) SetCreatorID(id uuid.UUID) *PlatformCreate {
|
|
pc.mutation.SetCreatorID(id)
|
|
return pc
|
|
}
|
|
|
|
// SetCreator sets the "creator" edge to the User entity.
|
|
func (pc *PlatformCreate) SetCreator(u *User) *PlatformCreate {
|
|
return pc.SetCreatorID(u.ID)
|
|
}
|
|
|
|
// SetEditorID sets the "editor" edge to the User entity by ID.
|
|
func (pc *PlatformCreate) SetEditorID(id uuid.UUID) *PlatformCreate {
|
|
pc.mutation.SetEditorID(id)
|
|
return pc
|
|
}
|
|
|
|
// SetEditor sets the "editor" edge to the User entity.
|
|
func (pc *PlatformCreate) SetEditor(u *User) *PlatformCreate {
|
|
return pc.SetEditorID(u.ID)
|
|
}
|
|
|
|
// SetOrganizationID sets the "organization" edge to the Organization entity by ID.
|
|
func (pc *PlatformCreate) SetOrganizationID(id uuid.UUID) *PlatformCreate {
|
|
pc.mutation.SetOrganizationID(id)
|
|
return pc
|
|
}
|
|
|
|
// SetOrganization sets the "organization" edge to the Organization entity.
|
|
func (pc *PlatformCreate) SetOrganization(o *Organization) *PlatformCreate {
|
|
return pc.SetOrganizationID(o.ID)
|
|
}
|
|
|
|
// Mutation returns the PlatformMutation object of the builder.
|
|
func (pc *PlatformCreate) Mutation() *PlatformMutation {
|
|
return pc.mutation
|
|
}
|
|
|
|
// Save creates the Platform in the database.
|
|
func (pc *PlatformCreate) Save(ctx context.Context) (*Platform, error) {
|
|
pc.defaults()
|
|
return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (pc *PlatformCreate) SaveX(ctx context.Context) *Platform {
|
|
v, err := pc.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (pc *PlatformCreate) Exec(ctx context.Context) error {
|
|
_, err := pc.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (pc *PlatformCreate) ExecX(ctx context.Context) {
|
|
if err := pc.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (pc *PlatformCreate) defaults() {
|
|
if _, ok := pc.mutation.CreatedAt(); !ok {
|
|
v := platform.DefaultCreatedAt()
|
|
pc.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := pc.mutation.UpdatedAt(); !ok {
|
|
v := platform.DefaultUpdatedAt()
|
|
pc.mutation.SetUpdatedAt(v)
|
|
}
|
|
if _, ok := pc.mutation.ID(); !ok {
|
|
v := platform.DefaultID()
|
|
pc.mutation.SetID(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (pc *PlatformCreate) check() error {
|
|
if _, ok := pc.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Platform.created_at"`)}
|
|
}
|
|
if _, ok := pc.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Platform.updated_at"`)}
|
|
}
|
|
if _, ok := pc.mutation.CreatedByID(); !ok {
|
|
return &ValidationError{Name: "created_by_id", err: errors.New(`ent: missing required field "Platform.created_by_id"`)}
|
|
}
|
|
if _, ok := pc.mutation.UpdatedByID(); !ok {
|
|
return &ValidationError{Name: "updated_by_id", err: errors.New(`ent: missing required field "Platform.updated_by_id"`)}
|
|
}
|
|
if _, ok := pc.mutation.OrgID(); !ok {
|
|
return &ValidationError{Name: "org_id", err: errors.New(`ent: missing required field "Platform.org_id"`)}
|
|
}
|
|
if _, ok := pc.mutation.Name(); !ok {
|
|
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Platform.name"`)}
|
|
}
|
|
if v, ok := pc.mutation.Name(); ok {
|
|
if err := platform.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Platform.name": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := pc.mutation.DisplayName(); !ok {
|
|
return &ValidationError{Name: "display_name", err: errors.New(`ent: missing required field "Platform.display_name"`)}
|
|
}
|
|
if _, ok := pc.mutation.CreatorID(); !ok {
|
|
return &ValidationError{Name: "creator", err: errors.New(`ent: missing required edge "Platform.creator"`)}
|
|
}
|
|
if _, ok := pc.mutation.EditorID(); !ok {
|
|
return &ValidationError{Name: "editor", err: errors.New(`ent: missing required edge "Platform.editor"`)}
|
|
}
|
|
if _, ok := pc.mutation.OrganizationID(); !ok {
|
|
return &ValidationError{Name: "organization", err: errors.New(`ent: missing required edge "Platform.organization"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (pc *PlatformCreate) sqlSave(ctx context.Context) (*Platform, error) {
|
|
if err := pc.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := pc.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, pc.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
|
|
}
|
|
}
|
|
pc.mutation.id = &_node.ID
|
|
pc.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (pc *PlatformCreate) createSpec() (*Platform, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &Platform{config: pc.config}
|
|
_spec = sqlgraph.NewCreateSpec(platform.Table, sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID))
|
|
)
|
|
_spec.OnConflict = pc.conflict
|
|
if id, ok := pc.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = &id
|
|
}
|
|
if value, ok := pc.mutation.CreatedAt(); ok {
|
|
_spec.SetField(platform.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := pc.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(platform.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if value, ok := pc.mutation.Name(); ok {
|
|
_spec.SetField(platform.FieldName, field.TypeString, value)
|
|
_node.Name = value
|
|
}
|
|
if value, ok := pc.mutation.DisplayName(); ok {
|
|
_spec.SetField(platform.FieldDisplayName, field.TypeString, value)
|
|
_node.DisplayName = value
|
|
}
|
|
if value, ok := pc.mutation.Form(); ok {
|
|
_spec.SetField(platform.FieldForm, field.TypeJSON, value)
|
|
_node.Form = value
|
|
}
|
|
if value, ok := pc.mutation.Model(); ok {
|
|
_spec.SetField(platform.FieldModel, field.TypeJSON, value)
|
|
_node.Model = value
|
|
}
|
|
if value, ok := pc.mutation.Cue(); ok {
|
|
_spec.SetField(platform.FieldCue, field.TypeBytes, value)
|
|
_node.Cue = value
|
|
}
|
|
if value, ok := pc.mutation.CueDefinition(); ok {
|
|
_spec.SetField(platform.FieldCueDefinition, field.TypeString, value)
|
|
_node.CueDefinition = value
|
|
}
|
|
if nodes := pc.mutation.CreatorIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: platform.CreatorTable,
|
|
Columns: []string{platform.CreatorColumn},
|
|
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.CreatedByID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := pc.mutation.EditorIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: platform.EditorTable,
|
|
Columns: []string{platform.EditorColumn},
|
|
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.UpdatedByID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := pc.mutation.OrganizationIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: platform.OrganizationTable,
|
|
Columns: []string{platform.OrganizationColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.OrgID = 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.Platform.Create().
|
|
// SetCreatedAt(v).
|
|
// OnConflict(
|
|
// // Update the row with the new values
|
|
// // the was proposed for insertion.
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// // Override some of the fields with custom
|
|
// // update values.
|
|
// Update(func(u *ent.PlatformUpsert) {
|
|
// SetCreatedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (pc *PlatformCreate) OnConflict(opts ...sql.ConflictOption) *PlatformUpsertOne {
|
|
pc.conflict = opts
|
|
return &PlatformUpsertOne{
|
|
create: pc,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.Platform.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (pc *PlatformCreate) OnConflictColumns(columns ...string) *PlatformUpsertOne {
|
|
pc.conflict = append(pc.conflict, sql.ConflictColumns(columns...))
|
|
return &PlatformUpsertOne{
|
|
create: pc,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// PlatformUpsertOne is the builder for "upsert"-ing
|
|
// one Platform node.
|
|
PlatformUpsertOne struct {
|
|
create *PlatformCreate
|
|
}
|
|
|
|
// PlatformUpsert is the "OnConflict" setter.
|
|
PlatformUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *PlatformUpsert) SetUpdatedAt(v time.Time) *PlatformUpsert {
|
|
u.Set(platform.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *PlatformUpsert) UpdateUpdatedAt() *PlatformUpsert {
|
|
u.SetExcluded(platform.FieldUpdatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedByID sets the "updated_by_id" field.
|
|
func (u *PlatformUpsert) SetUpdatedByID(v uuid.UUID) *PlatformUpsert {
|
|
u.Set(platform.FieldUpdatedByID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedByID sets the "updated_by_id" field to the value that was provided on create.
|
|
func (u *PlatformUpsert) UpdateUpdatedByID() *PlatformUpsert {
|
|
u.SetExcluded(platform.FieldUpdatedByID)
|
|
return u
|
|
}
|
|
|
|
// SetOrgID sets the "org_id" field.
|
|
func (u *PlatformUpsert) SetOrgID(v uuid.UUID) *PlatformUpsert {
|
|
u.Set(platform.FieldOrgID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateOrgID sets the "org_id" field to the value that was provided on create.
|
|
func (u *PlatformUpsert) UpdateOrgID() *PlatformUpsert {
|
|
u.SetExcluded(platform.FieldOrgID)
|
|
return u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *PlatformUpsert) SetName(v string) *PlatformUpsert {
|
|
u.Set(platform.FieldName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *PlatformUpsert) UpdateName() *PlatformUpsert {
|
|
u.SetExcluded(platform.FieldName)
|
|
return u
|
|
}
|
|
|
|
// SetDisplayName sets the "display_name" field.
|
|
func (u *PlatformUpsert) SetDisplayName(v string) *PlatformUpsert {
|
|
u.Set(platform.FieldDisplayName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDisplayName sets the "display_name" field to the value that was provided on create.
|
|
func (u *PlatformUpsert) UpdateDisplayName() *PlatformUpsert {
|
|
u.SetExcluded(platform.FieldDisplayName)
|
|
return u
|
|
}
|
|
|
|
// SetForm sets the "form" field.
|
|
func (u *PlatformUpsert) SetForm(v *storage.Form) *PlatformUpsert {
|
|
u.Set(platform.FieldForm, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateForm sets the "form" field to the value that was provided on create.
|
|
func (u *PlatformUpsert) UpdateForm() *PlatformUpsert {
|
|
u.SetExcluded(platform.FieldForm)
|
|
return u
|
|
}
|
|
|
|
// ClearForm clears the value of the "form" field.
|
|
func (u *PlatformUpsert) ClearForm() *PlatformUpsert {
|
|
u.SetNull(platform.FieldForm)
|
|
return u
|
|
}
|
|
|
|
// SetModel sets the "model" field.
|
|
func (u *PlatformUpsert) SetModel(v *storage.Model) *PlatformUpsert {
|
|
u.Set(platform.FieldModel, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateModel sets the "model" field to the value that was provided on create.
|
|
func (u *PlatformUpsert) UpdateModel() *PlatformUpsert {
|
|
u.SetExcluded(platform.FieldModel)
|
|
return u
|
|
}
|
|
|
|
// ClearModel clears the value of the "model" field.
|
|
func (u *PlatformUpsert) ClearModel() *PlatformUpsert {
|
|
u.SetNull(platform.FieldModel)
|
|
return u
|
|
}
|
|
|
|
// SetCue sets the "cue" field.
|
|
func (u *PlatformUpsert) SetCue(v []byte) *PlatformUpsert {
|
|
u.Set(platform.FieldCue, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCue sets the "cue" field to the value that was provided on create.
|
|
func (u *PlatformUpsert) UpdateCue() *PlatformUpsert {
|
|
u.SetExcluded(platform.FieldCue)
|
|
return u
|
|
}
|
|
|
|
// ClearCue clears the value of the "cue" field.
|
|
func (u *PlatformUpsert) ClearCue() *PlatformUpsert {
|
|
u.SetNull(platform.FieldCue)
|
|
return u
|
|
}
|
|
|
|
// SetCueDefinition sets the "cue_definition" field.
|
|
func (u *PlatformUpsert) SetCueDefinition(v string) *PlatformUpsert {
|
|
u.Set(platform.FieldCueDefinition, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCueDefinition sets the "cue_definition" field to the value that was provided on create.
|
|
func (u *PlatformUpsert) UpdateCueDefinition() *PlatformUpsert {
|
|
u.SetExcluded(platform.FieldCueDefinition)
|
|
return u
|
|
}
|
|
|
|
// ClearCueDefinition clears the value of the "cue_definition" field.
|
|
func (u *PlatformUpsert) ClearCueDefinition() *PlatformUpsert {
|
|
u.SetNull(platform.FieldCueDefinition)
|
|
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.Platform.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(platform.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *PlatformUpsertOne) UpdateNewValues() *PlatformUpsertOne {
|
|
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(platform.FieldID)
|
|
}
|
|
if _, exists := u.create.mutation.CreatedAt(); exists {
|
|
s.SetIgnore(platform.FieldCreatedAt)
|
|
}
|
|
if _, exists := u.create.mutation.CreatedByID(); exists {
|
|
s.SetIgnore(platform.FieldCreatedByID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.Platform.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *PlatformUpsertOne) Ignore() *PlatformUpsertOne {
|
|
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 *PlatformUpsertOne) DoNothing() *PlatformUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the PlatformCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *PlatformUpsertOne) Update(set func(*PlatformUpsert)) *PlatformUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&PlatformUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *PlatformUpsertOne) SetUpdatedAt(v time.Time) *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *PlatformUpsertOne) UpdateUpdatedAt() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedByID sets the "updated_by_id" field.
|
|
func (u *PlatformUpsertOne) SetUpdatedByID(v uuid.UUID) *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetUpdatedByID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedByID sets the "updated_by_id" field to the value that was provided on create.
|
|
func (u *PlatformUpsertOne) UpdateUpdatedByID() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateUpdatedByID()
|
|
})
|
|
}
|
|
|
|
// SetOrgID sets the "org_id" field.
|
|
func (u *PlatformUpsertOne) SetOrgID(v uuid.UUID) *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetOrgID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOrgID sets the "org_id" field to the value that was provided on create.
|
|
func (u *PlatformUpsertOne) UpdateOrgID() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateOrgID()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *PlatformUpsertOne) SetName(v string) *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *PlatformUpsertOne) UpdateName() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetDisplayName sets the "display_name" field.
|
|
func (u *PlatformUpsertOne) SetDisplayName(v string) *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetDisplayName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDisplayName sets the "display_name" field to the value that was provided on create.
|
|
func (u *PlatformUpsertOne) UpdateDisplayName() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateDisplayName()
|
|
})
|
|
}
|
|
|
|
// SetForm sets the "form" field.
|
|
func (u *PlatformUpsertOne) SetForm(v *storage.Form) *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetForm(v)
|
|
})
|
|
}
|
|
|
|
// UpdateForm sets the "form" field to the value that was provided on create.
|
|
func (u *PlatformUpsertOne) UpdateForm() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateForm()
|
|
})
|
|
}
|
|
|
|
// ClearForm clears the value of the "form" field.
|
|
func (u *PlatformUpsertOne) ClearForm() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.ClearForm()
|
|
})
|
|
}
|
|
|
|
// SetModel sets the "model" field.
|
|
func (u *PlatformUpsertOne) SetModel(v *storage.Model) *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetModel(v)
|
|
})
|
|
}
|
|
|
|
// UpdateModel sets the "model" field to the value that was provided on create.
|
|
func (u *PlatformUpsertOne) UpdateModel() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateModel()
|
|
})
|
|
}
|
|
|
|
// ClearModel clears the value of the "model" field.
|
|
func (u *PlatformUpsertOne) ClearModel() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.ClearModel()
|
|
})
|
|
}
|
|
|
|
// SetCue sets the "cue" field.
|
|
func (u *PlatformUpsertOne) SetCue(v []byte) *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetCue(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCue sets the "cue" field to the value that was provided on create.
|
|
func (u *PlatformUpsertOne) UpdateCue() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateCue()
|
|
})
|
|
}
|
|
|
|
// ClearCue clears the value of the "cue" field.
|
|
func (u *PlatformUpsertOne) ClearCue() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.ClearCue()
|
|
})
|
|
}
|
|
|
|
// SetCueDefinition sets the "cue_definition" field.
|
|
func (u *PlatformUpsertOne) SetCueDefinition(v string) *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetCueDefinition(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCueDefinition sets the "cue_definition" field to the value that was provided on create.
|
|
func (u *PlatformUpsertOne) UpdateCueDefinition() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateCueDefinition()
|
|
})
|
|
}
|
|
|
|
// ClearCueDefinition clears the value of the "cue_definition" field.
|
|
func (u *PlatformUpsertOne) ClearCueDefinition() *PlatformUpsertOne {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.ClearCueDefinition()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *PlatformUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for PlatformCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *PlatformUpsertOne) 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 *PlatformUpsertOne) 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: PlatformUpsertOne.ID is not supported by MySQL driver. Use PlatformUpsertOne.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 *PlatformUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// PlatformCreateBulk is the builder for creating many Platform entities in bulk.
|
|
type PlatformCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*PlatformCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the Platform entities in the database.
|
|
func (pcb *PlatformCreateBulk) Save(ctx context.Context) ([]*Platform, error) {
|
|
if pcb.err != nil {
|
|
return nil, pcb.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(pcb.builders))
|
|
nodes := make([]*Platform, len(pcb.builders))
|
|
mutators := make([]Mutator, len(pcb.builders))
|
|
for i := range pcb.builders {
|
|
func(i int, root context.Context) {
|
|
builder := pcb.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*PlatformMutation)
|
|
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, pcb.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
spec.OnConflict = pcb.conflict
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, pcb.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, pcb.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (pcb *PlatformCreateBulk) SaveX(ctx context.Context) []*Platform {
|
|
v, err := pcb.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (pcb *PlatformCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := pcb.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (pcb *PlatformCreateBulk) ExecX(ctx context.Context) {
|
|
if err := pcb.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.Platform.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.PlatformUpsert) {
|
|
// SetCreatedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (pcb *PlatformCreateBulk) OnConflict(opts ...sql.ConflictOption) *PlatformUpsertBulk {
|
|
pcb.conflict = opts
|
|
return &PlatformUpsertBulk{
|
|
create: pcb,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.Platform.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (pcb *PlatformCreateBulk) OnConflictColumns(columns ...string) *PlatformUpsertBulk {
|
|
pcb.conflict = append(pcb.conflict, sql.ConflictColumns(columns...))
|
|
return &PlatformUpsertBulk{
|
|
create: pcb,
|
|
}
|
|
}
|
|
|
|
// PlatformUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of Platform nodes.
|
|
type PlatformUpsertBulk struct {
|
|
create *PlatformCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.Platform.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(platform.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *PlatformUpsertBulk) UpdateNewValues() *PlatformUpsertBulk {
|
|
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(platform.FieldID)
|
|
}
|
|
if _, exists := b.mutation.CreatedAt(); exists {
|
|
s.SetIgnore(platform.FieldCreatedAt)
|
|
}
|
|
if _, exists := b.mutation.CreatedByID(); exists {
|
|
s.SetIgnore(platform.FieldCreatedByID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.Platform.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *PlatformUpsertBulk) Ignore() *PlatformUpsertBulk {
|
|
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 *PlatformUpsertBulk) DoNothing() *PlatformUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the PlatformCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *PlatformUpsertBulk) Update(set func(*PlatformUpsert)) *PlatformUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&PlatformUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *PlatformUpsertBulk) SetUpdatedAt(v time.Time) *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *PlatformUpsertBulk) UpdateUpdatedAt() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedByID sets the "updated_by_id" field.
|
|
func (u *PlatformUpsertBulk) SetUpdatedByID(v uuid.UUID) *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetUpdatedByID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedByID sets the "updated_by_id" field to the value that was provided on create.
|
|
func (u *PlatformUpsertBulk) UpdateUpdatedByID() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateUpdatedByID()
|
|
})
|
|
}
|
|
|
|
// SetOrgID sets the "org_id" field.
|
|
func (u *PlatformUpsertBulk) SetOrgID(v uuid.UUID) *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetOrgID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOrgID sets the "org_id" field to the value that was provided on create.
|
|
func (u *PlatformUpsertBulk) UpdateOrgID() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateOrgID()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *PlatformUpsertBulk) SetName(v string) *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *PlatformUpsertBulk) UpdateName() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetDisplayName sets the "display_name" field.
|
|
func (u *PlatformUpsertBulk) SetDisplayName(v string) *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetDisplayName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDisplayName sets the "display_name" field to the value that was provided on create.
|
|
func (u *PlatformUpsertBulk) UpdateDisplayName() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateDisplayName()
|
|
})
|
|
}
|
|
|
|
// SetForm sets the "form" field.
|
|
func (u *PlatformUpsertBulk) SetForm(v *storage.Form) *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetForm(v)
|
|
})
|
|
}
|
|
|
|
// UpdateForm sets the "form" field to the value that was provided on create.
|
|
func (u *PlatformUpsertBulk) UpdateForm() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateForm()
|
|
})
|
|
}
|
|
|
|
// ClearForm clears the value of the "form" field.
|
|
func (u *PlatformUpsertBulk) ClearForm() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.ClearForm()
|
|
})
|
|
}
|
|
|
|
// SetModel sets the "model" field.
|
|
func (u *PlatformUpsertBulk) SetModel(v *storage.Model) *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetModel(v)
|
|
})
|
|
}
|
|
|
|
// UpdateModel sets the "model" field to the value that was provided on create.
|
|
func (u *PlatformUpsertBulk) UpdateModel() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateModel()
|
|
})
|
|
}
|
|
|
|
// ClearModel clears the value of the "model" field.
|
|
func (u *PlatformUpsertBulk) ClearModel() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.ClearModel()
|
|
})
|
|
}
|
|
|
|
// SetCue sets the "cue" field.
|
|
func (u *PlatformUpsertBulk) SetCue(v []byte) *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetCue(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCue sets the "cue" field to the value that was provided on create.
|
|
func (u *PlatformUpsertBulk) UpdateCue() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateCue()
|
|
})
|
|
}
|
|
|
|
// ClearCue clears the value of the "cue" field.
|
|
func (u *PlatformUpsertBulk) ClearCue() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.ClearCue()
|
|
})
|
|
}
|
|
|
|
// SetCueDefinition sets the "cue_definition" field.
|
|
func (u *PlatformUpsertBulk) SetCueDefinition(v string) *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.SetCueDefinition(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCueDefinition sets the "cue_definition" field to the value that was provided on create.
|
|
func (u *PlatformUpsertBulk) UpdateCueDefinition() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.UpdateCueDefinition()
|
|
})
|
|
}
|
|
|
|
// ClearCueDefinition clears the value of the "cue_definition" field.
|
|
func (u *PlatformUpsertBulk) ClearCueDefinition() *PlatformUpsertBulk {
|
|
return u.Update(func(s *PlatformUpsert) {
|
|
s.ClearCueDefinition()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *PlatformUpsertBulk) Exec(ctx context.Context) error {
|
|
if u.create.err != nil {
|
|
return u.create.err
|
|
}
|
|
for i, b := range u.create.builders {
|
|
if len(b.conflict) != 0 {
|
|
return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the PlatformCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for PlatformCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *PlatformUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|