Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
227
properties_writer.go1.31 kB
package node_properties import ( "context" "github.com/Southclaws/fault" "github.com/Southclaws/fault/fctx" "github.com/Southclaws/opt" "github.com/Southclaws/storyden/app/resources/library" "github.com/Southclaws/storyden/internal/ent" "github.com/Southclaws/storyden/internal/ent/property" "github.com/rs/xid" ) type Writer struct { db *ent.Client } func (w *Writer) Update(ctx context.Context, nid library.NodeID, schema library.PropertySchema, props library.ExistingPropertyMutations) (*library.PropertyTable, error) { tx, err := w.db.Tx(ctx) if err != nil { return nil, fault.Wrap(err, fctx.With(ctx)) } defer func() { err = tx.Rollback() }() updated := library.PropertyTable{ Schema: schema, } for _, prop := range props { create := tx.Property.Create(). SetValue(prop.Value). SetFieldID(prop.ID). SetNodeID(xid.ID(nid)) create.OnConflictColumns(property.FieldFieldID, property.FieldNodeID).UpdateNewValues() r, err := create.Save(ctx) if err != nil { return nil, fault.Wrap(err, fctx.With(ctx)) } updated.Properties = append(updated.Properties, &library.Property{ Field: prop.PropertySchemaField, Value: opt.New(r.Value), }) } err = tx.Commit() if err != nil { return nil, fault.Wrap(err, fctx.With(ctx)) } return &updated, 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