mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
1448 lines
41 KiB
Go
1448 lines
41 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/mcptool"
|
|
"github.com/chaitin/MonkeyCode/backend/db/mcpupstream"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// MCPToolCreate is the builder for creating a MCPTool entity.
|
|
type MCPToolCreate struct {
|
|
config
|
|
mutation *MCPToolMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_c *MCPToolCreate) SetDeletedAt(v time.Time) *MCPToolCreate {
|
|
_c.mutation.SetDeletedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_c *MCPToolCreate) SetNillableDeletedAt(v *time.Time) *MCPToolCreate {
|
|
if v != nil {
|
|
_c.SetDeletedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpstreamID sets the "upstream_id" field.
|
|
func (_c *MCPToolCreate) SetUpstreamID(v uuid.UUID) *MCPToolCreate {
|
|
_c.mutation.SetUpstreamID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_c *MCPToolCreate) SetName(v string) *MCPToolCreate {
|
|
_c.mutation.SetName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNamespacedName sets the "namespaced_name" field.
|
|
func (_c *MCPToolCreate) SetNamespacedName(v string) *MCPToolCreate {
|
|
_c.mutation.SetNamespacedName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetScope sets the "scope" field.
|
|
func (_c *MCPToolCreate) SetScope(v mcptool.Scope) *MCPToolCreate {
|
|
_c.mutation.SetScope(v)
|
|
return _c
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_c *MCPToolCreate) SetUserID(v uuid.UUID) *MCPToolCreate {
|
|
_c.mutation.SetUserID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_c *MCPToolCreate) SetNillableUserID(v *uuid.UUID) *MCPToolCreate {
|
|
if v != nil {
|
|
_c.SetUserID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_c *MCPToolCreate) SetDescription(v string) *MCPToolCreate {
|
|
_c.mutation.SetDescription(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_c *MCPToolCreate) SetNillableDescription(v *string) *MCPToolCreate {
|
|
if v != nil {
|
|
_c.SetDescription(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetInputSchema sets the "input_schema" field.
|
|
func (_c *MCPToolCreate) SetInputSchema(v map[string]interface{}) *MCPToolCreate {
|
|
_c.mutation.SetInputSchema(v)
|
|
return _c
|
|
}
|
|
|
|
// SetPrice sets the "price" field.
|
|
func (_c *MCPToolCreate) SetPrice(v int64) *MCPToolCreate {
|
|
_c.mutation.SetPrice(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillablePrice sets the "price" field if the given value is not nil.
|
|
func (_c *MCPToolCreate) SetNillablePrice(v *int64) *MCPToolCreate {
|
|
if v != nil {
|
|
_c.SetPrice(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (_c *MCPToolCreate) SetEnabled(v bool) *MCPToolCreate {
|
|
_c.mutation.SetEnabled(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
|
|
func (_c *MCPToolCreate) SetNillableEnabled(v *bool) *MCPToolCreate {
|
|
if v != nil {
|
|
_c.SetEnabled(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetVersionHash sets the "version_hash" field.
|
|
func (_c *MCPToolCreate) SetVersionHash(v string) *MCPToolCreate {
|
|
_c.mutation.SetVersionHash(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableVersionHash sets the "version_hash" field if the given value is not nil.
|
|
func (_c *MCPToolCreate) SetNillableVersionHash(v *string) *MCPToolCreate {
|
|
if v != nil {
|
|
_c.SetVersionHash(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetSyncedAt sets the "synced_at" field.
|
|
func (_c *MCPToolCreate) SetSyncedAt(v time.Time) *MCPToolCreate {
|
|
_c.mutation.SetSyncedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableSyncedAt sets the "synced_at" field if the given value is not nil.
|
|
func (_c *MCPToolCreate) SetNillableSyncedAt(v *time.Time) *MCPToolCreate {
|
|
if v != nil {
|
|
_c.SetSyncedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *MCPToolCreate) SetCreatedAt(v time.Time) *MCPToolCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *MCPToolCreate) SetNillableCreatedAt(v *time.Time) *MCPToolCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *MCPToolCreate) SetUpdatedAt(v time.Time) *MCPToolCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *MCPToolCreate) SetNillableUpdatedAt(v *time.Time) *MCPToolCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *MCPToolCreate) SetID(v uuid.UUID) *MCPToolCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetUpstream sets the "upstream" edge to the MCPUpstream entity.
|
|
func (_c *MCPToolCreate) SetUpstream(v *MCPUpstream) *MCPToolCreate {
|
|
return _c.SetUpstreamID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the MCPToolMutation object of the builder.
|
|
func (_c *MCPToolCreate) Mutation() *MCPToolMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the MCPTool in the database.
|
|
func (_c *MCPToolCreate) Save(ctx context.Context) (*MCPTool, error) {
|
|
if err := _c.defaults(); err != nil {
|
|
return nil, err
|
|
}
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *MCPToolCreate) SaveX(ctx context.Context) *MCPTool {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *MCPToolCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *MCPToolCreate) 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 *MCPToolCreate) defaults() error {
|
|
if _, ok := _c.mutation.Price(); !ok {
|
|
v := mcptool.DefaultPrice
|
|
_c.mutation.SetPrice(v)
|
|
}
|
|
if _, ok := _c.mutation.Enabled(); !ok {
|
|
v := mcptool.DefaultEnabled
|
|
_c.mutation.SetEnabled(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
if mcptool.DefaultCreatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized mcptool.DefaultCreatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := mcptool.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
if mcptool.DefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized mcptool.DefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := mcptool.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *MCPToolCreate) check() error {
|
|
if _, ok := _c.mutation.UpstreamID(); !ok {
|
|
return &ValidationError{Name: "upstream_id", err: errors.New(`db: missing required field "MCPTool.upstream_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
return &ValidationError{Name: "name", err: errors.New(`db: missing required field "MCPTool.name"`)}
|
|
}
|
|
if v, ok := _c.mutation.Name(); ok {
|
|
if err := mcptool.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "MCPTool.name": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.NamespacedName(); !ok {
|
|
return &ValidationError{Name: "namespaced_name", err: errors.New(`db: missing required field "MCPTool.namespaced_name"`)}
|
|
}
|
|
if v, ok := _c.mutation.NamespacedName(); ok {
|
|
if err := mcptool.NamespacedNameValidator(v); err != nil {
|
|
return &ValidationError{Name: "namespaced_name", err: fmt.Errorf(`db: validator failed for field "MCPTool.namespaced_name": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Scope(); !ok {
|
|
return &ValidationError{Name: "scope", err: errors.New(`db: missing required field "MCPTool.scope"`)}
|
|
}
|
|
if v, ok := _c.mutation.Scope(); ok {
|
|
if err := mcptool.ScopeValidator(v); err != nil {
|
|
return &ValidationError{Name: "scope", err: fmt.Errorf(`db: validator failed for field "MCPTool.scope": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Price(); !ok {
|
|
return &ValidationError{Name: "price", err: errors.New(`db: missing required field "MCPTool.price"`)}
|
|
}
|
|
if _, ok := _c.mutation.Enabled(); !ok {
|
|
return &ValidationError{Name: "enabled", err: errors.New(`db: missing required field "MCPTool.enabled"`)}
|
|
}
|
|
if v, ok := _c.mutation.VersionHash(); ok {
|
|
if err := mcptool.VersionHashValidator(v); err != nil {
|
|
return &ValidationError{Name: "version_hash", err: fmt.Errorf(`db: validator failed for field "MCPTool.version_hash": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "MCPTool.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "MCPTool.updated_at"`)}
|
|
}
|
|
if len(_c.mutation.UpstreamIDs()) == 0 {
|
|
return &ValidationError{Name: "upstream", err: errors.New(`db: missing required edge "MCPTool.upstream"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *MCPToolCreate) sqlSave(ctx context.Context) (*MCPTool, 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 *MCPToolCreate) createSpec() (*MCPTool, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &MCPTool{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(mcptool.Table, sqlgraph.NewFieldSpec(mcptool.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.DeletedAt(); ok {
|
|
_spec.SetField(mcptool.FieldDeletedAt, field.TypeTime, value)
|
|
_node.DeletedAt = value
|
|
}
|
|
if value, ok := _c.mutation.Name(); ok {
|
|
_spec.SetField(mcptool.FieldName, field.TypeString, value)
|
|
_node.Name = value
|
|
}
|
|
if value, ok := _c.mutation.NamespacedName(); ok {
|
|
_spec.SetField(mcptool.FieldNamespacedName, field.TypeString, value)
|
|
_node.NamespacedName = value
|
|
}
|
|
if value, ok := _c.mutation.Scope(); ok {
|
|
_spec.SetField(mcptool.FieldScope, field.TypeEnum, value)
|
|
_node.Scope = value
|
|
}
|
|
if value, ok := _c.mutation.UserID(); ok {
|
|
_spec.SetField(mcptool.FieldUserID, field.TypeUUID, value)
|
|
_node.UserID = &value
|
|
}
|
|
if value, ok := _c.mutation.Description(); ok {
|
|
_spec.SetField(mcptool.FieldDescription, field.TypeString, value)
|
|
_node.Description = value
|
|
}
|
|
if value, ok := _c.mutation.InputSchema(); ok {
|
|
_spec.SetField(mcptool.FieldInputSchema, field.TypeJSON, value)
|
|
_node.InputSchema = value
|
|
}
|
|
if value, ok := _c.mutation.Price(); ok {
|
|
_spec.SetField(mcptool.FieldPrice, field.TypeInt64, value)
|
|
_node.Price = value
|
|
}
|
|
if value, ok := _c.mutation.Enabled(); ok {
|
|
_spec.SetField(mcptool.FieldEnabled, field.TypeBool, value)
|
|
_node.Enabled = value
|
|
}
|
|
if value, ok := _c.mutation.VersionHash(); ok {
|
|
_spec.SetField(mcptool.FieldVersionHash, field.TypeString, value)
|
|
_node.VersionHash = value
|
|
}
|
|
if value, ok := _c.mutation.SyncedAt(); ok {
|
|
_spec.SetField(mcptool.FieldSyncedAt, field.TypeTime, value)
|
|
_node.SyncedAt = &value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(mcptool.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(mcptool.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if nodes := _c.mutation.UpstreamIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: mcptool.UpstreamTable,
|
|
Columns: []string{mcptool.UpstreamColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(mcpupstream.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.UpstreamID = 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.MCPTool.Create().
|
|
// SetDeletedAt(v).
|
|
// OnConflict(
|
|
// // Update the row with the new values
|
|
// // the was proposed for insertion.
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// // Override some of the fields with custom
|
|
// // update values.
|
|
// Update(func(u *ent.MCPToolUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *MCPToolCreate) OnConflict(opts ...sql.ConflictOption) *MCPToolUpsertOne {
|
|
_c.conflict = opts
|
|
return &MCPToolUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.MCPTool.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *MCPToolCreate) OnConflictColumns(columns ...string) *MCPToolUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &MCPToolUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// MCPToolUpsertOne is the builder for "upsert"-ing
|
|
// one MCPTool node.
|
|
MCPToolUpsertOne struct {
|
|
create *MCPToolCreate
|
|
}
|
|
|
|
// MCPToolUpsert is the "OnConflict" setter.
|
|
MCPToolUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *MCPToolUpsert) SetDeletedAt(v time.Time) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldDeletedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateDeletedAt() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *MCPToolUpsert) ClearDeletedAt() *MCPToolUpsert {
|
|
u.SetNull(mcptool.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpstreamID sets the "upstream_id" field.
|
|
func (u *MCPToolUpsert) SetUpstreamID(v uuid.UUID) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldUpstreamID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpstreamID sets the "upstream_id" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateUpstreamID() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldUpstreamID)
|
|
return u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *MCPToolUpsert) SetName(v string) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateName() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldName)
|
|
return u
|
|
}
|
|
|
|
// SetNamespacedName sets the "namespaced_name" field.
|
|
func (u *MCPToolUpsert) SetNamespacedName(v string) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldNamespacedName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateNamespacedName sets the "namespaced_name" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateNamespacedName() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldNamespacedName)
|
|
return u
|
|
}
|
|
|
|
// SetScope sets the "scope" field.
|
|
func (u *MCPToolUpsert) SetScope(v mcptool.Scope) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldScope, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateScope sets the "scope" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateScope() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldScope)
|
|
return u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *MCPToolUpsert) SetUserID(v uuid.UUID) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldUserID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateUserID() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldUserID)
|
|
return u
|
|
}
|
|
|
|
// ClearUserID clears the value of the "user_id" field.
|
|
func (u *MCPToolUpsert) ClearUserID() *MCPToolUpsert {
|
|
u.SetNull(mcptool.FieldUserID)
|
|
return u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (u *MCPToolUpsert) SetDescription(v string) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldDescription, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDescription sets the "description" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateDescription() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldDescription)
|
|
return u
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (u *MCPToolUpsert) ClearDescription() *MCPToolUpsert {
|
|
u.SetNull(mcptool.FieldDescription)
|
|
return u
|
|
}
|
|
|
|
// SetInputSchema sets the "input_schema" field.
|
|
func (u *MCPToolUpsert) SetInputSchema(v map[string]interface{}) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldInputSchema, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateInputSchema sets the "input_schema" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateInputSchema() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldInputSchema)
|
|
return u
|
|
}
|
|
|
|
// ClearInputSchema clears the value of the "input_schema" field.
|
|
func (u *MCPToolUpsert) ClearInputSchema() *MCPToolUpsert {
|
|
u.SetNull(mcptool.FieldInputSchema)
|
|
return u
|
|
}
|
|
|
|
// SetPrice sets the "price" field.
|
|
func (u *MCPToolUpsert) SetPrice(v int64) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldPrice, v)
|
|
return u
|
|
}
|
|
|
|
// UpdatePrice sets the "price" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdatePrice() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldPrice)
|
|
return u
|
|
}
|
|
|
|
// AddPrice adds v to the "price" field.
|
|
func (u *MCPToolUpsert) AddPrice(v int64) *MCPToolUpsert {
|
|
u.Add(mcptool.FieldPrice, v)
|
|
return u
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (u *MCPToolUpsert) SetEnabled(v bool) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldEnabled, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateEnabled sets the "enabled" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateEnabled() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldEnabled)
|
|
return u
|
|
}
|
|
|
|
// SetVersionHash sets the "version_hash" field.
|
|
func (u *MCPToolUpsert) SetVersionHash(v string) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldVersionHash, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateVersionHash sets the "version_hash" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateVersionHash() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldVersionHash)
|
|
return u
|
|
}
|
|
|
|
// ClearVersionHash clears the value of the "version_hash" field.
|
|
func (u *MCPToolUpsert) ClearVersionHash() *MCPToolUpsert {
|
|
u.SetNull(mcptool.FieldVersionHash)
|
|
return u
|
|
}
|
|
|
|
// SetSyncedAt sets the "synced_at" field.
|
|
func (u *MCPToolUpsert) SetSyncedAt(v time.Time) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldSyncedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateSyncedAt sets the "synced_at" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateSyncedAt() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldSyncedAt)
|
|
return u
|
|
}
|
|
|
|
// ClearSyncedAt clears the value of the "synced_at" field.
|
|
func (u *MCPToolUpsert) ClearSyncedAt() *MCPToolUpsert {
|
|
u.SetNull(mcptool.FieldSyncedAt)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *MCPToolUpsert) SetCreatedAt(v time.Time) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateCreatedAt() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *MCPToolUpsert) SetUpdatedAt(v time.Time) *MCPToolUpsert {
|
|
u.Set(mcptool.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *MCPToolUpsert) UpdateUpdatedAt() *MCPToolUpsert {
|
|
u.SetExcluded(mcptool.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.MCPTool.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(mcptool.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *MCPToolUpsertOne) UpdateNewValues() *MCPToolUpsertOne {
|
|
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(mcptool.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.MCPTool.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *MCPToolUpsertOne) Ignore() *MCPToolUpsertOne {
|
|
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 *MCPToolUpsertOne) DoNothing() *MCPToolUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the MCPToolCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *MCPToolUpsertOne) Update(set func(*MCPToolUpsert)) *MCPToolUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&MCPToolUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *MCPToolUpsertOne) SetDeletedAt(v time.Time) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateDeletedAt() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *MCPToolUpsertOne) ClearDeletedAt() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpstreamID sets the "upstream_id" field.
|
|
func (u *MCPToolUpsertOne) SetUpstreamID(v uuid.UUID) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetUpstreamID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpstreamID sets the "upstream_id" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateUpstreamID() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateUpstreamID()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *MCPToolUpsertOne) SetName(v string) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateName() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetNamespacedName sets the "namespaced_name" field.
|
|
func (u *MCPToolUpsertOne) SetNamespacedName(v string) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetNamespacedName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateNamespacedName sets the "namespaced_name" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateNamespacedName() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateNamespacedName()
|
|
})
|
|
}
|
|
|
|
// SetScope sets the "scope" field.
|
|
func (u *MCPToolUpsertOne) SetScope(v mcptool.Scope) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetScope(v)
|
|
})
|
|
}
|
|
|
|
// UpdateScope sets the "scope" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateScope() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateScope()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *MCPToolUpsertOne) SetUserID(v uuid.UUID) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateUserID() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// ClearUserID clears the value of the "user_id" field.
|
|
func (u *MCPToolUpsertOne) ClearUserID() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.ClearUserID()
|
|
})
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (u *MCPToolUpsertOne) SetDescription(v string) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetDescription(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDescription sets the "description" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateDescription() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateDescription()
|
|
})
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (u *MCPToolUpsertOne) ClearDescription() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.ClearDescription()
|
|
})
|
|
}
|
|
|
|
// SetInputSchema sets the "input_schema" field.
|
|
func (u *MCPToolUpsertOne) SetInputSchema(v map[string]interface{}) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetInputSchema(v)
|
|
})
|
|
}
|
|
|
|
// UpdateInputSchema sets the "input_schema" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateInputSchema() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateInputSchema()
|
|
})
|
|
}
|
|
|
|
// ClearInputSchema clears the value of the "input_schema" field.
|
|
func (u *MCPToolUpsertOne) ClearInputSchema() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.ClearInputSchema()
|
|
})
|
|
}
|
|
|
|
// SetPrice sets the "price" field.
|
|
func (u *MCPToolUpsertOne) SetPrice(v int64) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetPrice(v)
|
|
})
|
|
}
|
|
|
|
// AddPrice adds v to the "price" field.
|
|
func (u *MCPToolUpsertOne) AddPrice(v int64) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.AddPrice(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePrice sets the "price" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdatePrice() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdatePrice()
|
|
})
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (u *MCPToolUpsertOne) SetEnabled(v bool) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetEnabled(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEnabled sets the "enabled" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateEnabled() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateEnabled()
|
|
})
|
|
}
|
|
|
|
// SetVersionHash sets the "version_hash" field.
|
|
func (u *MCPToolUpsertOne) SetVersionHash(v string) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetVersionHash(v)
|
|
})
|
|
}
|
|
|
|
// UpdateVersionHash sets the "version_hash" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateVersionHash() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateVersionHash()
|
|
})
|
|
}
|
|
|
|
// ClearVersionHash clears the value of the "version_hash" field.
|
|
func (u *MCPToolUpsertOne) ClearVersionHash() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.ClearVersionHash()
|
|
})
|
|
}
|
|
|
|
// SetSyncedAt sets the "synced_at" field.
|
|
func (u *MCPToolUpsertOne) SetSyncedAt(v time.Time) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetSyncedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSyncedAt sets the "synced_at" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateSyncedAt() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateSyncedAt()
|
|
})
|
|
}
|
|
|
|
// ClearSyncedAt clears the value of the "synced_at" field.
|
|
func (u *MCPToolUpsertOne) ClearSyncedAt() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.ClearSyncedAt()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *MCPToolUpsertOne) SetCreatedAt(v time.Time) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateCreatedAt() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *MCPToolUpsertOne) SetUpdatedAt(v time.Time) *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertOne) UpdateUpdatedAt() *MCPToolUpsertOne {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *MCPToolUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for MCPToolCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *MCPToolUpsertOne) 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 *MCPToolUpsertOne) 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: MCPToolUpsertOne.ID is not supported by MySQL driver. Use MCPToolUpsertOne.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 *MCPToolUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// MCPToolCreateBulk is the builder for creating many MCPTool entities in bulk.
|
|
type MCPToolCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*MCPToolCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the MCPTool entities in the database.
|
|
func (_c *MCPToolCreateBulk) Save(ctx context.Context) ([]*MCPTool, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*MCPTool, 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.(*MCPToolMutation)
|
|
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 *MCPToolCreateBulk) SaveX(ctx context.Context) []*MCPTool {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *MCPToolCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *MCPToolCreateBulk) 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.MCPTool.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.MCPToolUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *MCPToolCreateBulk) OnConflict(opts ...sql.ConflictOption) *MCPToolUpsertBulk {
|
|
_c.conflict = opts
|
|
return &MCPToolUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.MCPTool.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *MCPToolCreateBulk) OnConflictColumns(columns ...string) *MCPToolUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &MCPToolUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// MCPToolUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of MCPTool nodes.
|
|
type MCPToolUpsertBulk struct {
|
|
create *MCPToolCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.MCPTool.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(mcptool.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *MCPToolUpsertBulk) UpdateNewValues() *MCPToolUpsertBulk {
|
|
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(mcptool.FieldID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.MCPTool.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *MCPToolUpsertBulk) Ignore() *MCPToolUpsertBulk {
|
|
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 *MCPToolUpsertBulk) DoNothing() *MCPToolUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the MCPToolCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *MCPToolUpsertBulk) Update(set func(*MCPToolUpsert)) *MCPToolUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&MCPToolUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *MCPToolUpsertBulk) SetDeletedAt(v time.Time) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateDeletedAt() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *MCPToolUpsertBulk) ClearDeletedAt() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpstreamID sets the "upstream_id" field.
|
|
func (u *MCPToolUpsertBulk) SetUpstreamID(v uuid.UUID) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetUpstreamID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpstreamID sets the "upstream_id" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateUpstreamID() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateUpstreamID()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *MCPToolUpsertBulk) SetName(v string) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateName() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetNamespacedName sets the "namespaced_name" field.
|
|
func (u *MCPToolUpsertBulk) SetNamespacedName(v string) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetNamespacedName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateNamespacedName sets the "namespaced_name" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateNamespacedName() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateNamespacedName()
|
|
})
|
|
}
|
|
|
|
// SetScope sets the "scope" field.
|
|
func (u *MCPToolUpsertBulk) SetScope(v mcptool.Scope) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetScope(v)
|
|
})
|
|
}
|
|
|
|
// UpdateScope sets the "scope" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateScope() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateScope()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *MCPToolUpsertBulk) SetUserID(v uuid.UUID) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateUserID() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// ClearUserID clears the value of the "user_id" field.
|
|
func (u *MCPToolUpsertBulk) ClearUserID() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.ClearUserID()
|
|
})
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (u *MCPToolUpsertBulk) SetDescription(v string) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetDescription(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDescription sets the "description" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateDescription() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateDescription()
|
|
})
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (u *MCPToolUpsertBulk) ClearDescription() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.ClearDescription()
|
|
})
|
|
}
|
|
|
|
// SetInputSchema sets the "input_schema" field.
|
|
func (u *MCPToolUpsertBulk) SetInputSchema(v map[string]interface{}) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetInputSchema(v)
|
|
})
|
|
}
|
|
|
|
// UpdateInputSchema sets the "input_schema" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateInputSchema() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateInputSchema()
|
|
})
|
|
}
|
|
|
|
// ClearInputSchema clears the value of the "input_schema" field.
|
|
func (u *MCPToolUpsertBulk) ClearInputSchema() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.ClearInputSchema()
|
|
})
|
|
}
|
|
|
|
// SetPrice sets the "price" field.
|
|
func (u *MCPToolUpsertBulk) SetPrice(v int64) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetPrice(v)
|
|
})
|
|
}
|
|
|
|
// AddPrice adds v to the "price" field.
|
|
func (u *MCPToolUpsertBulk) AddPrice(v int64) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.AddPrice(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePrice sets the "price" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdatePrice() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdatePrice()
|
|
})
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (u *MCPToolUpsertBulk) SetEnabled(v bool) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetEnabled(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEnabled sets the "enabled" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateEnabled() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateEnabled()
|
|
})
|
|
}
|
|
|
|
// SetVersionHash sets the "version_hash" field.
|
|
func (u *MCPToolUpsertBulk) SetVersionHash(v string) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetVersionHash(v)
|
|
})
|
|
}
|
|
|
|
// UpdateVersionHash sets the "version_hash" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateVersionHash() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateVersionHash()
|
|
})
|
|
}
|
|
|
|
// ClearVersionHash clears the value of the "version_hash" field.
|
|
func (u *MCPToolUpsertBulk) ClearVersionHash() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.ClearVersionHash()
|
|
})
|
|
}
|
|
|
|
// SetSyncedAt sets the "synced_at" field.
|
|
func (u *MCPToolUpsertBulk) SetSyncedAt(v time.Time) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetSyncedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSyncedAt sets the "synced_at" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateSyncedAt() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateSyncedAt()
|
|
})
|
|
}
|
|
|
|
// ClearSyncedAt clears the value of the "synced_at" field.
|
|
func (u *MCPToolUpsertBulk) ClearSyncedAt() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.ClearSyncedAt()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *MCPToolUpsertBulk) SetCreatedAt(v time.Time) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateCreatedAt() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *MCPToolUpsertBulk) SetUpdatedAt(v time.Time) *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *MCPToolUpsertBulk) UpdateUpdatedAt() *MCPToolUpsertBulk {
|
|
return u.Update(func(s *MCPToolUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *MCPToolUpsertBulk) 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 MCPToolCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for MCPToolCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *MCPToolUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|