We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Southclaws/storyden'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Southclaws/storyden/internal/ent/collection"
"github.com/Southclaws/storyden/internal/ent/collectionnode"
"github.com/Southclaws/storyden/internal/ent/node"
"github.com/Southclaws/storyden/internal/ent/predicate"
"github.com/rs/xid"
)
// CollectionNodeUpdate is the builder for updating CollectionNode entities.
type CollectionNodeUpdate struct {
config
hooks []Hook
mutation *CollectionNodeMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the CollectionNodeUpdate builder.
func (cnu *CollectionNodeUpdate) Where(ps ...predicate.CollectionNode) *CollectionNodeUpdate {
cnu.mutation.Where(ps...)
return cnu
}
// SetCollectionID sets the "collection_id" field.
func (cnu *CollectionNodeUpdate) SetCollectionID(x xid.ID) *CollectionNodeUpdate {
cnu.mutation.SetCollectionID(x)
return cnu
}
// SetNillableCollectionID sets the "collection_id" field if the given value is not nil.
func (cnu *CollectionNodeUpdate) SetNillableCollectionID(x *xid.ID) *CollectionNodeUpdate {
if x != nil {
cnu.SetCollectionID(*x)
}
return cnu
}
// SetNodeID sets the "node_id" field.
func (cnu *CollectionNodeUpdate) SetNodeID(x xid.ID) *CollectionNodeUpdate {
cnu.mutation.SetNodeID(x)
return cnu
}
// SetNillableNodeID sets the "node_id" field if the given value is not nil.
func (cnu *CollectionNodeUpdate) SetNillableNodeID(x *xid.ID) *CollectionNodeUpdate {
if x != nil {
cnu.SetNodeID(*x)
}
return cnu
}
// SetMembershipType sets the "membership_type" field.
func (cnu *CollectionNodeUpdate) SetMembershipType(s string) *CollectionNodeUpdate {
cnu.mutation.SetMembershipType(s)
return cnu
}
// SetNillableMembershipType sets the "membership_type" field if the given value is not nil.
func (cnu *CollectionNodeUpdate) SetNillableMembershipType(s *string) *CollectionNodeUpdate {
if s != nil {
cnu.SetMembershipType(*s)
}
return cnu
}
// SetCollection sets the "collection" edge to the Collection entity.
func (cnu *CollectionNodeUpdate) SetCollection(c *Collection) *CollectionNodeUpdate {
return cnu.SetCollectionID(c.ID)
}
// SetNode sets the "node" edge to the Node entity.
func (cnu *CollectionNodeUpdate) SetNode(n *Node) *CollectionNodeUpdate {
return cnu.SetNodeID(n.ID)
}
// Mutation returns the CollectionNodeMutation object of the builder.
func (cnu *CollectionNodeUpdate) Mutation() *CollectionNodeMutation {
return cnu.mutation
}
// ClearCollection clears the "collection" edge to the Collection entity.
func (cnu *CollectionNodeUpdate) ClearCollection() *CollectionNodeUpdate {
cnu.mutation.ClearCollection()
return cnu
}
// ClearNode clears the "node" edge to the Node entity.
func (cnu *CollectionNodeUpdate) ClearNode() *CollectionNodeUpdate {
cnu.mutation.ClearNode()
return cnu
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (cnu *CollectionNodeUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, cnu.sqlSave, cnu.mutation, cnu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (cnu *CollectionNodeUpdate) SaveX(ctx context.Context) int {
affected, err := cnu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (cnu *CollectionNodeUpdate) Exec(ctx context.Context) error {
_, err := cnu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (cnu *CollectionNodeUpdate) ExecX(ctx context.Context) {
if err := cnu.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (cnu *CollectionNodeUpdate) check() error {
if v, ok := cnu.mutation.CollectionID(); ok {
if err := collectionnode.CollectionIDValidator(v.String()); err != nil {
return &ValidationError{Name: "collection_id", err: fmt.Errorf(`ent: validator failed for field "CollectionNode.collection_id": %w`, err)}
}
}
if v, ok := cnu.mutation.NodeID(); ok {
if err := collectionnode.NodeIDValidator(v.String()); err != nil {
return &ValidationError{Name: "node_id", err: fmt.Errorf(`ent: validator failed for field "CollectionNode.node_id": %w`, err)}
}
}
if cnu.mutation.CollectionCleared() && len(cnu.mutation.CollectionIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "CollectionNode.collection"`)
}
if cnu.mutation.NodeCleared() && len(cnu.mutation.NodeIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "CollectionNode.node"`)
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (cnu *CollectionNodeUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CollectionNodeUpdate {
cnu.modifiers = append(cnu.modifiers, modifiers...)
return cnu
}
func (cnu *CollectionNodeUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := cnu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(collectionnode.Table, collectionnode.Columns, sqlgraph.NewFieldSpec(collectionnode.FieldCollectionID, field.TypeString), sqlgraph.NewFieldSpec(collectionnode.FieldNodeID, field.TypeString))
if ps := cnu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := cnu.mutation.MembershipType(); ok {
_spec.SetField(collectionnode.FieldMembershipType, field.TypeString, value)
}
if cnu.mutation.CollectionCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: collectionnode.CollectionTable,
Columns: []string{collectionnode.CollectionColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(collection.FieldID, field.TypeString),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := cnu.mutation.CollectionIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: collectionnode.CollectionTable,
Columns: []string{collectionnode.CollectionColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(collection.FieldID, field.TypeString),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if cnu.mutation.NodeCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: collectionnode.NodeTable,
Columns: []string{collectionnode.NodeColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(node.FieldID, field.TypeString),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := cnu.mutation.NodeIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: collectionnode.NodeTable,
Columns: []string{collectionnode.NodeColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(node.FieldID, field.TypeString),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(cnu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, cnu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{collectionnode.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
cnu.mutation.done = true
return n, nil
}
// CollectionNodeUpdateOne is the builder for updating a single CollectionNode entity.
type CollectionNodeUpdateOne struct {
config
fields []string
hooks []Hook
mutation *CollectionNodeMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetCollectionID sets the "collection_id" field.
func (cnuo *CollectionNodeUpdateOne) SetCollectionID(x xid.ID) *CollectionNodeUpdateOne {
cnuo.mutation.SetCollectionID(x)
return cnuo
}
// SetNillableCollectionID sets the "collection_id" field if the given value is not nil.
func (cnuo *CollectionNodeUpdateOne) SetNillableCollectionID(x *xid.ID) *CollectionNodeUpdateOne {
if x != nil {
cnuo.SetCollectionID(*x)
}
return cnuo
}
// SetNodeID sets the "node_id" field.
func (cnuo *CollectionNodeUpdateOne) SetNodeID(x xid.ID) *CollectionNodeUpdateOne {
cnuo.mutation.SetNodeID(x)
return cnuo
}
// SetNillableNodeID sets the "node_id" field if the given value is not nil.
func (cnuo *CollectionNodeUpdateOne) SetNillableNodeID(x *xid.ID) *CollectionNodeUpdateOne {
if x != nil {
cnuo.SetNodeID(*x)
}
return cnuo
}
// SetMembershipType sets the "membership_type" field.
func (cnuo *CollectionNodeUpdateOne) SetMembershipType(s string) *CollectionNodeUpdateOne {
cnuo.mutation.SetMembershipType(s)
return cnuo
}
// SetNillableMembershipType sets the "membership_type" field if the given value is not nil.
func (cnuo *CollectionNodeUpdateOne) SetNillableMembershipType(s *string) *CollectionNodeUpdateOne {
if s != nil {
cnuo.SetMembershipType(*s)
}
return cnuo
}
// SetCollection sets the "collection" edge to the Collection entity.
func (cnuo *CollectionNodeUpdateOne) SetCollection(c *Collection) *CollectionNodeUpdateOne {
return cnuo.SetCollectionID(c.ID)
}
// SetNode sets the "node" edge to the Node entity.
func (cnuo *CollectionNodeUpdateOne) SetNode(n *Node) *CollectionNodeUpdateOne {
return cnuo.SetNodeID(n.ID)
}
// Mutation returns the CollectionNodeMutation object of the builder.
func (cnuo *CollectionNodeUpdateOne) Mutation() *CollectionNodeMutation {
return cnuo.mutation
}
// ClearCollection clears the "collection" edge to the Collection entity.
func (cnuo *CollectionNodeUpdateOne) ClearCollection() *CollectionNodeUpdateOne {
cnuo.mutation.ClearCollection()
return cnuo
}
// ClearNode clears the "node" edge to the Node entity.
func (cnuo *CollectionNodeUpdateOne) ClearNode() *CollectionNodeUpdateOne {
cnuo.mutation.ClearNode()
return cnuo
}
// Where appends a list predicates to the CollectionNodeUpdate builder.
func (cnuo *CollectionNodeUpdateOne) Where(ps ...predicate.CollectionNode) *CollectionNodeUpdateOne {
cnuo.mutation.Where(ps...)
return cnuo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (cnuo *CollectionNodeUpdateOne) Select(field string, fields ...string) *CollectionNodeUpdateOne {
cnuo.fields = append([]string{field}, fields...)
return cnuo
}
// Save executes the query and returns the updated CollectionNode entity.
func (cnuo *CollectionNodeUpdateOne) Save(ctx context.Context) (*CollectionNode, error) {
return withHooks(ctx, cnuo.sqlSave, cnuo.mutation, cnuo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (cnuo *CollectionNodeUpdateOne) SaveX(ctx context.Context) *CollectionNode {
node, err := cnuo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (cnuo *CollectionNodeUpdateOne) Exec(ctx context.Context) error {
_, err := cnuo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (cnuo *CollectionNodeUpdateOne) ExecX(ctx context.Context) {
if err := cnuo.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (cnuo *CollectionNodeUpdateOne) check() error {
if v, ok := cnuo.mutation.CollectionID(); ok {
if err := collectionnode.CollectionIDValidator(v.String()); err != nil {
return &ValidationError{Name: "collection_id", err: fmt.Errorf(`ent: validator failed for field "CollectionNode.collection_id": %w`, err)}
}
}
if v, ok := cnuo.mutation.NodeID(); ok {
if err := collectionnode.NodeIDValidator(v.String()); err != nil {
return &ValidationError{Name: "node_id", err: fmt.Errorf(`ent: validator failed for field "CollectionNode.node_id": %w`, err)}
}
}
if cnuo.mutation.CollectionCleared() && len(cnuo.mutation.CollectionIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "CollectionNode.collection"`)
}
if cnuo.mutation.NodeCleared() && len(cnuo.mutation.NodeIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "CollectionNode.node"`)
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (cnuo *CollectionNodeUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CollectionNodeUpdateOne {
cnuo.modifiers = append(cnuo.modifiers, modifiers...)
return cnuo
}
func (cnuo *CollectionNodeUpdateOne) sqlSave(ctx context.Context) (_node *CollectionNode, err error) {
if err := cnuo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(collectionnode.Table, collectionnode.Columns, sqlgraph.NewFieldSpec(collectionnode.FieldCollectionID, field.TypeString), sqlgraph.NewFieldSpec(collectionnode.FieldNodeID, field.TypeString))
if id, ok := cnuo.mutation.CollectionID(); !ok {
return nil, &ValidationError{Name: "collection_id", err: errors.New(`ent: missing "CollectionNode.collection_id" for update`)}
} else {
_spec.Node.CompositeID[0].Value = id
}
if id, ok := cnuo.mutation.NodeID(); !ok {
return nil, &ValidationError{Name: "node_id", err: errors.New(`ent: missing "CollectionNode.node_id" for update`)}
} else {
_spec.Node.CompositeID[1].Value = id
}
if fields := cnuo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, len(fields))
for i, f := range fields {
if !collectionnode.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
_spec.Node.Columns[i] = f
}
}
if ps := cnuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := cnuo.mutation.MembershipType(); ok {
_spec.SetField(collectionnode.FieldMembershipType, field.TypeString, value)
}
if cnuo.mutation.CollectionCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: collectionnode.CollectionTable,
Columns: []string{collectionnode.CollectionColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(collection.FieldID, field.TypeString),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := cnuo.mutation.CollectionIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: collectionnode.CollectionTable,
Columns: []string{collectionnode.CollectionColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(collection.FieldID, field.TypeString),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if cnuo.mutation.NodeCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: collectionnode.NodeTable,
Columns: []string{collectionnode.NodeColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(node.FieldID, field.TypeString),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := cnuo.mutation.NodeIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: collectionnode.NodeTable,
Columns: []string{collectionnode.NodeColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(node.FieldID, field.TypeString),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(cnuo.modifiers...)
_node = &CollectionNode{config: cnuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, cnuo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{collectionnode.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
cnuo.mutation.done = true
return _node, nil
}