mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1582 lines
48 KiB
Go
1582 lines
48 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/agentskill"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentskillrepo"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentskillversion"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// AgentSkillCreate is the builder for creating a AgentSkill entity.
|
|
type AgentSkillCreate struct {
|
|
config
|
|
mutation *AgentSkillMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetRepoID sets the "repo_id" field.
|
|
func (_c *AgentSkillCreate) SetRepoID(v uuid.UUID) *AgentSkillCreate {
|
|
_c.mutation.SetRepoID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_c *AgentSkillCreate) SetName(v string) *AgentSkillCreate {
|
|
_c.mutation.SetName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_c *AgentSkillCreate) SetDescription(v string) *AgentSkillCreate {
|
|
_c.mutation.SetDescription(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableDescription(v *string) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetDescription(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetScopeType sets the "scope_type" field.
|
|
func (_c *AgentSkillCreate) SetScopeType(v agentskill.ScopeType) *AgentSkillCreate {
|
|
_c.mutation.SetScopeType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableScopeType sets the "scope_type" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableScopeType(v *agentskill.ScopeType) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetScopeType(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetScopeID sets the "scope_id" field.
|
|
func (_c *AgentSkillCreate) SetScopeID(v string) *AgentSkillCreate {
|
|
_c.mutation.SetScopeID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableScopeID sets the "scope_id" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableScopeID(v *string) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetScopeID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedBy sets the "created_by" field.
|
|
func (_c *AgentSkillCreate) SetCreatedBy(v uuid.UUID) *AgentSkillCreate {
|
|
_c.mutation.SetCreatedBy(v)
|
|
return _c
|
|
}
|
|
|
|
// SetActiveVersionID sets the "active_version_id" field.
|
|
func (_c *AgentSkillCreate) SetActiveVersionID(v uuid.UUID) *AgentSkillCreate {
|
|
_c.mutation.SetActiveVersionID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableActiveVersionID(v *uuid.UUID) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetActiveVersionID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetIsForceDelivery sets the "is_force_delivery" field.
|
|
func (_c *AgentSkillCreate) SetIsForceDelivery(v bool) *AgentSkillCreate {
|
|
_c.mutation.SetIsForceDelivery(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableIsForceDelivery sets the "is_force_delivery" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableIsForceDelivery(v *bool) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetIsForceDelivery(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetIsOrphan sets the "is_orphan" field.
|
|
func (_c *AgentSkillCreate) SetIsOrphan(v bool) *AgentSkillCreate {
|
|
_c.mutation.SetIsOrphan(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableIsOrphan sets the "is_orphan" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableIsOrphan(v *bool) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetIsOrphan(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetIsDeleted sets the "is_deleted" field.
|
|
func (_c *AgentSkillCreate) SetIsDeleted(v bool) *AgentSkillCreate {
|
|
_c.mutation.SetIsDeleted(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableIsDeleted(v *bool) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetIsDeleted(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (_c *AgentSkillCreate) SetEnabled(v bool) *AgentSkillCreate {
|
|
_c.mutation.SetEnabled(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableEnabled(v *bool) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetEnabled(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetExtensionPackageID sets the "extension_package_id" field.
|
|
func (_c *AgentSkillCreate) SetExtensionPackageID(v string) *AgentSkillCreate {
|
|
_c.mutation.SetExtensionPackageID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableExtensionPackageID sets the "extension_package_id" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableExtensionPackageID(v *string) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetExtensionPackageID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetAdminDescription sets the "admin_description" field.
|
|
func (_c *AgentSkillCreate) SetAdminDescription(v string) *AgentSkillCreate {
|
|
_c.mutation.SetAdminDescription(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableAdminDescription sets the "admin_description" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableAdminDescription(v *string) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetAdminDescription(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetAdminTags sets the "admin_tags" field.
|
|
func (_c *AgentSkillCreate) SetAdminTags(v []string) *AgentSkillCreate {
|
|
_c.mutation.SetAdminTags(v)
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *AgentSkillCreate) SetCreatedAt(v time.Time) *AgentSkillCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableCreatedAt(v *time.Time) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *AgentSkillCreate) SetUpdatedAt(v time.Time) *AgentSkillCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableUpdatedAt(v *time.Time) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *AgentSkillCreate) SetID(v uuid.UUID) *AgentSkillCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableID sets the "id" field if the given value is not nil.
|
|
func (_c *AgentSkillCreate) SetNillableID(v *uuid.UUID) *AgentSkillCreate {
|
|
if v != nil {
|
|
_c.SetID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRepo sets the "repo" edge to the AgentSkillRepo entity.
|
|
func (_c *AgentSkillCreate) SetRepo(v *AgentSkillRepo) *AgentSkillCreate {
|
|
return _c.SetRepoID(v.ID)
|
|
}
|
|
|
|
// AddVersionIDs adds the "versions" edge to the AgentSkillVersion entity by IDs.
|
|
func (_c *AgentSkillCreate) AddVersionIDs(ids ...uuid.UUID) *AgentSkillCreate {
|
|
_c.mutation.AddVersionIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddVersions adds the "versions" edges to the AgentSkillVersion entity.
|
|
func (_c *AgentSkillCreate) AddVersions(v ...*AgentSkillVersion) *AgentSkillCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddVersionIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the AgentSkillMutation object of the builder.
|
|
func (_c *AgentSkillCreate) Mutation() *AgentSkillMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the AgentSkill in the database.
|
|
func (_c *AgentSkillCreate) Save(ctx context.Context) (*AgentSkill, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *AgentSkillCreate) SaveX(ctx context.Context) *AgentSkill {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *AgentSkillCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *AgentSkillCreate) 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 *AgentSkillCreate) defaults() {
|
|
if _, ok := _c.mutation.ScopeType(); !ok {
|
|
v := agentskill.DefaultScopeType
|
|
_c.mutation.SetScopeType(v)
|
|
}
|
|
if _, ok := _c.mutation.ScopeID(); !ok {
|
|
v := agentskill.DefaultScopeID
|
|
_c.mutation.SetScopeID(v)
|
|
}
|
|
if _, ok := _c.mutation.IsForceDelivery(); !ok {
|
|
v := agentskill.DefaultIsForceDelivery
|
|
_c.mutation.SetIsForceDelivery(v)
|
|
}
|
|
if _, ok := _c.mutation.IsOrphan(); !ok {
|
|
v := agentskill.DefaultIsOrphan
|
|
_c.mutation.SetIsOrphan(v)
|
|
}
|
|
if _, ok := _c.mutation.IsDeleted(); !ok {
|
|
v := agentskill.DefaultIsDeleted
|
|
_c.mutation.SetIsDeleted(v)
|
|
}
|
|
if _, ok := _c.mutation.Enabled(); !ok {
|
|
v := agentskill.DefaultEnabled
|
|
_c.mutation.SetEnabled(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
v := agentskill.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
v := agentskill.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.ID(); !ok {
|
|
v := agentskill.DefaultID()
|
|
_c.mutation.SetID(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *AgentSkillCreate) check() error {
|
|
if _, ok := _c.mutation.RepoID(); !ok {
|
|
return &ValidationError{Name: "repo_id", err: errors.New(`db: missing required field "AgentSkill.repo_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
return &ValidationError{Name: "name", err: errors.New(`db: missing required field "AgentSkill.name"`)}
|
|
}
|
|
if v, ok := _c.mutation.Name(); ok {
|
|
if err := agentskill.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentSkill.name": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.ScopeType(); !ok {
|
|
return &ValidationError{Name: "scope_type", err: errors.New(`db: missing required field "AgentSkill.scope_type"`)}
|
|
}
|
|
if v, ok := _c.mutation.ScopeType(); ok {
|
|
if err := agentskill.ScopeTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentSkill.scope_type": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.ScopeID(); !ok {
|
|
return &ValidationError{Name: "scope_id", err: errors.New(`db: missing required field "AgentSkill.scope_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.CreatedBy(); !ok {
|
|
return &ValidationError{Name: "created_by", err: errors.New(`db: missing required field "AgentSkill.created_by"`)}
|
|
}
|
|
if _, ok := _c.mutation.IsForceDelivery(); !ok {
|
|
return &ValidationError{Name: "is_force_delivery", err: errors.New(`db: missing required field "AgentSkill.is_force_delivery"`)}
|
|
}
|
|
if _, ok := _c.mutation.IsOrphan(); !ok {
|
|
return &ValidationError{Name: "is_orphan", err: errors.New(`db: missing required field "AgentSkill.is_orphan"`)}
|
|
}
|
|
if _, ok := _c.mutation.IsDeleted(); !ok {
|
|
return &ValidationError{Name: "is_deleted", err: errors.New(`db: missing required field "AgentSkill.is_deleted"`)}
|
|
}
|
|
if _, ok := _c.mutation.Enabled(); !ok {
|
|
return &ValidationError{Name: "enabled", err: errors.New(`db: missing required field "AgentSkill.enabled"`)}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentSkill.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "AgentSkill.updated_at"`)}
|
|
}
|
|
if len(_c.mutation.RepoIDs()) == 0 {
|
|
return &ValidationError{Name: "repo", err: errors.New(`db: missing required edge "AgentSkill.repo"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *AgentSkillCreate) sqlSave(ctx context.Context) (*AgentSkill, error) {
|
|
if err := _c.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := _c.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
if _spec.ID.Value != nil {
|
|
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
|
_node.ID = *id
|
|
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *AgentSkillCreate) createSpec() (*AgentSkill, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &AgentSkill{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(agentskill.Table, sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID))
|
|
)
|
|
_spec.OnConflict = _c.conflict
|
|
if id, ok := _c.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = &id
|
|
}
|
|
if value, ok := _c.mutation.Name(); ok {
|
|
_spec.SetField(agentskill.FieldName, field.TypeString, value)
|
|
_node.Name = value
|
|
}
|
|
if value, ok := _c.mutation.Description(); ok {
|
|
_spec.SetField(agentskill.FieldDescription, field.TypeString, value)
|
|
_node.Description = value
|
|
}
|
|
if value, ok := _c.mutation.ScopeType(); ok {
|
|
_spec.SetField(agentskill.FieldScopeType, field.TypeEnum, value)
|
|
_node.ScopeType = value
|
|
}
|
|
if value, ok := _c.mutation.ScopeID(); ok {
|
|
_spec.SetField(agentskill.FieldScopeID, field.TypeString, value)
|
|
_node.ScopeID = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedBy(); ok {
|
|
_spec.SetField(agentskill.FieldCreatedBy, field.TypeUUID, value)
|
|
_node.CreatedBy = value
|
|
}
|
|
if value, ok := _c.mutation.ActiveVersionID(); ok {
|
|
_spec.SetField(agentskill.FieldActiveVersionID, field.TypeUUID, value)
|
|
_node.ActiveVersionID = &value
|
|
}
|
|
if value, ok := _c.mutation.IsForceDelivery(); ok {
|
|
_spec.SetField(agentskill.FieldIsForceDelivery, field.TypeBool, value)
|
|
_node.IsForceDelivery = value
|
|
}
|
|
if value, ok := _c.mutation.IsOrphan(); ok {
|
|
_spec.SetField(agentskill.FieldIsOrphan, field.TypeBool, value)
|
|
_node.IsOrphan = value
|
|
}
|
|
if value, ok := _c.mutation.IsDeleted(); ok {
|
|
_spec.SetField(agentskill.FieldIsDeleted, field.TypeBool, value)
|
|
_node.IsDeleted = value
|
|
}
|
|
if value, ok := _c.mutation.Enabled(); ok {
|
|
_spec.SetField(agentskill.FieldEnabled, field.TypeBool, value)
|
|
_node.Enabled = value
|
|
}
|
|
if value, ok := _c.mutation.ExtensionPackageID(); ok {
|
|
_spec.SetField(agentskill.FieldExtensionPackageID, field.TypeString, value)
|
|
_node.ExtensionPackageID = &value
|
|
}
|
|
if value, ok := _c.mutation.AdminDescription(); ok {
|
|
_spec.SetField(agentskill.FieldAdminDescription, field.TypeString, value)
|
|
_node.AdminDescription = &value
|
|
}
|
|
if value, ok := _c.mutation.AdminTags(); ok {
|
|
_spec.SetField(agentskill.FieldAdminTags, field.TypeJSON, value)
|
|
_node.AdminTags = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(agentskill.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(agentskill.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if nodes := _c.mutation.RepoIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: agentskill.RepoTable,
|
|
Columns: []string{agentskill.RepoColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.RepoID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.VersionsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: agentskill.VersionsTable,
|
|
Columns: []string{agentskill.VersionsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskillversion.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.AgentSkill.Create().
|
|
// SetRepoID(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.AgentSkillUpsert) {
|
|
// SetRepoID(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *AgentSkillCreate) OnConflict(opts ...sql.ConflictOption) *AgentSkillUpsertOne {
|
|
_c.conflict = opts
|
|
return &AgentSkillUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.AgentSkill.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *AgentSkillCreate) OnConflictColumns(columns ...string) *AgentSkillUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &AgentSkillUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// AgentSkillUpsertOne is the builder for "upsert"-ing
|
|
// one AgentSkill node.
|
|
AgentSkillUpsertOne struct {
|
|
create *AgentSkillCreate
|
|
}
|
|
|
|
// AgentSkillUpsert is the "OnConflict" setter.
|
|
AgentSkillUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetRepoID sets the "repo_id" field.
|
|
func (u *AgentSkillUpsert) SetRepoID(v uuid.UUID) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldRepoID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateRepoID sets the "repo_id" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateRepoID() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldRepoID)
|
|
return u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *AgentSkillUpsert) SetName(v string) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateName() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldName)
|
|
return u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (u *AgentSkillUpsert) SetDescription(v string) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldDescription, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDescription sets the "description" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateDescription() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldDescription)
|
|
return u
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (u *AgentSkillUpsert) ClearDescription() *AgentSkillUpsert {
|
|
u.SetNull(agentskill.FieldDescription)
|
|
return u
|
|
}
|
|
|
|
// SetScopeType sets the "scope_type" field.
|
|
func (u *AgentSkillUpsert) SetScopeType(v agentskill.ScopeType) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldScopeType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateScopeType sets the "scope_type" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateScopeType() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldScopeType)
|
|
return u
|
|
}
|
|
|
|
// SetScopeID sets the "scope_id" field.
|
|
func (u *AgentSkillUpsert) SetScopeID(v string) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldScopeID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateScopeID sets the "scope_id" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateScopeID() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldScopeID)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedBy sets the "created_by" field.
|
|
func (u *AgentSkillUpsert) SetCreatedBy(v uuid.UUID) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldCreatedBy, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedBy sets the "created_by" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateCreatedBy() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldCreatedBy)
|
|
return u
|
|
}
|
|
|
|
// SetActiveVersionID sets the "active_version_id" field.
|
|
func (u *AgentSkillUpsert) SetActiveVersionID(v uuid.UUID) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldActiveVersionID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateActiveVersionID() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldActiveVersionID)
|
|
return u
|
|
}
|
|
|
|
// ClearActiveVersionID clears the value of the "active_version_id" field.
|
|
func (u *AgentSkillUpsert) ClearActiveVersionID() *AgentSkillUpsert {
|
|
u.SetNull(agentskill.FieldActiveVersionID)
|
|
return u
|
|
}
|
|
|
|
// SetIsForceDelivery sets the "is_force_delivery" field.
|
|
func (u *AgentSkillUpsert) SetIsForceDelivery(v bool) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldIsForceDelivery, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateIsForceDelivery sets the "is_force_delivery" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateIsForceDelivery() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldIsForceDelivery)
|
|
return u
|
|
}
|
|
|
|
// SetIsOrphan sets the "is_orphan" field.
|
|
func (u *AgentSkillUpsert) SetIsOrphan(v bool) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldIsOrphan, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateIsOrphan sets the "is_orphan" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateIsOrphan() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldIsOrphan)
|
|
return u
|
|
}
|
|
|
|
// SetIsDeleted sets the "is_deleted" field.
|
|
func (u *AgentSkillUpsert) SetIsDeleted(v bool) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldIsDeleted, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateIsDeleted() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldIsDeleted)
|
|
return u
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (u *AgentSkillUpsert) SetEnabled(v bool) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldEnabled, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateEnabled sets the "enabled" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateEnabled() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldEnabled)
|
|
return u
|
|
}
|
|
|
|
// SetExtensionPackageID sets the "extension_package_id" field.
|
|
func (u *AgentSkillUpsert) SetExtensionPackageID(v string) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldExtensionPackageID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateExtensionPackageID sets the "extension_package_id" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateExtensionPackageID() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldExtensionPackageID)
|
|
return u
|
|
}
|
|
|
|
// ClearExtensionPackageID clears the value of the "extension_package_id" field.
|
|
func (u *AgentSkillUpsert) ClearExtensionPackageID() *AgentSkillUpsert {
|
|
u.SetNull(agentskill.FieldExtensionPackageID)
|
|
return u
|
|
}
|
|
|
|
// SetAdminDescription sets the "admin_description" field.
|
|
func (u *AgentSkillUpsert) SetAdminDescription(v string) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldAdminDescription, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateAdminDescription sets the "admin_description" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateAdminDescription() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldAdminDescription)
|
|
return u
|
|
}
|
|
|
|
// ClearAdminDescription clears the value of the "admin_description" field.
|
|
func (u *AgentSkillUpsert) ClearAdminDescription() *AgentSkillUpsert {
|
|
u.SetNull(agentskill.FieldAdminDescription)
|
|
return u
|
|
}
|
|
|
|
// SetAdminTags sets the "admin_tags" field.
|
|
func (u *AgentSkillUpsert) SetAdminTags(v []string) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldAdminTags, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateAdminTags sets the "admin_tags" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateAdminTags() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldAdminTags)
|
|
return u
|
|
}
|
|
|
|
// ClearAdminTags clears the value of the "admin_tags" field.
|
|
func (u *AgentSkillUpsert) ClearAdminTags() *AgentSkillUpsert {
|
|
u.SetNull(agentskill.FieldAdminTags)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *AgentSkillUpsert) SetCreatedAt(v time.Time) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateCreatedAt() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *AgentSkillUpsert) SetUpdatedAt(v time.Time) *AgentSkillUpsert {
|
|
u.Set(agentskill.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsert) UpdateUpdatedAt() *AgentSkillUpsert {
|
|
u.SetExcluded(agentskill.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.AgentSkill.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(agentskill.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *AgentSkillUpsertOne) UpdateNewValues() *AgentSkillUpsertOne {
|
|
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(agentskill.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.AgentSkill.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *AgentSkillUpsertOne) Ignore() *AgentSkillUpsertOne {
|
|
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 *AgentSkillUpsertOne) DoNothing() *AgentSkillUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the AgentSkillCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *AgentSkillUpsertOne) Update(set func(*AgentSkillUpsert)) *AgentSkillUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&AgentSkillUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetRepoID sets the "repo_id" field.
|
|
func (u *AgentSkillUpsertOne) SetRepoID(v uuid.UUID) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetRepoID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRepoID sets the "repo_id" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateRepoID() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateRepoID()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *AgentSkillUpsertOne) SetName(v string) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateName() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (u *AgentSkillUpsertOne) SetDescription(v string) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetDescription(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDescription sets the "description" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateDescription() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateDescription()
|
|
})
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (u *AgentSkillUpsertOne) ClearDescription() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.ClearDescription()
|
|
})
|
|
}
|
|
|
|
// SetScopeType sets the "scope_type" field.
|
|
func (u *AgentSkillUpsertOne) SetScopeType(v agentskill.ScopeType) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetScopeType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateScopeType sets the "scope_type" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateScopeType() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateScopeType()
|
|
})
|
|
}
|
|
|
|
// SetScopeID sets the "scope_id" field.
|
|
func (u *AgentSkillUpsertOne) SetScopeID(v string) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetScopeID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateScopeID sets the "scope_id" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateScopeID() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateScopeID()
|
|
})
|
|
}
|
|
|
|
// SetCreatedBy sets the "created_by" field.
|
|
func (u *AgentSkillUpsertOne) SetCreatedBy(v uuid.UUID) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetCreatedBy(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedBy sets the "created_by" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateCreatedBy() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateCreatedBy()
|
|
})
|
|
}
|
|
|
|
// SetActiveVersionID sets the "active_version_id" field.
|
|
func (u *AgentSkillUpsertOne) SetActiveVersionID(v uuid.UUID) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetActiveVersionID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateActiveVersionID() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateActiveVersionID()
|
|
})
|
|
}
|
|
|
|
// ClearActiveVersionID clears the value of the "active_version_id" field.
|
|
func (u *AgentSkillUpsertOne) ClearActiveVersionID() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.ClearActiveVersionID()
|
|
})
|
|
}
|
|
|
|
// SetIsForceDelivery sets the "is_force_delivery" field.
|
|
func (u *AgentSkillUpsertOne) SetIsForceDelivery(v bool) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetIsForceDelivery(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsForceDelivery sets the "is_force_delivery" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateIsForceDelivery() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateIsForceDelivery()
|
|
})
|
|
}
|
|
|
|
// SetIsOrphan sets the "is_orphan" field.
|
|
func (u *AgentSkillUpsertOne) SetIsOrphan(v bool) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetIsOrphan(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsOrphan sets the "is_orphan" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateIsOrphan() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateIsOrphan()
|
|
})
|
|
}
|
|
|
|
// SetIsDeleted sets the "is_deleted" field.
|
|
func (u *AgentSkillUpsertOne) SetIsDeleted(v bool) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetIsDeleted(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateIsDeleted() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateIsDeleted()
|
|
})
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (u *AgentSkillUpsertOne) SetEnabled(v bool) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetEnabled(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEnabled sets the "enabled" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateEnabled() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateEnabled()
|
|
})
|
|
}
|
|
|
|
// SetExtensionPackageID sets the "extension_package_id" field.
|
|
func (u *AgentSkillUpsertOne) SetExtensionPackageID(v string) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetExtensionPackageID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExtensionPackageID sets the "extension_package_id" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateExtensionPackageID() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateExtensionPackageID()
|
|
})
|
|
}
|
|
|
|
// ClearExtensionPackageID clears the value of the "extension_package_id" field.
|
|
func (u *AgentSkillUpsertOne) ClearExtensionPackageID() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.ClearExtensionPackageID()
|
|
})
|
|
}
|
|
|
|
// SetAdminDescription sets the "admin_description" field.
|
|
func (u *AgentSkillUpsertOne) SetAdminDescription(v string) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetAdminDescription(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAdminDescription sets the "admin_description" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateAdminDescription() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateAdminDescription()
|
|
})
|
|
}
|
|
|
|
// ClearAdminDescription clears the value of the "admin_description" field.
|
|
func (u *AgentSkillUpsertOne) ClearAdminDescription() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.ClearAdminDescription()
|
|
})
|
|
}
|
|
|
|
// SetAdminTags sets the "admin_tags" field.
|
|
func (u *AgentSkillUpsertOne) SetAdminTags(v []string) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetAdminTags(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAdminTags sets the "admin_tags" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateAdminTags() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateAdminTags()
|
|
})
|
|
}
|
|
|
|
// ClearAdminTags clears the value of the "admin_tags" field.
|
|
func (u *AgentSkillUpsertOne) ClearAdminTags() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.ClearAdminTags()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *AgentSkillUpsertOne) SetCreatedAt(v time.Time) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateCreatedAt() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *AgentSkillUpsertOne) SetUpdatedAt(v time.Time) *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertOne) UpdateUpdatedAt() *AgentSkillUpsertOne {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *AgentSkillUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for AgentSkillCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *AgentSkillUpsertOne) 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 *AgentSkillUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) {
|
|
if u.create.driver.Dialect() == dialect.MySQL {
|
|
// In case of "ON CONFLICT", there is no way to get back non-numeric ID
|
|
// fields from the database since MySQL does not support the RETURNING clause.
|
|
return id, errors.New("db: AgentSkillUpsertOne.ID is not supported by MySQL driver. Use AgentSkillUpsertOne.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 *AgentSkillUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// AgentSkillCreateBulk is the builder for creating many AgentSkill entities in bulk.
|
|
type AgentSkillCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*AgentSkillCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the AgentSkill entities in the database.
|
|
func (_c *AgentSkillCreateBulk) Save(ctx context.Context) ([]*AgentSkill, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*AgentSkill, 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.(*AgentSkillMutation)
|
|
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 *AgentSkillCreateBulk) SaveX(ctx context.Context) []*AgentSkill {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *AgentSkillCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *AgentSkillCreateBulk) 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.AgentSkill.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.AgentSkillUpsert) {
|
|
// SetRepoID(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *AgentSkillCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentSkillUpsertBulk {
|
|
_c.conflict = opts
|
|
return &AgentSkillUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.AgentSkill.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *AgentSkillCreateBulk) OnConflictColumns(columns ...string) *AgentSkillUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &AgentSkillUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// AgentSkillUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of AgentSkill nodes.
|
|
type AgentSkillUpsertBulk struct {
|
|
create *AgentSkillCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.AgentSkill.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(agentskill.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *AgentSkillUpsertBulk) UpdateNewValues() *AgentSkillUpsertBulk {
|
|
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(agentskill.FieldID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.AgentSkill.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *AgentSkillUpsertBulk) Ignore() *AgentSkillUpsertBulk {
|
|
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 *AgentSkillUpsertBulk) DoNothing() *AgentSkillUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the AgentSkillCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *AgentSkillUpsertBulk) Update(set func(*AgentSkillUpsert)) *AgentSkillUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&AgentSkillUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetRepoID sets the "repo_id" field.
|
|
func (u *AgentSkillUpsertBulk) SetRepoID(v uuid.UUID) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetRepoID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRepoID sets the "repo_id" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateRepoID() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateRepoID()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *AgentSkillUpsertBulk) SetName(v string) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateName() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (u *AgentSkillUpsertBulk) SetDescription(v string) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetDescription(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDescription sets the "description" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateDescription() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateDescription()
|
|
})
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (u *AgentSkillUpsertBulk) ClearDescription() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.ClearDescription()
|
|
})
|
|
}
|
|
|
|
// SetScopeType sets the "scope_type" field.
|
|
func (u *AgentSkillUpsertBulk) SetScopeType(v agentskill.ScopeType) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetScopeType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateScopeType sets the "scope_type" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateScopeType() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateScopeType()
|
|
})
|
|
}
|
|
|
|
// SetScopeID sets the "scope_id" field.
|
|
func (u *AgentSkillUpsertBulk) SetScopeID(v string) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetScopeID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateScopeID sets the "scope_id" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateScopeID() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateScopeID()
|
|
})
|
|
}
|
|
|
|
// SetCreatedBy sets the "created_by" field.
|
|
func (u *AgentSkillUpsertBulk) SetCreatedBy(v uuid.UUID) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetCreatedBy(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedBy sets the "created_by" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateCreatedBy() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateCreatedBy()
|
|
})
|
|
}
|
|
|
|
// SetActiveVersionID sets the "active_version_id" field.
|
|
func (u *AgentSkillUpsertBulk) SetActiveVersionID(v uuid.UUID) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetActiveVersionID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateActiveVersionID() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateActiveVersionID()
|
|
})
|
|
}
|
|
|
|
// ClearActiveVersionID clears the value of the "active_version_id" field.
|
|
func (u *AgentSkillUpsertBulk) ClearActiveVersionID() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.ClearActiveVersionID()
|
|
})
|
|
}
|
|
|
|
// SetIsForceDelivery sets the "is_force_delivery" field.
|
|
func (u *AgentSkillUpsertBulk) SetIsForceDelivery(v bool) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetIsForceDelivery(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsForceDelivery sets the "is_force_delivery" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateIsForceDelivery() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateIsForceDelivery()
|
|
})
|
|
}
|
|
|
|
// SetIsOrphan sets the "is_orphan" field.
|
|
func (u *AgentSkillUpsertBulk) SetIsOrphan(v bool) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetIsOrphan(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsOrphan sets the "is_orphan" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateIsOrphan() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateIsOrphan()
|
|
})
|
|
}
|
|
|
|
// SetIsDeleted sets the "is_deleted" field.
|
|
func (u *AgentSkillUpsertBulk) SetIsDeleted(v bool) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetIsDeleted(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateIsDeleted() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateIsDeleted()
|
|
})
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (u *AgentSkillUpsertBulk) SetEnabled(v bool) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetEnabled(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEnabled sets the "enabled" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateEnabled() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateEnabled()
|
|
})
|
|
}
|
|
|
|
// SetExtensionPackageID sets the "extension_package_id" field.
|
|
func (u *AgentSkillUpsertBulk) SetExtensionPackageID(v string) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetExtensionPackageID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExtensionPackageID sets the "extension_package_id" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateExtensionPackageID() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateExtensionPackageID()
|
|
})
|
|
}
|
|
|
|
// ClearExtensionPackageID clears the value of the "extension_package_id" field.
|
|
func (u *AgentSkillUpsertBulk) ClearExtensionPackageID() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.ClearExtensionPackageID()
|
|
})
|
|
}
|
|
|
|
// SetAdminDescription sets the "admin_description" field.
|
|
func (u *AgentSkillUpsertBulk) SetAdminDescription(v string) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetAdminDescription(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAdminDescription sets the "admin_description" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateAdminDescription() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateAdminDescription()
|
|
})
|
|
}
|
|
|
|
// ClearAdminDescription clears the value of the "admin_description" field.
|
|
func (u *AgentSkillUpsertBulk) ClearAdminDescription() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.ClearAdminDescription()
|
|
})
|
|
}
|
|
|
|
// SetAdminTags sets the "admin_tags" field.
|
|
func (u *AgentSkillUpsertBulk) SetAdminTags(v []string) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetAdminTags(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAdminTags sets the "admin_tags" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateAdminTags() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateAdminTags()
|
|
})
|
|
}
|
|
|
|
// ClearAdminTags clears the value of the "admin_tags" field.
|
|
func (u *AgentSkillUpsertBulk) ClearAdminTags() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.ClearAdminTags()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *AgentSkillUpsertBulk) SetCreatedAt(v time.Time) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateCreatedAt() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *AgentSkillUpsertBulk) SetUpdatedAt(v time.Time) *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *AgentSkillUpsertBulk) UpdateUpdatedAt() *AgentSkillUpsertBulk {
|
|
return u.Update(func(s *AgentSkillUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *AgentSkillUpsertBulk) 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 AgentSkillCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for AgentSkillCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *AgentSkillUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|