|
@@ -0,0 +1,965 @@
|
|
|
+// Code generated by ent, DO NOT EDIT.
|
|
|
+
|
|
|
+package ent
|
|
|
+
|
|
|
+import (
|
|
|
+ "context"
|
|
|
+ "errors"
|
|
|
+ "fmt"
|
|
|
+ "time"
|
|
|
+ "wechat-api/ent/allocagent"
|
|
|
+
|
|
|
+ "entgo.io/ent/dialect/sql"
|
|
|
+ "entgo.io/ent/dialect/sql/sqlgraph"
|
|
|
+ "entgo.io/ent/schema/field"
|
|
|
+)
|
|
|
+
|
|
|
+// AllocAgentCreate is the builder for creating a AllocAgent entity.
|
|
|
+type AllocAgentCreate struct {
|
|
|
+ config
|
|
|
+ mutation *AllocAgentMutation
|
|
|
+ hooks []Hook
|
|
|
+ conflict []sql.ConflictOption
|
|
|
+}
|
|
|
+
|
|
|
+// SetCreatedAt sets the "created_at" field.
|
|
|
+func (aac *AllocAgentCreate) SetCreatedAt(t time.Time) *AllocAgentCreate {
|
|
|
+ aac.mutation.SetCreatedAt(t)
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
|
+func (aac *AllocAgentCreate) SetNillableCreatedAt(t *time.Time) *AllocAgentCreate {
|
|
|
+ if t != nil {
|
|
|
+ aac.SetCreatedAt(*t)
|
|
|
+ }
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (aac *AllocAgentCreate) SetUpdatedAt(t time.Time) *AllocAgentCreate {
|
|
|
+ aac.mutation.SetUpdatedAt(t)
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
|
+func (aac *AllocAgentCreate) SetNillableUpdatedAt(t *time.Time) *AllocAgentCreate {
|
|
|
+ if t != nil {
|
|
|
+ aac.SetUpdatedAt(*t)
|
|
|
+ }
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (aac *AllocAgentCreate) SetDeletedAt(t time.Time) *AllocAgentCreate {
|
|
|
+ aac.mutation.SetDeletedAt(t)
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
|
+func (aac *AllocAgentCreate) SetNillableDeletedAt(t *time.Time) *AllocAgentCreate {
|
|
|
+ if t != nil {
|
|
|
+ aac.SetDeletedAt(*t)
|
|
|
+ }
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetUserID sets the "user_id" field.
|
|
|
+func (aac *AllocAgentCreate) SetUserID(s string) *AllocAgentCreate {
|
|
|
+ aac.mutation.SetUserID(s)
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
|
+func (aac *AllocAgentCreate) SetNillableUserID(s *string) *AllocAgentCreate {
|
|
|
+ if s != nil {
|
|
|
+ aac.SetUserID(*s)
|
|
|
+ }
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetOrganizationID sets the "organization_id" field.
|
|
|
+func (aac *AllocAgentCreate) SetOrganizationID(u uint64) *AllocAgentCreate {
|
|
|
+ aac.mutation.SetOrganizationID(u)
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
|
|
|
+func (aac *AllocAgentCreate) SetNillableOrganizationID(u *uint64) *AllocAgentCreate {
|
|
|
+ if u != nil {
|
|
|
+ aac.SetOrganizationID(*u)
|
|
|
+ }
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetAgents sets the "agents" field.
|
|
|
+func (aac *AllocAgentCreate) SetAgents(u []uint64) *AllocAgentCreate {
|
|
|
+ aac.mutation.SetAgents(u)
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (aac *AllocAgentCreate) SetStatus(i int) *AllocAgentCreate {
|
|
|
+ aac.mutation.SetStatus(i)
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
|
+func (aac *AllocAgentCreate) SetNillableStatus(i *int) *AllocAgentCreate {
|
|
|
+ if i != nil {
|
|
|
+ aac.SetStatus(*i)
|
|
|
+ }
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// SetID sets the "id" field.
|
|
|
+func (aac *AllocAgentCreate) SetID(u uint64) *AllocAgentCreate {
|
|
|
+ aac.mutation.SetID(u)
|
|
|
+ return aac
|
|
|
+}
|
|
|
+
|
|
|
+// Mutation returns the AllocAgentMutation object of the builder.
|
|
|
+func (aac *AllocAgentCreate) Mutation() *AllocAgentMutation {
|
|
|
+ return aac.mutation
|
|
|
+}
|
|
|
+
|
|
|
+// Save creates the AllocAgent in the database.
|
|
|
+func (aac *AllocAgentCreate) Save(ctx context.Context) (*AllocAgent, error) {
|
|
|
+ if err := aac.defaults(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return withHooks(ctx, aac.sqlSave, aac.mutation, aac.hooks)
|
|
|
+}
|
|
|
+
|
|
|
+// SaveX calls Save and panics if Save returns an error.
|
|
|
+func (aac *AllocAgentCreate) SaveX(ctx context.Context) *AllocAgent {
|
|
|
+ v, err := aac.Save(ctx)
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ return v
|
|
|
+}
|
|
|
+
|
|
|
+// Exec executes the query.
|
|
|
+func (aac *AllocAgentCreate) Exec(ctx context.Context) error {
|
|
|
+ _, err := aac.Save(ctx)
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+// ExecX is like Exec, but panics if an error occurs.
|
|
|
+func (aac *AllocAgentCreate) ExecX(ctx context.Context) {
|
|
|
+ if err := aac.Exec(ctx); err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// defaults sets the default values of the builder before save.
|
|
|
+func (aac *AllocAgentCreate) defaults() error {
|
|
|
+ if _, ok := aac.mutation.CreatedAt(); !ok {
|
|
|
+ if allocagent.DefaultCreatedAt == nil {
|
|
|
+ return fmt.Errorf("ent: uninitialized allocagent.DefaultCreatedAt (forgotten import ent/runtime?)")
|
|
|
+ }
|
|
|
+ v := allocagent.DefaultCreatedAt()
|
|
|
+ aac.mutation.SetCreatedAt(v)
|
|
|
+ }
|
|
|
+ if _, ok := aac.mutation.UpdatedAt(); !ok {
|
|
|
+ if allocagent.DefaultUpdatedAt == nil {
|
|
|
+ return fmt.Errorf("ent: uninitialized allocagent.DefaultUpdatedAt (forgotten import ent/runtime?)")
|
|
|
+ }
|
|
|
+ v := allocagent.DefaultUpdatedAt()
|
|
|
+ aac.mutation.SetUpdatedAt(v)
|
|
|
+ }
|
|
|
+ if _, ok := aac.mutation.UserID(); !ok {
|
|
|
+ v := allocagent.DefaultUserID
|
|
|
+ aac.mutation.SetUserID(v)
|
|
|
+ }
|
|
|
+ if _, ok := aac.mutation.OrganizationID(); !ok {
|
|
|
+ v := allocagent.DefaultOrganizationID
|
|
|
+ aac.mutation.SetOrganizationID(v)
|
|
|
+ }
|
|
|
+ if _, ok := aac.mutation.Status(); !ok {
|
|
|
+ v := allocagent.DefaultStatus
|
|
|
+ aac.mutation.SetStatus(v)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// check runs all checks and user-defined validators on the builder.
|
|
|
+func (aac *AllocAgentCreate) check() error {
|
|
|
+ if _, ok := aac.mutation.CreatedAt(); !ok {
|
|
|
+ return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "AllocAgent.created_at"`)}
|
|
|
+ }
|
|
|
+ if _, ok := aac.mutation.UpdatedAt(); !ok {
|
|
|
+ return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "AllocAgent.updated_at"`)}
|
|
|
+ }
|
|
|
+ if _, ok := aac.mutation.Agents(); !ok {
|
|
|
+ return &ValidationError{Name: "agents", err: errors.New(`ent: missing required field "AllocAgent.agents"`)}
|
|
|
+ }
|
|
|
+ if v, ok := aac.mutation.Status(); ok {
|
|
|
+ if err := allocagent.StatusValidator(v); err != nil {
|
|
|
+ return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "AllocAgent.status": %w`, err)}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (aac *AllocAgentCreate) sqlSave(ctx context.Context) (*AllocAgent, error) {
|
|
|
+ if err := aac.check(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ _node, _spec := aac.createSpec()
|
|
|
+ if err := sqlgraph.CreateNode(ctx, aac.driver, _spec); err != nil {
|
|
|
+ if sqlgraph.IsConstraintError(err) {
|
|
|
+ err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
|
+ }
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if _spec.ID.Value != _node.ID {
|
|
|
+ id := _spec.ID.Value.(int64)
|
|
|
+ _node.ID = uint64(id)
|
|
|
+ }
|
|
|
+ aac.mutation.id = &_node.ID
|
|
|
+ aac.mutation.done = true
|
|
|
+ return _node, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (aac *AllocAgentCreate) createSpec() (*AllocAgent, *sqlgraph.CreateSpec) {
|
|
|
+ var (
|
|
|
+ _node = &AllocAgent{config: aac.config}
|
|
|
+ _spec = sqlgraph.NewCreateSpec(allocagent.Table, sqlgraph.NewFieldSpec(allocagent.FieldID, field.TypeUint64))
|
|
|
+ )
|
|
|
+ _spec.OnConflict = aac.conflict
|
|
|
+ if id, ok := aac.mutation.ID(); ok {
|
|
|
+ _node.ID = id
|
|
|
+ _spec.ID.Value = id
|
|
|
+ }
|
|
|
+ if value, ok := aac.mutation.CreatedAt(); ok {
|
|
|
+ _spec.SetField(allocagent.FieldCreatedAt, field.TypeTime, value)
|
|
|
+ _node.CreatedAt = value
|
|
|
+ }
|
|
|
+ if value, ok := aac.mutation.UpdatedAt(); ok {
|
|
|
+ _spec.SetField(allocagent.FieldUpdatedAt, field.TypeTime, value)
|
|
|
+ _node.UpdatedAt = value
|
|
|
+ }
|
|
|
+ if value, ok := aac.mutation.DeletedAt(); ok {
|
|
|
+ _spec.SetField(allocagent.FieldDeletedAt, field.TypeTime, value)
|
|
|
+ _node.DeletedAt = value
|
|
|
+ }
|
|
|
+ if value, ok := aac.mutation.UserID(); ok {
|
|
|
+ _spec.SetField(allocagent.FieldUserID, field.TypeString, value)
|
|
|
+ _node.UserID = value
|
|
|
+ }
|
|
|
+ if value, ok := aac.mutation.OrganizationID(); ok {
|
|
|
+ _spec.SetField(allocagent.FieldOrganizationID, field.TypeUint64, value)
|
|
|
+ _node.OrganizationID = value
|
|
|
+ }
|
|
|
+ if value, ok := aac.mutation.Agents(); ok {
|
|
|
+ _spec.SetField(allocagent.FieldAgents, field.TypeJSON, value)
|
|
|
+ _node.Agents = value
|
|
|
+ }
|
|
|
+ if value, ok := aac.mutation.Status(); ok {
|
|
|
+ _spec.SetField(allocagent.FieldStatus, field.TypeInt, value)
|
|
|
+ _node.Status = value
|
|
|
+ }
|
|
|
+ return _node, _spec
|
|
|
+}
|
|
|
+
|
|
|
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
|
+// of the `INSERT` statement. For example:
|
|
|
+//
|
|
|
+// client.AllocAgent.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.AllocAgentUpsert) {
|
|
|
+// SetCreatedAt(v+v).
|
|
|
+// }).
|
|
|
+// Exec(ctx)
|
|
|
+func (aac *AllocAgentCreate) OnConflict(opts ...sql.ConflictOption) *AllocAgentUpsertOne {
|
|
|
+ aac.conflict = opts
|
|
|
+ return &AllocAgentUpsertOne{
|
|
|
+ create: aac,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// OnConflictColumns calls `OnConflict` and configures the columns
|
|
|
+// as conflict target. Using this option is equivalent to using:
|
|
|
+//
|
|
|
+// client.AllocAgent.Create().
|
|
|
+// OnConflict(sql.ConflictColumns(columns...)).
|
|
|
+// Exec(ctx)
|
|
|
+func (aac *AllocAgentCreate) OnConflictColumns(columns ...string) *AllocAgentUpsertOne {
|
|
|
+ aac.conflict = append(aac.conflict, sql.ConflictColumns(columns...))
|
|
|
+ return &AllocAgentUpsertOne{
|
|
|
+ create: aac,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type (
|
|
|
+ // AllocAgentUpsertOne is the builder for "upsert"-ing
|
|
|
+ // one AllocAgent node.
|
|
|
+ AllocAgentUpsertOne struct {
|
|
|
+ create *AllocAgentCreate
|
|
|
+ }
|
|
|
+
|
|
|
+ // AllocAgentUpsert is the "OnConflict" setter.
|
|
|
+ AllocAgentUpsert struct {
|
|
|
+ *sql.UpdateSet
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (u *AllocAgentUpsert) SetUpdatedAt(v time.Time) *AllocAgentUpsert {
|
|
|
+ u.Set(allocagent.FieldUpdatedAt, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsert) UpdateUpdatedAt() *AllocAgentUpsert {
|
|
|
+ u.SetExcluded(allocagent.FieldUpdatedAt)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (u *AllocAgentUpsert) SetDeletedAt(v time.Time) *AllocAgentUpsert {
|
|
|
+ u.Set(allocagent.FieldDeletedAt, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsert) UpdateDeletedAt() *AllocAgentUpsert {
|
|
|
+ u.SetExcluded(allocagent.FieldDeletedAt)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
|
+func (u *AllocAgentUpsert) ClearDeletedAt() *AllocAgentUpsert {
|
|
|
+ u.SetNull(allocagent.FieldDeletedAt)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetUserID sets the "user_id" field.
|
|
|
+func (u *AllocAgentUpsert) SetUserID(v string) *AllocAgentUpsert {
|
|
|
+ u.Set(allocagent.FieldUserID, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsert) UpdateUserID() *AllocAgentUpsert {
|
|
|
+ u.SetExcluded(allocagent.FieldUserID)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// ClearUserID clears the value of the "user_id" field.
|
|
|
+func (u *AllocAgentUpsert) ClearUserID() *AllocAgentUpsert {
|
|
|
+ u.SetNull(allocagent.FieldUserID)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetOrganizationID sets the "organization_id" field.
|
|
|
+func (u *AllocAgentUpsert) SetOrganizationID(v uint64) *AllocAgentUpsert {
|
|
|
+ u.Set(allocagent.FieldOrganizationID, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsert) UpdateOrganizationID() *AllocAgentUpsert {
|
|
|
+ u.SetExcluded(allocagent.FieldOrganizationID)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// AddOrganizationID adds v to the "organization_id" field.
|
|
|
+func (u *AllocAgentUpsert) AddOrganizationID(v uint64) *AllocAgentUpsert {
|
|
|
+ u.Add(allocagent.FieldOrganizationID, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// ClearOrganizationID clears the value of the "organization_id" field.
|
|
|
+func (u *AllocAgentUpsert) ClearOrganizationID() *AllocAgentUpsert {
|
|
|
+ u.SetNull(allocagent.FieldOrganizationID)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetAgents sets the "agents" field.
|
|
|
+func (u *AllocAgentUpsert) SetAgents(v []uint64) *AllocAgentUpsert {
|
|
|
+ u.Set(allocagent.FieldAgents, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateAgents sets the "agents" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsert) UpdateAgents() *AllocAgentUpsert {
|
|
|
+ u.SetExcluded(allocagent.FieldAgents)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (u *AllocAgentUpsert) SetStatus(v int) *AllocAgentUpsert {
|
|
|
+ u.Set(allocagent.FieldStatus, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsert) UpdateStatus() *AllocAgentUpsert {
|
|
|
+ u.SetExcluded(allocagent.FieldStatus)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// AddStatus adds v to the "status" field.
|
|
|
+func (u *AllocAgentUpsert) AddStatus(v int) *AllocAgentUpsert {
|
|
|
+ u.Add(allocagent.FieldStatus, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// ClearStatus clears the value of the "status" field.
|
|
|
+func (u *AllocAgentUpsert) ClearStatus() *AllocAgentUpsert {
|
|
|
+ u.SetNull(allocagent.FieldStatus)
|
|
|
+ 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.AllocAgent.Create().
|
|
|
+// OnConflict(
|
|
|
+// sql.ResolveWithNewValues(),
|
|
|
+// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
|
+// u.SetIgnore(allocagent.FieldID)
|
|
|
+// }),
|
|
|
+// ).
|
|
|
+// Exec(ctx)
|
|
|
+func (u *AllocAgentUpsertOne) UpdateNewValues() *AllocAgentUpsertOne {
|
|
|
+ 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(allocagent.FieldID)
|
|
|
+ }
|
|
|
+ if _, exists := u.create.mutation.CreatedAt(); exists {
|
|
|
+ s.SetIgnore(allocagent.FieldCreatedAt)
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// Ignore sets each column to itself in case of conflict.
|
|
|
+// Using this option is equivalent to using:
|
|
|
+//
|
|
|
+// client.AllocAgent.Create().
|
|
|
+// OnConflict(sql.ResolveWithIgnore()).
|
|
|
+// Exec(ctx)
|
|
|
+func (u *AllocAgentUpsertOne) Ignore() *AllocAgentUpsertOne {
|
|
|
+ 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 *AllocAgentUpsertOne) DoNothing() *AllocAgentUpsertOne {
|
|
|
+ u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// Update allows overriding fields `UPDATE` values. See the AllocAgentCreate.OnConflict
|
|
|
+// documentation for more info.
|
|
|
+func (u *AllocAgentUpsertOne) Update(set func(*AllocAgentUpsert)) *AllocAgentUpsertOne {
|
|
|
+ u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
|
+ set(&AllocAgentUpsert{UpdateSet: update})
|
|
|
+ }))
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (u *AllocAgentUpsertOne) SetUpdatedAt(v time.Time) *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.SetUpdatedAt(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsertOne) UpdateUpdatedAt() *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.UpdateUpdatedAt()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (u *AllocAgentUpsertOne) SetDeletedAt(v time.Time) *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.SetDeletedAt(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsertOne) UpdateDeletedAt() *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.UpdateDeletedAt()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
|
+func (u *AllocAgentUpsertOne) ClearDeletedAt() *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.ClearDeletedAt()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetUserID sets the "user_id" field.
|
|
|
+func (u *AllocAgentUpsertOne) SetUserID(v string) *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.SetUserID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsertOne) UpdateUserID() *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.UpdateUserID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearUserID clears the value of the "user_id" field.
|
|
|
+func (u *AllocAgentUpsertOne) ClearUserID() *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.ClearUserID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetOrganizationID sets the "organization_id" field.
|
|
|
+func (u *AllocAgentUpsertOne) SetOrganizationID(v uint64) *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.SetOrganizationID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddOrganizationID adds v to the "organization_id" field.
|
|
|
+func (u *AllocAgentUpsertOne) AddOrganizationID(v uint64) *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.AddOrganizationID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsertOne) UpdateOrganizationID() *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.UpdateOrganizationID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearOrganizationID clears the value of the "organization_id" field.
|
|
|
+func (u *AllocAgentUpsertOne) ClearOrganizationID() *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.ClearOrganizationID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetAgents sets the "agents" field.
|
|
|
+func (u *AllocAgentUpsertOne) SetAgents(v []uint64) *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.SetAgents(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateAgents sets the "agents" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsertOne) UpdateAgents() *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.UpdateAgents()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (u *AllocAgentUpsertOne) SetStatus(v int) *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.SetStatus(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddStatus adds v to the "status" field.
|
|
|
+func (u *AllocAgentUpsertOne) AddStatus(v int) *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.AddStatus(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsertOne) UpdateStatus() *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.UpdateStatus()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearStatus clears the value of the "status" field.
|
|
|
+func (u *AllocAgentUpsertOne) ClearStatus() *AllocAgentUpsertOne {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.ClearStatus()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// Exec executes the query.
|
|
|
+func (u *AllocAgentUpsertOne) Exec(ctx context.Context) error {
|
|
|
+ if len(u.create.conflict) == 0 {
|
|
|
+ return errors.New("ent: missing options for AllocAgentCreate.OnConflict")
|
|
|
+ }
|
|
|
+ return u.create.Exec(ctx)
|
|
|
+}
|
|
|
+
|
|
|
+// ExecX is like Exec, but panics if an error occurs.
|
|
|
+func (u *AllocAgentUpsertOne) 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 *AllocAgentUpsertOne) ID(ctx context.Context) (id uint64, err error) {
|
|
|
+ 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 *AllocAgentUpsertOne) IDX(ctx context.Context) uint64 {
|
|
|
+ id, err := u.ID(ctx)
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ return id
|
|
|
+}
|
|
|
+
|
|
|
+// AllocAgentCreateBulk is the builder for creating many AllocAgent entities in bulk.
|
|
|
+type AllocAgentCreateBulk struct {
|
|
|
+ config
|
|
|
+ err error
|
|
|
+ builders []*AllocAgentCreate
|
|
|
+ conflict []sql.ConflictOption
|
|
|
+}
|
|
|
+
|
|
|
+// Save creates the AllocAgent entities in the database.
|
|
|
+func (aacb *AllocAgentCreateBulk) Save(ctx context.Context) ([]*AllocAgent, error) {
|
|
|
+ if aacb.err != nil {
|
|
|
+ return nil, aacb.err
|
|
|
+ }
|
|
|
+ specs := make([]*sqlgraph.CreateSpec, len(aacb.builders))
|
|
|
+ nodes := make([]*AllocAgent, len(aacb.builders))
|
|
|
+ mutators := make([]Mutator, len(aacb.builders))
|
|
|
+ for i := range aacb.builders {
|
|
|
+ func(i int, root context.Context) {
|
|
|
+ builder := aacb.builders[i]
|
|
|
+ builder.defaults()
|
|
|
+ var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
|
+ mutation, ok := m.(*AllocAgentMutation)
|
|
|
+ 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, aacb.builders[i+1].mutation)
|
|
|
+ } else {
|
|
|
+ spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
|
+ spec.OnConflict = aacb.conflict
|
|
|
+ // Invoke the actual operation on the latest mutation in the chain.
|
|
|
+ if err = sqlgraph.BatchCreate(ctx, aacb.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
|
|
|
+ if specs[i].ID.Value != nil && nodes[i].ID == 0 {
|
|
|
+ id := specs[i].ID.Value.(int64)
|
|
|
+ nodes[i].ID = uint64(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, aacb.builders[0].mutation); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nodes, nil
|
|
|
+}
|
|
|
+
|
|
|
+// SaveX is like Save, but panics if an error occurs.
|
|
|
+func (aacb *AllocAgentCreateBulk) SaveX(ctx context.Context) []*AllocAgent {
|
|
|
+ v, err := aacb.Save(ctx)
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ return v
|
|
|
+}
|
|
|
+
|
|
|
+// Exec executes the query.
|
|
|
+func (aacb *AllocAgentCreateBulk) Exec(ctx context.Context) error {
|
|
|
+ _, err := aacb.Save(ctx)
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+// ExecX is like Exec, but panics if an error occurs.
|
|
|
+func (aacb *AllocAgentCreateBulk) ExecX(ctx context.Context) {
|
|
|
+ if err := aacb.Exec(ctx); err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
|
+// of the `INSERT` statement. For example:
|
|
|
+//
|
|
|
+// client.AllocAgent.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.AllocAgentUpsert) {
|
|
|
+// SetCreatedAt(v+v).
|
|
|
+// }).
|
|
|
+// Exec(ctx)
|
|
|
+func (aacb *AllocAgentCreateBulk) OnConflict(opts ...sql.ConflictOption) *AllocAgentUpsertBulk {
|
|
|
+ aacb.conflict = opts
|
|
|
+ return &AllocAgentUpsertBulk{
|
|
|
+ create: aacb,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// OnConflictColumns calls `OnConflict` and configures the columns
|
|
|
+// as conflict target. Using this option is equivalent to using:
|
|
|
+//
|
|
|
+// client.AllocAgent.Create().
|
|
|
+// OnConflict(sql.ConflictColumns(columns...)).
|
|
|
+// Exec(ctx)
|
|
|
+func (aacb *AllocAgentCreateBulk) OnConflictColumns(columns ...string) *AllocAgentUpsertBulk {
|
|
|
+ aacb.conflict = append(aacb.conflict, sql.ConflictColumns(columns...))
|
|
|
+ return &AllocAgentUpsertBulk{
|
|
|
+ create: aacb,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AllocAgentUpsertBulk is the builder for "upsert"-ing
|
|
|
+// a bulk of AllocAgent nodes.
|
|
|
+type AllocAgentUpsertBulk struct {
|
|
|
+ create *AllocAgentCreateBulk
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateNewValues updates the mutable fields using the new values that
|
|
|
+// were set on create. Using this option is equivalent to using:
|
|
|
+//
|
|
|
+// client.AllocAgent.Create().
|
|
|
+// OnConflict(
|
|
|
+// sql.ResolveWithNewValues(),
|
|
|
+// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
|
+// u.SetIgnore(allocagent.FieldID)
|
|
|
+// }),
|
|
|
+// ).
|
|
|
+// Exec(ctx)
|
|
|
+func (u *AllocAgentUpsertBulk) UpdateNewValues() *AllocAgentUpsertBulk {
|
|
|
+ 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(allocagent.FieldID)
|
|
|
+ }
|
|
|
+ if _, exists := b.mutation.CreatedAt(); exists {
|
|
|
+ s.SetIgnore(allocagent.FieldCreatedAt)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// Ignore sets each column to itself in case of conflict.
|
|
|
+// Using this option is equivalent to using:
|
|
|
+//
|
|
|
+// client.AllocAgent.Create().
|
|
|
+// OnConflict(sql.ResolveWithIgnore()).
|
|
|
+// Exec(ctx)
|
|
|
+func (u *AllocAgentUpsertBulk) Ignore() *AllocAgentUpsertBulk {
|
|
|
+ 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 *AllocAgentUpsertBulk) DoNothing() *AllocAgentUpsertBulk {
|
|
|
+ u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// Update allows overriding fields `UPDATE` values. See the AllocAgentCreateBulk.OnConflict
|
|
|
+// documentation for more info.
|
|
|
+func (u *AllocAgentUpsertBulk) Update(set func(*AllocAgentUpsert)) *AllocAgentUpsertBulk {
|
|
|
+ u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
|
+ set(&AllocAgentUpsert{UpdateSet: update})
|
|
|
+ }))
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (u *AllocAgentUpsertBulk) SetUpdatedAt(v time.Time) *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.SetUpdatedAt(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsertBulk) UpdateUpdatedAt() *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.UpdateUpdatedAt()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (u *AllocAgentUpsertBulk) SetDeletedAt(v time.Time) *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.SetDeletedAt(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsertBulk) UpdateDeletedAt() *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.UpdateDeletedAt()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
|
+func (u *AllocAgentUpsertBulk) ClearDeletedAt() *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.ClearDeletedAt()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetUserID sets the "user_id" field.
|
|
|
+func (u *AllocAgentUpsertBulk) SetUserID(v string) *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.SetUserID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsertBulk) UpdateUserID() *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.UpdateUserID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearUserID clears the value of the "user_id" field.
|
|
|
+func (u *AllocAgentUpsertBulk) ClearUserID() *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.ClearUserID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetOrganizationID sets the "organization_id" field.
|
|
|
+func (u *AllocAgentUpsertBulk) SetOrganizationID(v uint64) *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.SetOrganizationID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddOrganizationID adds v to the "organization_id" field.
|
|
|
+func (u *AllocAgentUpsertBulk) AddOrganizationID(v uint64) *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.AddOrganizationID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsertBulk) UpdateOrganizationID() *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.UpdateOrganizationID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearOrganizationID clears the value of the "organization_id" field.
|
|
|
+func (u *AllocAgentUpsertBulk) ClearOrganizationID() *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.ClearOrganizationID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetAgents sets the "agents" field.
|
|
|
+func (u *AllocAgentUpsertBulk) SetAgents(v []uint64) *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.SetAgents(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateAgents sets the "agents" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsertBulk) UpdateAgents() *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.UpdateAgents()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (u *AllocAgentUpsertBulk) SetStatus(v int) *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.SetStatus(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddStatus adds v to the "status" field.
|
|
|
+func (u *AllocAgentUpsertBulk) AddStatus(v int) *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.AddStatus(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
|
+func (u *AllocAgentUpsertBulk) UpdateStatus() *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.UpdateStatus()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearStatus clears the value of the "status" field.
|
|
|
+func (u *AllocAgentUpsertBulk) ClearStatus() *AllocAgentUpsertBulk {
|
|
|
+ return u.Update(func(s *AllocAgentUpsert) {
|
|
|
+ s.ClearStatus()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// Exec executes the query.
|
|
|
+func (u *AllocAgentUpsertBulk) 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 AllocAgentCreateBulk instead", i)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(u.create.conflict) == 0 {
|
|
|
+ return errors.New("ent: missing options for AllocAgentCreateBulk.OnConflict")
|
|
|
+ }
|
|
|
+ return u.create.Exec(ctx)
|
|
|
+}
|
|
|
+
|
|
|
+// ExecX is like Exec, but panics if an error occurs.
|
|
|
+func (u *AllocAgentUpsertBulk) ExecX(ctx context.Context) {
|
|
|
+ if err := u.create.Exec(ctx); err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+}
|