Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
227
accountfollow_update.go14.8 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/account" "github.com/Southclaws/storyden/internal/ent/accountfollow" "github.com/Southclaws/storyden/internal/ent/predicate" "github.com/rs/xid" ) // AccountFollowUpdate is the builder for updating AccountFollow entities. type AccountFollowUpdate struct { config hooks []Hook mutation *AccountFollowMutation modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the AccountFollowUpdate builder. func (_u *AccountFollowUpdate) Where(ps ...predicate.AccountFollow) *AccountFollowUpdate { _u.mutation.Where(ps...) return _u } // SetFollowerAccountID sets the "follower_account_id" field. func (_u *AccountFollowUpdate) SetFollowerAccountID(v xid.ID) *AccountFollowUpdate { _u.mutation.SetFollowerAccountID(v) return _u } // SetNillableFollowerAccountID sets the "follower_account_id" field if the given value is not nil. func (_u *AccountFollowUpdate) SetNillableFollowerAccountID(v *xid.ID) *AccountFollowUpdate { if v != nil { _u.SetFollowerAccountID(*v) } return _u } // SetFollowingAccountID sets the "following_account_id" field. func (_u *AccountFollowUpdate) SetFollowingAccountID(v xid.ID) *AccountFollowUpdate { _u.mutation.SetFollowingAccountID(v) return _u } // SetNillableFollowingAccountID sets the "following_account_id" field if the given value is not nil. func (_u *AccountFollowUpdate) SetNillableFollowingAccountID(v *xid.ID) *AccountFollowUpdate { if v != nil { _u.SetFollowingAccountID(*v) } return _u } // SetFollowerID sets the "follower" edge to the Account entity by ID. func (_u *AccountFollowUpdate) SetFollowerID(id xid.ID) *AccountFollowUpdate { _u.mutation.SetFollowerID(id) return _u } // SetFollower sets the "follower" edge to the Account entity. func (_u *AccountFollowUpdate) SetFollower(v *Account) *AccountFollowUpdate { return _u.SetFollowerID(v.ID) } // SetFollowingID sets the "following" edge to the Account entity by ID. func (_u *AccountFollowUpdate) SetFollowingID(id xid.ID) *AccountFollowUpdate { _u.mutation.SetFollowingID(id) return _u } // SetFollowing sets the "following" edge to the Account entity. func (_u *AccountFollowUpdate) SetFollowing(v *Account) *AccountFollowUpdate { return _u.SetFollowingID(v.ID) } // Mutation returns the AccountFollowMutation object of the builder. func (_u *AccountFollowUpdate) Mutation() *AccountFollowMutation { return _u.mutation } // ClearFollower clears the "follower" edge to the Account entity. func (_u *AccountFollowUpdate) ClearFollower() *AccountFollowUpdate { _u.mutation.ClearFollower() return _u } // ClearFollowing clears the "following" edge to the Account entity. func (_u *AccountFollowUpdate) ClearFollowing() *AccountFollowUpdate { _u.mutation.ClearFollowing() return _u } // Save executes the query and returns the number of nodes affected by the update operation. func (_u *AccountFollowUpdate) 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 *AccountFollowUpdate) SaveX(ctx context.Context) int { affected, err := _u.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (_u *AccountFollowUpdate) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *AccountFollowUpdate) 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 *AccountFollowUpdate) check() error { if _u.mutation.FollowerCleared() && len(_u.mutation.FollowerIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "AccountFollow.follower"`) } if _u.mutation.FollowingCleared() && len(_u.mutation.FollowingIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "AccountFollow.following"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (_u *AccountFollowUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AccountFollowUpdate { _u.modifiers = append(_u.modifiers, modifiers...) return _u } func (_u *AccountFollowUpdate) sqlSave(ctx context.Context) (_node int, err error) { if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(accountfollow.Table, accountfollow.Columns, sqlgraph.NewFieldSpec(accountfollow.FieldID, field.TypeString)) if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if _u.mutation.FollowerCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: accountfollow.FollowerTable, Columns: []string{accountfollow.FollowerColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.FollowerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: accountfollow.FollowerTable, Columns: []string{accountfollow.FollowerColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.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.FollowingCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: accountfollow.FollowingTable, Columns: []string{accountfollow.FollowingColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.FollowingIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: accountfollow.FollowingTable, Columns: []string{accountfollow.FollowingColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.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{accountfollow.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } _u.mutation.done = true return _node, nil } // AccountFollowUpdateOne is the builder for updating a single AccountFollow entity. type AccountFollowUpdateOne struct { config fields []string hooks []Hook mutation *AccountFollowMutation modifiers []func(*sql.UpdateBuilder) } // SetFollowerAccountID sets the "follower_account_id" field. func (_u *AccountFollowUpdateOne) SetFollowerAccountID(v xid.ID) *AccountFollowUpdateOne { _u.mutation.SetFollowerAccountID(v) return _u } // SetNillableFollowerAccountID sets the "follower_account_id" field if the given value is not nil. func (_u *AccountFollowUpdateOne) SetNillableFollowerAccountID(v *xid.ID) *AccountFollowUpdateOne { if v != nil { _u.SetFollowerAccountID(*v) } return _u } // SetFollowingAccountID sets the "following_account_id" field. func (_u *AccountFollowUpdateOne) SetFollowingAccountID(v xid.ID) *AccountFollowUpdateOne { _u.mutation.SetFollowingAccountID(v) return _u } // SetNillableFollowingAccountID sets the "following_account_id" field if the given value is not nil. func (_u *AccountFollowUpdateOne) SetNillableFollowingAccountID(v *xid.ID) *AccountFollowUpdateOne { if v != nil { _u.SetFollowingAccountID(*v) } return _u } // SetFollowerID sets the "follower" edge to the Account entity by ID. func (_u *AccountFollowUpdateOne) SetFollowerID(id xid.ID) *AccountFollowUpdateOne { _u.mutation.SetFollowerID(id) return _u } // SetFollower sets the "follower" edge to the Account entity. func (_u *AccountFollowUpdateOne) SetFollower(v *Account) *AccountFollowUpdateOne { return _u.SetFollowerID(v.ID) } // SetFollowingID sets the "following" edge to the Account entity by ID. func (_u *AccountFollowUpdateOne) SetFollowingID(id xid.ID) *AccountFollowUpdateOne { _u.mutation.SetFollowingID(id) return _u } // SetFollowing sets the "following" edge to the Account entity. func (_u *AccountFollowUpdateOne) SetFollowing(v *Account) *AccountFollowUpdateOne { return _u.SetFollowingID(v.ID) } // Mutation returns the AccountFollowMutation object of the builder. func (_u *AccountFollowUpdateOne) Mutation() *AccountFollowMutation { return _u.mutation } // ClearFollower clears the "follower" edge to the Account entity. func (_u *AccountFollowUpdateOne) ClearFollower() *AccountFollowUpdateOne { _u.mutation.ClearFollower() return _u } // ClearFollowing clears the "following" edge to the Account entity. func (_u *AccountFollowUpdateOne) ClearFollowing() *AccountFollowUpdateOne { _u.mutation.ClearFollowing() return _u } // Where appends a list predicates to the AccountFollowUpdate builder. func (_u *AccountFollowUpdateOne) Where(ps ...predicate.AccountFollow) *AccountFollowUpdateOne { _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 *AccountFollowUpdateOne) Select(field string, fields ...string) *AccountFollowUpdateOne { _u.fields = append([]string{field}, fields...) return _u } // Save executes the query and returns the updated AccountFollow entity. func (_u *AccountFollowUpdateOne) Save(ctx context.Context) (*AccountFollow, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *AccountFollowUpdateOne) SaveX(ctx context.Context) *AccountFollow { node, err := _u.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (_u *AccountFollowUpdateOne) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *AccountFollowUpdateOne) 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 *AccountFollowUpdateOne) check() error { if _u.mutation.FollowerCleared() && len(_u.mutation.FollowerIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "AccountFollow.follower"`) } if _u.mutation.FollowingCleared() && len(_u.mutation.FollowingIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "AccountFollow.following"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (_u *AccountFollowUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AccountFollowUpdateOne { _u.modifiers = append(_u.modifiers, modifiers...) return _u } func (_u *AccountFollowUpdateOne) sqlSave(ctx context.Context) (_node *AccountFollow, err error) { if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(accountfollow.Table, accountfollow.Columns, sqlgraph.NewFieldSpec(accountfollow.FieldID, field.TypeString)) id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AccountFollow.id" for update`)} } _spec.Node.ID.Value = id if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, accountfollow.FieldID) for _, f := range fields { if !accountfollow.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } if f != accountfollow.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, f) } } } if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if _u.mutation.FollowerCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: accountfollow.FollowerTable, Columns: []string{accountfollow.FollowerColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.FollowerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: accountfollow.FollowerTable, Columns: []string{accountfollow.FollowerColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.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.FollowingCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: accountfollow.FollowingTable, Columns: []string{accountfollow.FollowingColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.FollowingIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: accountfollow.FollowingTable, Columns: []string{accountfollow.FollowingColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.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 = &AccountFollow{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{accountfollow.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