Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
227
collectionnode_update.go16.3 kB
// 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 (_u *CollectionNodeUpdate) Where(ps ...predicate.CollectionNode) *CollectionNodeUpdate { _u.mutation.Where(ps...) return _u } // SetCollectionID sets the "collection_id" field. func (_u *CollectionNodeUpdate) SetCollectionID(v xid.ID) *CollectionNodeUpdate { _u.mutation.SetCollectionID(v) return _u } // SetNillableCollectionID sets the "collection_id" field if the given value is not nil. func (_u *CollectionNodeUpdate) SetNillableCollectionID(v *xid.ID) *CollectionNodeUpdate { if v != nil { _u.SetCollectionID(*v) } return _u } // SetNodeID sets the "node_id" field. func (_u *CollectionNodeUpdate) SetNodeID(v xid.ID) *CollectionNodeUpdate { _u.mutation.SetNodeID(v) return _u } // SetNillableNodeID sets the "node_id" field if the given value is not nil. func (_u *CollectionNodeUpdate) SetNillableNodeID(v *xid.ID) *CollectionNodeUpdate { if v != nil { _u.SetNodeID(*v) } return _u } // SetMembershipType sets the "membership_type" field. func (_u *CollectionNodeUpdate) SetMembershipType(v string) *CollectionNodeUpdate { _u.mutation.SetMembershipType(v) return _u } // SetNillableMembershipType sets the "membership_type" field if the given value is not nil. func (_u *CollectionNodeUpdate) SetNillableMembershipType(v *string) *CollectionNodeUpdate { if v != nil { _u.SetMembershipType(*v) } return _u } // SetCollection sets the "collection" edge to the Collection entity. func (_u *CollectionNodeUpdate) SetCollection(v *Collection) *CollectionNodeUpdate { return _u.SetCollectionID(v.ID) } // SetNode sets the "node" edge to the Node entity. func (_u *CollectionNodeUpdate) SetNode(v *Node) *CollectionNodeUpdate { return _u.SetNodeID(v.ID) } // Mutation returns the CollectionNodeMutation object of the builder. func (_u *CollectionNodeUpdate) Mutation() *CollectionNodeMutation { return _u.mutation } // ClearCollection clears the "collection" edge to the Collection entity. func (_u *CollectionNodeUpdate) ClearCollection() *CollectionNodeUpdate { _u.mutation.ClearCollection() return _u } // ClearNode clears the "node" edge to the Node entity. func (_u *CollectionNodeUpdate) ClearNode() *CollectionNodeUpdate { _u.mutation.ClearNode() return _u } // Save executes the query and returns the number of nodes affected by the update operation. func (_u *CollectionNodeUpdate) Save(ctx context.Context) (int, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *CollectionNodeUpdate) SaveX(ctx context.Context) int { affected, err := _u.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (_u *CollectionNodeUpdate) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *CollectionNodeUpdate) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. func (_u *CollectionNodeUpdate) check() error { if v, ok := _u.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 := _u.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 _u.mutation.CollectionCleared() && len(_u.mutation.CollectionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "CollectionNode.collection"`) } if _u.mutation.NodeCleared() && len(_u.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 (_u *CollectionNodeUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CollectionNodeUpdate { _u.modifiers = append(_u.modifiers, modifiers...) return _u } func (_u *CollectionNodeUpdate) sqlSave(ctx context.Context) (_node int, err error) { if err := _u.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 ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := _u.mutation.MembershipType(); ok { _spec.SetField(collectionnode.FieldMembershipType, field.TypeString, value) } if _u.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 := _u.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 _u.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 := _u.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(_u.modifiers...) if _node, err = sqlgraph.UpdateNodes(ctx, _u.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 } _u.mutation.done = true return _node, 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 (_u *CollectionNodeUpdateOne) SetCollectionID(v xid.ID) *CollectionNodeUpdateOne { _u.mutation.SetCollectionID(v) return _u } // SetNillableCollectionID sets the "collection_id" field if the given value is not nil. func (_u *CollectionNodeUpdateOne) SetNillableCollectionID(v *xid.ID) *CollectionNodeUpdateOne { if v != nil { _u.SetCollectionID(*v) } return _u } // SetNodeID sets the "node_id" field. func (_u *CollectionNodeUpdateOne) SetNodeID(v xid.ID) *CollectionNodeUpdateOne { _u.mutation.SetNodeID(v) return _u } // SetNillableNodeID sets the "node_id" field if the given value is not nil. func (_u *CollectionNodeUpdateOne) SetNillableNodeID(v *xid.ID) *CollectionNodeUpdateOne { if v != nil { _u.SetNodeID(*v) } return _u } // SetMembershipType sets the "membership_type" field. func (_u *CollectionNodeUpdateOne) SetMembershipType(v string) *CollectionNodeUpdateOne { _u.mutation.SetMembershipType(v) return _u } // SetNillableMembershipType sets the "membership_type" field if the given value is not nil. func (_u *CollectionNodeUpdateOne) SetNillableMembershipType(v *string) *CollectionNodeUpdateOne { if v != nil { _u.SetMembershipType(*v) } return _u } // SetCollection sets the "collection" edge to the Collection entity. func (_u *CollectionNodeUpdateOne) SetCollection(v *Collection) *CollectionNodeUpdateOne { return _u.SetCollectionID(v.ID) } // SetNode sets the "node" edge to the Node entity. func (_u *CollectionNodeUpdateOne) SetNode(v *Node) *CollectionNodeUpdateOne { return _u.SetNodeID(v.ID) } // Mutation returns the CollectionNodeMutation object of the builder. func (_u *CollectionNodeUpdateOne) Mutation() *CollectionNodeMutation { return _u.mutation } // ClearCollection clears the "collection" edge to the Collection entity. func (_u *CollectionNodeUpdateOne) ClearCollection() *CollectionNodeUpdateOne { _u.mutation.ClearCollection() return _u } // ClearNode clears the "node" edge to the Node entity. func (_u *CollectionNodeUpdateOne) ClearNode() *CollectionNodeUpdateOne { _u.mutation.ClearNode() return _u } // Where appends a list predicates to the CollectionNodeUpdate builder. func (_u *CollectionNodeUpdateOne) Where(ps ...predicate.CollectionNode) *CollectionNodeUpdateOne { _u.mutation.Where(ps...) return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (_u *CollectionNodeUpdateOne) Select(field string, fields ...string) *CollectionNodeUpdateOne { _u.fields = append([]string{field}, fields...) return _u } // Save executes the query and returns the updated CollectionNode entity. func (_u *CollectionNodeUpdateOne) Save(ctx context.Context) (*CollectionNode, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *CollectionNodeUpdateOne) SaveX(ctx context.Context) *CollectionNode { node, err := _u.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (_u *CollectionNodeUpdateOne) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *CollectionNodeUpdateOne) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. func (_u *CollectionNodeUpdateOne) check() error { if v, ok := _u.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 := _u.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 _u.mutation.CollectionCleared() && len(_u.mutation.CollectionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "CollectionNode.collection"`) } if _u.mutation.NodeCleared() && len(_u.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 (_u *CollectionNodeUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CollectionNodeUpdateOne { _u.modifiers = append(_u.modifiers, modifiers...) return _u } func (_u *CollectionNodeUpdateOne) sqlSave(ctx context.Context) (_node *CollectionNode, err error) { if err := _u.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 := _u.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 := _u.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 := _u.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 := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := _u.mutation.MembershipType(); ok { _spec.SetField(collectionnode.FieldMembershipType, field.TypeString, value) } if _u.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 := _u.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 _u.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 := _u.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(_u.modifiers...) _node = &CollectionNode{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues if err = sqlgraph.UpdateNode(ctx, _u.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 } _u.mutation.done = true return _node, nil }

MCP directory API

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