Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
227
account_create.go59.2 kB
// Code generated by ent, DO NOT EDIT. package ent 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/Southclaws/storyden/internal/ent/account" "github.com/Southclaws/storyden/internal/ent/accountfollow" "github.com/Southclaws/storyden/internal/ent/accountroles" "github.com/Southclaws/storyden/internal/ent/asset" "github.com/Southclaws/storyden/internal/ent/authentication" "github.com/Southclaws/storyden/internal/ent/collection" "github.com/Southclaws/storyden/internal/ent/email" "github.com/Southclaws/storyden/internal/ent/eventparticipant" "github.com/Southclaws/storyden/internal/ent/invitation" "github.com/Southclaws/storyden/internal/ent/likepost" "github.com/Southclaws/storyden/internal/ent/mentionprofile" "github.com/Southclaws/storyden/internal/ent/node" "github.com/Southclaws/storyden/internal/ent/notification" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/postread" "github.com/Southclaws/storyden/internal/ent/question" "github.com/Southclaws/storyden/internal/ent/react" "github.com/Southclaws/storyden/internal/ent/report" "github.com/Southclaws/storyden/internal/ent/role" "github.com/Southclaws/storyden/internal/ent/schema" "github.com/Southclaws/storyden/internal/ent/session" "github.com/Southclaws/storyden/internal/ent/tag" "github.com/rs/xid" ) // AccountCreate is the builder for creating a Account entity. type AccountCreate struct { config mutation *AccountMutation hooks []Hook conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. func (_c *AccountCreate) SetCreatedAt(v time.Time) *AccountCreate { _c.mutation.SetCreatedAt(v) return _c } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (_c *AccountCreate) SetNillableCreatedAt(v *time.Time) *AccountCreate { if v != nil { _c.SetCreatedAt(*v) } return _c } // SetUpdatedAt sets the "updated_at" field. func (_c *AccountCreate) SetUpdatedAt(v time.Time) *AccountCreate { _c.mutation.SetUpdatedAt(v) return _c } // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. func (_c *AccountCreate) SetNillableUpdatedAt(v *time.Time) *AccountCreate { if v != nil { _c.SetUpdatedAt(*v) } return _c } // SetDeletedAt sets the "deleted_at" field. func (_c *AccountCreate) SetDeletedAt(v time.Time) *AccountCreate { _c.mutation.SetDeletedAt(v) return _c } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (_c *AccountCreate) SetNillableDeletedAt(v *time.Time) *AccountCreate { if v != nil { _c.SetDeletedAt(*v) } return _c } // SetIndexedAt sets the "indexed_at" field. func (_c *AccountCreate) SetIndexedAt(v time.Time) *AccountCreate { _c.mutation.SetIndexedAt(v) return _c } // SetNillableIndexedAt sets the "indexed_at" field if the given value is not nil. func (_c *AccountCreate) SetNillableIndexedAt(v *time.Time) *AccountCreate { if v != nil { _c.SetIndexedAt(*v) } return _c } // SetHandle sets the "handle" field. func (_c *AccountCreate) SetHandle(v string) *AccountCreate { _c.mutation.SetHandle(v) return _c } // SetName sets the "name" field. func (_c *AccountCreate) SetName(v string) *AccountCreate { _c.mutation.SetName(v) return _c } // SetBio sets the "bio" field. func (_c *AccountCreate) SetBio(v string) *AccountCreate { _c.mutation.SetBio(v) return _c } // SetNillableBio sets the "bio" field if the given value is not nil. func (_c *AccountCreate) SetNillableBio(v *string) *AccountCreate { if v != nil { _c.SetBio(*v) } return _c } // SetKind sets the "kind" field. func (_c *AccountCreate) SetKind(v account.Kind) *AccountCreate { _c.mutation.SetKind(v) return _c } // SetNillableKind sets the "kind" field if the given value is not nil. func (_c *AccountCreate) SetNillableKind(v *account.Kind) *AccountCreate { if v != nil { _c.SetKind(*v) } return _c } // SetAdmin sets the "admin" field. func (_c *AccountCreate) SetAdmin(v bool) *AccountCreate { _c.mutation.SetAdmin(v) return _c } // SetNillableAdmin sets the "admin" field if the given value is not nil. func (_c *AccountCreate) SetNillableAdmin(v *bool) *AccountCreate { if v != nil { _c.SetAdmin(*v) } return _c } // SetLinks sets the "links" field. func (_c *AccountCreate) SetLinks(v []schema.ExternalLink) *AccountCreate { _c.mutation.SetLinks(v) return _c } // SetMetadata sets the "metadata" field. func (_c *AccountCreate) SetMetadata(v map[string]interface{}) *AccountCreate { _c.mutation.SetMetadata(v) return _c } // SetInvitedByID sets the "invited_by_id" field. func (_c *AccountCreate) SetInvitedByID(v xid.ID) *AccountCreate { _c.mutation.SetInvitedByID(v) return _c } // SetNillableInvitedByID sets the "invited_by_id" field if the given value is not nil. func (_c *AccountCreate) SetNillableInvitedByID(v *xid.ID) *AccountCreate { if v != nil { _c.SetInvitedByID(*v) } return _c } // SetID sets the "id" field. func (_c *AccountCreate) SetID(v xid.ID) *AccountCreate { _c.mutation.SetID(v) return _c } // SetNillableID sets the "id" field if the given value is not nil. func (_c *AccountCreate) SetNillableID(v *xid.ID) *AccountCreate { if v != nil { _c.SetID(*v) } return _c } // AddSessionIDs adds the "sessions" edge to the Session entity by IDs. func (_c *AccountCreate) AddSessionIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddSessionIDs(ids...) return _c } // AddSessions adds the "sessions" edges to the Session entity. func (_c *AccountCreate) AddSessions(v ...*Session) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddSessionIDs(ids...) } // AddEmailIDs adds the "emails" edge to the Email entity by IDs. func (_c *AccountCreate) AddEmailIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddEmailIDs(ids...) return _c } // AddEmails adds the "emails" edges to the Email entity. func (_c *AccountCreate) AddEmails(v ...*Email) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddEmailIDs(ids...) } // AddNotificationIDs adds the "notifications" edge to the Notification entity by IDs. func (_c *AccountCreate) AddNotificationIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddNotificationIDs(ids...) return _c } // AddNotifications adds the "notifications" edges to the Notification entity. func (_c *AccountCreate) AddNotifications(v ...*Notification) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddNotificationIDs(ids...) } // AddTriggeredNotificationIDs adds the "triggered_notifications" edge to the Notification entity by IDs. func (_c *AccountCreate) AddTriggeredNotificationIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddTriggeredNotificationIDs(ids...) return _c } // AddTriggeredNotifications adds the "triggered_notifications" edges to the Notification entity. func (_c *AccountCreate) AddTriggeredNotifications(v ...*Notification) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddTriggeredNotificationIDs(ids...) } // AddFollowingIDs adds the "following" edge to the AccountFollow entity by IDs. func (_c *AccountCreate) AddFollowingIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddFollowingIDs(ids...) return _c } // AddFollowing adds the "following" edges to the AccountFollow entity. func (_c *AccountCreate) AddFollowing(v ...*AccountFollow) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddFollowingIDs(ids...) } // AddFollowedByIDs adds the "followed_by" edge to the AccountFollow entity by IDs. func (_c *AccountCreate) AddFollowedByIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddFollowedByIDs(ids...) return _c } // AddFollowedBy adds the "followed_by" edges to the AccountFollow entity. func (_c *AccountCreate) AddFollowedBy(v ...*AccountFollow) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddFollowedByIDs(ids...) } // AddInvitationIDs adds the "invitations" edge to the Invitation entity by IDs. func (_c *AccountCreate) AddInvitationIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddInvitationIDs(ids...) return _c } // AddInvitations adds the "invitations" edges to the Invitation entity. func (_c *AccountCreate) AddInvitations(v ...*Invitation) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddInvitationIDs(ids...) } // SetInvitedBy sets the "invited_by" edge to the Invitation entity. func (_c *AccountCreate) SetInvitedBy(v *Invitation) *AccountCreate { return _c.SetInvitedByID(v.ID) } // AddPostIDs adds the "posts" edge to the Post entity by IDs. func (_c *AccountCreate) AddPostIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddPostIDs(ids...) return _c } // AddPosts adds the "posts" edges to the Post entity. func (_c *AccountCreate) AddPosts(v ...*Post) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddPostIDs(ids...) } // AddQuestionIDs adds the "questions" edge to the Question entity by IDs. func (_c *AccountCreate) AddQuestionIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddQuestionIDs(ids...) return _c } // AddQuestions adds the "questions" edges to the Question entity. func (_c *AccountCreate) AddQuestions(v ...*Question) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddQuestionIDs(ids...) } // AddReactIDs adds the "reacts" edge to the React entity by IDs. func (_c *AccountCreate) AddReactIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddReactIDs(ids...) return _c } // AddReacts adds the "reacts" edges to the React entity. func (_c *AccountCreate) AddReacts(v ...*React) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddReactIDs(ids...) } // AddLikeIDs adds the "likes" edge to the LikePost entity by IDs. func (_c *AccountCreate) AddLikeIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddLikeIDs(ids...) return _c } // AddLikes adds the "likes" edges to the LikePost entity. func (_c *AccountCreate) AddLikes(v ...*LikePost) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddLikeIDs(ids...) } // AddMentionIDs adds the "mentions" edge to the MentionProfile entity by IDs. func (_c *AccountCreate) AddMentionIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddMentionIDs(ids...) return _c } // AddMentions adds the "mentions" edges to the MentionProfile entity. func (_c *AccountCreate) AddMentions(v ...*MentionProfile) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddMentionIDs(ids...) } // AddRoleIDs adds the "roles" edge to the Role entity by IDs. func (_c *AccountCreate) AddRoleIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddRoleIDs(ids...) return _c } // AddRoles adds the "roles" edges to the Role entity. func (_c *AccountCreate) AddRoles(v ...*Role) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddRoleIDs(ids...) } // AddAuthenticationIDs adds the "authentication" edge to the Authentication entity by IDs. func (_c *AccountCreate) AddAuthenticationIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddAuthenticationIDs(ids...) return _c } // AddAuthentication adds the "authentication" edges to the Authentication entity. func (_c *AccountCreate) AddAuthentication(v ...*Authentication) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddAuthenticationIDs(ids...) } // AddTagIDs adds the "tags" edge to the Tag entity by IDs. func (_c *AccountCreate) AddTagIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddTagIDs(ids...) return _c } // AddTags adds the "tags" edges to the Tag entity. func (_c *AccountCreate) AddTags(v ...*Tag) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddTagIDs(ids...) } // AddCollectionIDs adds the "collections" edge to the Collection entity by IDs. func (_c *AccountCreate) AddCollectionIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddCollectionIDs(ids...) return _c } // AddCollections adds the "collections" edges to the Collection entity. func (_c *AccountCreate) AddCollections(v ...*Collection) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddCollectionIDs(ids...) } // AddNodeIDs adds the "nodes" edge to the Node entity by IDs. func (_c *AccountCreate) AddNodeIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddNodeIDs(ids...) return _c } // AddNodes adds the "nodes" edges to the Node entity. func (_c *AccountCreate) AddNodes(v ...*Node) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddNodeIDs(ids...) } // AddAssetIDs adds the "assets" edge to the Asset entity by IDs. func (_c *AccountCreate) AddAssetIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddAssetIDs(ids...) return _c } // AddAssets adds the "assets" edges to the Asset entity. func (_c *AccountCreate) AddAssets(v ...*Asset) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddAssetIDs(ids...) } // AddEventIDs adds the "events" edge to the EventParticipant entity by IDs. func (_c *AccountCreate) AddEventIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddEventIDs(ids...) return _c } // AddEvents adds the "events" edges to the EventParticipant entity. func (_c *AccountCreate) AddEvents(v ...*EventParticipant) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddEventIDs(ids...) } // AddPostReadIDs adds the "post_reads" edge to the PostRead entity by IDs. func (_c *AccountCreate) AddPostReadIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddPostReadIDs(ids...) return _c } // AddPostReads adds the "post_reads" edges to the PostRead entity. func (_c *AccountCreate) AddPostReads(v ...*PostRead) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddPostReadIDs(ids...) } // AddReportIDs adds the "reports" edge to the Report entity by IDs. func (_c *AccountCreate) AddReportIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddReportIDs(ids...) return _c } // AddReports adds the "reports" edges to the Report entity. func (_c *AccountCreate) AddReports(v ...*Report) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddReportIDs(ids...) } // AddHandledReportIDs adds the "handled_reports" edge to the Report entity by IDs. func (_c *AccountCreate) AddHandledReportIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddHandledReportIDs(ids...) return _c } // AddHandledReports adds the "handled_reports" edges to the Report entity. func (_c *AccountCreate) AddHandledReports(v ...*Report) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddHandledReportIDs(ids...) } // AddAccountRoleIDs adds the "account_roles" edge to the AccountRoles entity by IDs. func (_c *AccountCreate) AddAccountRoleIDs(ids ...xid.ID) *AccountCreate { _c.mutation.AddAccountRoleIDs(ids...) return _c } // AddAccountRoles adds the "account_roles" edges to the AccountRoles entity. func (_c *AccountCreate) AddAccountRoles(v ...*AccountRoles) *AccountCreate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _c.AddAccountRoleIDs(ids...) } // Mutation returns the AccountMutation object of the builder. func (_c *AccountCreate) Mutation() *AccountMutation { return _c.mutation } // Save creates the Account in the database. func (_c *AccountCreate) Save(ctx context.Context) (*Account, error) { _c.defaults() return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. func (_c *AccountCreate) SaveX(ctx context.Context) *Account { v, err := _c.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (_c *AccountCreate) Exec(ctx context.Context) error { _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_c *AccountCreate) 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 *AccountCreate) defaults() { if _, ok := _c.mutation.CreatedAt(); !ok { v := account.DefaultCreatedAt() _c.mutation.SetCreatedAt(v) } if _, ok := _c.mutation.UpdatedAt(); !ok { v := account.DefaultUpdatedAt() _c.mutation.SetUpdatedAt(v) } if _, ok := _c.mutation.Kind(); !ok { v := account.DefaultKind _c.mutation.SetKind(v) } if _, ok := _c.mutation.Admin(); !ok { v := account.DefaultAdmin _c.mutation.SetAdmin(v) } if _, ok := _c.mutation.ID(); !ok { v := account.DefaultID() _c.mutation.SetID(v) } } // check runs all checks and user-defined validators on the builder. func (_c *AccountCreate) check() error { if _, ok := _c.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Account.created_at"`)} } if _, ok := _c.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Account.updated_at"`)} } if _, ok := _c.mutation.Handle(); !ok { return &ValidationError{Name: "handle", err: errors.New(`ent: missing required field "Account.handle"`)} } if v, ok := _c.mutation.Handle(); ok { if err := account.HandleValidator(v); err != nil { return &ValidationError{Name: "handle", err: fmt.Errorf(`ent: validator failed for field "Account.handle": %w`, err)} } } if _, ok := _c.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Account.name"`)} } if v, ok := _c.mutation.Name(); ok { if err := account.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Account.name": %w`, err)} } } if _, ok := _c.mutation.Kind(); !ok { return &ValidationError{Name: "kind", err: errors.New(`ent: missing required field "Account.kind"`)} } if v, ok := _c.mutation.Kind(); ok { if err := account.KindValidator(v); err != nil { return &ValidationError{Name: "kind", err: fmt.Errorf(`ent: validator failed for field "Account.kind": %w`, err)} } } if _, ok := _c.mutation.Admin(); !ok { return &ValidationError{Name: "admin", err: errors.New(`ent: missing required field "Account.admin"`)} } if v, ok := _c.mutation.ID(); ok { if err := account.IDValidator(v.String()); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Account.id": %w`, err)} } } return nil } func (_c *AccountCreate) sqlSave(ctx context.Context) (*Account, 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.(*xid.ID); 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 *AccountCreate) createSpec() (*Account, *sqlgraph.CreateSpec) { var ( _node = &Account{config: _c.config} _spec = sqlgraph.NewCreateSpec(account.Table, sqlgraph.NewFieldSpec(account.FieldID, field.TypeString)) ) _spec.OnConflict = _c.conflict if id, ok := _c.mutation.ID(); ok { _node.ID = id _spec.ID.Value = &id } if value, ok := _c.mutation.CreatedAt(); ok { _spec.SetField(account.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } if value, ok := _c.mutation.UpdatedAt(); ok { _spec.SetField(account.FieldUpdatedAt, field.TypeTime, value) _node.UpdatedAt = value } if value, ok := _c.mutation.DeletedAt(); ok { _spec.SetField(account.FieldDeletedAt, field.TypeTime, value) _node.DeletedAt = &value } if value, ok := _c.mutation.IndexedAt(); ok { _spec.SetField(account.FieldIndexedAt, field.TypeTime, value) _node.IndexedAt = &value } if value, ok := _c.mutation.Handle(); ok { _spec.SetField(account.FieldHandle, field.TypeString, value) _node.Handle = value } if value, ok := _c.mutation.Name(); ok { _spec.SetField(account.FieldName, field.TypeString, value) _node.Name = value } if value, ok := _c.mutation.Bio(); ok { _spec.SetField(account.FieldBio, field.TypeString, value) _node.Bio = value } if value, ok := _c.mutation.Kind(); ok { _spec.SetField(account.FieldKind, field.TypeEnum, value) _node.Kind = value } if value, ok := _c.mutation.Admin(); ok { _spec.SetField(account.FieldAdmin, field.TypeBool, value) _node.Admin = value } if value, ok := _c.mutation.Links(); ok { _spec.SetField(account.FieldLinks, field.TypeJSON, value) _node.Links = value } if value, ok := _c.mutation.Metadata(); ok { _spec.SetField(account.FieldMetadata, field.TypeJSON, value) _node.Metadata = value } if nodes := _c.mutation.SessionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.SessionsTable, Columns: []string{account.SessionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(session.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.EmailsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.EmailsTable, Columns: []string{account.EmailsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(email.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.NotificationsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.NotificationsTable, Columns: []string{account.NotificationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(notification.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.TriggeredNotificationsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.TriggeredNotificationsTable, Columns: []string{account.TriggeredNotificationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(notification.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.FollowingIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.FollowingTable, Columns: []string{account.FollowingColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(accountfollow.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.FollowedByIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.FollowedByTable, Columns: []string{account.FollowedByColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(accountfollow.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.InvitationsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.InvitationsTable, Columns: []string{account.InvitationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(invitation.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.InvitedByIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: account.InvitedByTable, Columns: []string{account.InvitedByColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(invitation.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _node.InvitedByID = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.PostsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.PostsTable, Columns: []string{account.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.QuestionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.QuestionsTable, Columns: []string{account.QuestionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.ReactsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.ReactsTable, Columns: []string{account.ReactsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(react.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.LikesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.LikesTable, Columns: []string{account.LikesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(likepost.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.MentionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.MentionsTable, Columns: []string{account.MentionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(mentionprofile.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.RolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: account.RolesTable, Columns: account.RolesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &AccountRolesCreate{config: _c.config, mutation: newAccountRolesMutation(_c.config, OpCreate)} createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { edge.Target.Fields = append(edge.Target.Fields, specE.ID) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.AuthenticationIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.AuthenticationTable, Columns: []string{account.AuthenticationColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(authentication.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.TagsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: account.TagsTable, Columns: account.TagsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.CollectionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.CollectionsTable, Columns: []string{account.CollectionsColumn}, 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 = append(_spec.Edges, edge) } if nodes := _c.mutation.NodesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.NodesTable, Columns: []string{account.NodesColumn}, 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 = append(_spec.Edges, edge) } if nodes := _c.mutation.AssetsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.AssetsTable, Columns: []string{account.AssetsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.EventsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.EventsTable, Columns: []string{account.EventsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(eventparticipant.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.PostReadsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.PostReadsTable, Columns: []string{account.PostReadsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postread.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.ReportsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.ReportsTable, Columns: []string{account.ReportsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(report.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.HandledReportsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: account.HandledReportsTable, Columns: []string{account.HandledReportsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(report.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.AccountRolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, Table: account.AccountRolesTable, Columns: []string{account.AccountRolesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(accountroles.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _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.Account.Create(). // SetCreatedAt(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.AccountUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (_c *AccountCreate) OnConflict(opts ...sql.ConflictOption) *AccountUpsertOne { _c.conflict = opts return &AccountUpsertOne{ create: _c, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.Account.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (_c *AccountCreate) OnConflictColumns(columns ...string) *AccountUpsertOne { _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) return &AccountUpsertOne{ create: _c, } } type ( // AccountUpsertOne is the builder for "upsert"-ing // one Account node. AccountUpsertOne struct { create *AccountCreate } // AccountUpsert is the "OnConflict" setter. AccountUpsert struct { *sql.UpdateSet } ) // SetUpdatedAt sets the "updated_at" field. func (u *AccountUpsert) SetUpdatedAt(v time.Time) *AccountUpsert { u.Set(account.FieldUpdatedAt, v) return u } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *AccountUpsert) UpdateUpdatedAt() *AccountUpsert { u.SetExcluded(account.FieldUpdatedAt) return u } // SetDeletedAt sets the "deleted_at" field. func (u *AccountUpsert) SetDeletedAt(v time.Time) *AccountUpsert { u.Set(account.FieldDeletedAt, v) return u } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *AccountUpsert) UpdateDeletedAt() *AccountUpsert { u.SetExcluded(account.FieldDeletedAt) return u } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *AccountUpsert) ClearDeletedAt() *AccountUpsert { u.SetNull(account.FieldDeletedAt) return u } // SetIndexedAt sets the "indexed_at" field. func (u *AccountUpsert) SetIndexedAt(v time.Time) *AccountUpsert { u.Set(account.FieldIndexedAt, v) return u } // UpdateIndexedAt sets the "indexed_at" field to the value that was provided on create. func (u *AccountUpsert) UpdateIndexedAt() *AccountUpsert { u.SetExcluded(account.FieldIndexedAt) return u } // ClearIndexedAt clears the value of the "indexed_at" field. func (u *AccountUpsert) ClearIndexedAt() *AccountUpsert { u.SetNull(account.FieldIndexedAt) return u } // SetHandle sets the "handle" field. func (u *AccountUpsert) SetHandle(v string) *AccountUpsert { u.Set(account.FieldHandle, v) return u } // UpdateHandle sets the "handle" field to the value that was provided on create. func (u *AccountUpsert) UpdateHandle() *AccountUpsert { u.SetExcluded(account.FieldHandle) return u } // SetName sets the "name" field. func (u *AccountUpsert) SetName(v string) *AccountUpsert { u.Set(account.FieldName, v) return u } // UpdateName sets the "name" field to the value that was provided on create. func (u *AccountUpsert) UpdateName() *AccountUpsert { u.SetExcluded(account.FieldName) return u } // SetBio sets the "bio" field. func (u *AccountUpsert) SetBio(v string) *AccountUpsert { u.Set(account.FieldBio, v) return u } // UpdateBio sets the "bio" field to the value that was provided on create. func (u *AccountUpsert) UpdateBio() *AccountUpsert { u.SetExcluded(account.FieldBio) return u } // ClearBio clears the value of the "bio" field. func (u *AccountUpsert) ClearBio() *AccountUpsert { u.SetNull(account.FieldBio) return u } // SetKind sets the "kind" field. func (u *AccountUpsert) SetKind(v account.Kind) *AccountUpsert { u.Set(account.FieldKind, v) return u } // UpdateKind sets the "kind" field to the value that was provided on create. func (u *AccountUpsert) UpdateKind() *AccountUpsert { u.SetExcluded(account.FieldKind) return u } // SetAdmin sets the "admin" field. func (u *AccountUpsert) SetAdmin(v bool) *AccountUpsert { u.Set(account.FieldAdmin, v) return u } // UpdateAdmin sets the "admin" field to the value that was provided on create. func (u *AccountUpsert) UpdateAdmin() *AccountUpsert { u.SetExcluded(account.FieldAdmin) return u } // SetLinks sets the "links" field. func (u *AccountUpsert) SetLinks(v []schema.ExternalLink) *AccountUpsert { u.Set(account.FieldLinks, v) return u } // UpdateLinks sets the "links" field to the value that was provided on create. func (u *AccountUpsert) UpdateLinks() *AccountUpsert { u.SetExcluded(account.FieldLinks) return u } // ClearLinks clears the value of the "links" field. func (u *AccountUpsert) ClearLinks() *AccountUpsert { u.SetNull(account.FieldLinks) return u } // SetMetadata sets the "metadata" field. func (u *AccountUpsert) SetMetadata(v map[string]interface{}) *AccountUpsert { u.Set(account.FieldMetadata, v) return u } // UpdateMetadata sets the "metadata" field to the value that was provided on create. func (u *AccountUpsert) UpdateMetadata() *AccountUpsert { u.SetExcluded(account.FieldMetadata) return u } // ClearMetadata clears the value of the "metadata" field. func (u *AccountUpsert) ClearMetadata() *AccountUpsert { u.SetNull(account.FieldMetadata) return u } // SetInvitedByID sets the "invited_by_id" field. func (u *AccountUpsert) SetInvitedByID(v xid.ID) *AccountUpsert { u.Set(account.FieldInvitedByID, v) return u } // UpdateInvitedByID sets the "invited_by_id" field to the value that was provided on create. func (u *AccountUpsert) UpdateInvitedByID() *AccountUpsert { u.SetExcluded(account.FieldInvitedByID) return u } // ClearInvitedByID clears the value of the "invited_by_id" field. func (u *AccountUpsert) ClearInvitedByID() *AccountUpsert { u.SetNull(account.FieldInvitedByID) 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.Account.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(account.FieldID) // }), // ). // Exec(ctx) func (u *AccountUpsertOne) UpdateNewValues() *AccountUpsertOne { 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(account.FieldID) } if _, exists := u.create.mutation.CreatedAt(); exists { s.SetIgnore(account.FieldCreatedAt) } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.Account.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *AccountUpsertOne) Ignore() *AccountUpsertOne { 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 *AccountUpsertOne) DoNothing() *AccountUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the AccountCreate.OnConflict // documentation for more info. func (u *AccountUpsertOne) Update(set func(*AccountUpsert)) *AccountUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&AccountUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *AccountUpsertOne) SetUpdatedAt(v time.Time) *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *AccountUpsertOne) UpdateUpdatedAt() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.UpdateUpdatedAt() }) } // SetDeletedAt sets the "deleted_at" field. func (u *AccountUpsertOne) SetDeletedAt(v time.Time) *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.SetDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *AccountUpsertOne) UpdateDeletedAt() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *AccountUpsertOne) ClearDeletedAt() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.ClearDeletedAt() }) } // SetIndexedAt sets the "indexed_at" field. func (u *AccountUpsertOne) SetIndexedAt(v time.Time) *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.SetIndexedAt(v) }) } // UpdateIndexedAt sets the "indexed_at" field to the value that was provided on create. func (u *AccountUpsertOne) UpdateIndexedAt() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.UpdateIndexedAt() }) } // ClearIndexedAt clears the value of the "indexed_at" field. func (u *AccountUpsertOne) ClearIndexedAt() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.ClearIndexedAt() }) } // SetHandle sets the "handle" field. func (u *AccountUpsertOne) SetHandle(v string) *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.SetHandle(v) }) } // UpdateHandle sets the "handle" field to the value that was provided on create. func (u *AccountUpsertOne) UpdateHandle() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.UpdateHandle() }) } // SetName sets the "name" field. func (u *AccountUpsertOne) SetName(v string) *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.SetName(v) }) } // UpdateName sets the "name" field to the value that was provided on create. func (u *AccountUpsertOne) UpdateName() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.UpdateName() }) } // SetBio sets the "bio" field. func (u *AccountUpsertOne) SetBio(v string) *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.SetBio(v) }) } // UpdateBio sets the "bio" field to the value that was provided on create. func (u *AccountUpsertOne) UpdateBio() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.UpdateBio() }) } // ClearBio clears the value of the "bio" field. func (u *AccountUpsertOne) ClearBio() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.ClearBio() }) } // SetKind sets the "kind" field. func (u *AccountUpsertOne) SetKind(v account.Kind) *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.SetKind(v) }) } // UpdateKind sets the "kind" field to the value that was provided on create. func (u *AccountUpsertOne) UpdateKind() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.UpdateKind() }) } // SetAdmin sets the "admin" field. func (u *AccountUpsertOne) SetAdmin(v bool) *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.SetAdmin(v) }) } // UpdateAdmin sets the "admin" field to the value that was provided on create. func (u *AccountUpsertOne) UpdateAdmin() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.UpdateAdmin() }) } // SetLinks sets the "links" field. func (u *AccountUpsertOne) SetLinks(v []schema.ExternalLink) *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.SetLinks(v) }) } // UpdateLinks sets the "links" field to the value that was provided on create. func (u *AccountUpsertOne) UpdateLinks() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.UpdateLinks() }) } // ClearLinks clears the value of the "links" field. func (u *AccountUpsertOne) ClearLinks() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.ClearLinks() }) } // SetMetadata sets the "metadata" field. func (u *AccountUpsertOne) SetMetadata(v map[string]interface{}) *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.SetMetadata(v) }) } // UpdateMetadata sets the "metadata" field to the value that was provided on create. func (u *AccountUpsertOne) UpdateMetadata() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.UpdateMetadata() }) } // ClearMetadata clears the value of the "metadata" field. func (u *AccountUpsertOne) ClearMetadata() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.ClearMetadata() }) } // SetInvitedByID sets the "invited_by_id" field. func (u *AccountUpsertOne) SetInvitedByID(v xid.ID) *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.SetInvitedByID(v) }) } // UpdateInvitedByID sets the "invited_by_id" field to the value that was provided on create. func (u *AccountUpsertOne) UpdateInvitedByID() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.UpdateInvitedByID() }) } // ClearInvitedByID clears the value of the "invited_by_id" field. func (u *AccountUpsertOne) ClearInvitedByID() *AccountUpsertOne { return u.Update(func(s *AccountUpsert) { s.ClearInvitedByID() }) } // Exec executes the query. func (u *AccountUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { return errors.New("ent: missing options for AccountCreate.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *AccountUpsertOne) 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 *AccountUpsertOne) ID(ctx context.Context) (id xid.ID, 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("ent: AccountUpsertOne.ID is not supported by MySQL driver. Use AccountUpsertOne.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 *AccountUpsertOne) IDX(ctx context.Context) xid.ID { id, err := u.ID(ctx) if err != nil { panic(err) } return id } // AccountCreateBulk is the builder for creating many Account entities in bulk. type AccountCreateBulk struct { config err error builders []*AccountCreate conflict []sql.ConflictOption } // Save creates the Account entities in the database. func (_c *AccountCreateBulk) Save(ctx context.Context) ([]*Account, error) { if _c.err != nil { return nil, _c.err } specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) nodes := make([]*Account, 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.(*AccountMutation) 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 *AccountCreateBulk) SaveX(ctx context.Context) []*Account { v, err := _c.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (_c *AccountCreateBulk) Exec(ctx context.Context) error { _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_c *AccountCreateBulk) 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.Account.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.AccountUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (_c *AccountCreateBulk) OnConflict(opts ...sql.ConflictOption) *AccountUpsertBulk { _c.conflict = opts return &AccountUpsertBulk{ create: _c, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.Account.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (_c *AccountCreateBulk) OnConflictColumns(columns ...string) *AccountUpsertBulk { _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) return &AccountUpsertBulk{ create: _c, } } // AccountUpsertBulk is the builder for "upsert"-ing // a bulk of Account nodes. type AccountUpsertBulk struct { create *AccountCreateBulk } // UpdateNewValues updates the mutable fields using the new values that // were set on create. Using this option is equivalent to using: // // client.Account.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(account.FieldID) // }), // ). // Exec(ctx) func (u *AccountUpsertBulk) UpdateNewValues() *AccountUpsertBulk { 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(account.FieldID) } if _, exists := b.mutation.CreatedAt(); exists { s.SetIgnore(account.FieldCreatedAt) } } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.Account.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *AccountUpsertBulk) Ignore() *AccountUpsertBulk { 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 *AccountUpsertBulk) DoNothing() *AccountUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the AccountCreateBulk.OnConflict // documentation for more info. func (u *AccountUpsertBulk) Update(set func(*AccountUpsert)) *AccountUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&AccountUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *AccountUpsertBulk) SetUpdatedAt(v time.Time) *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *AccountUpsertBulk) UpdateUpdatedAt() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.UpdateUpdatedAt() }) } // SetDeletedAt sets the "deleted_at" field. func (u *AccountUpsertBulk) SetDeletedAt(v time.Time) *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.SetDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *AccountUpsertBulk) UpdateDeletedAt() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *AccountUpsertBulk) ClearDeletedAt() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.ClearDeletedAt() }) } // SetIndexedAt sets the "indexed_at" field. func (u *AccountUpsertBulk) SetIndexedAt(v time.Time) *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.SetIndexedAt(v) }) } // UpdateIndexedAt sets the "indexed_at" field to the value that was provided on create. func (u *AccountUpsertBulk) UpdateIndexedAt() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.UpdateIndexedAt() }) } // ClearIndexedAt clears the value of the "indexed_at" field. func (u *AccountUpsertBulk) ClearIndexedAt() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.ClearIndexedAt() }) } // SetHandle sets the "handle" field. func (u *AccountUpsertBulk) SetHandle(v string) *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.SetHandle(v) }) } // UpdateHandle sets the "handle" field to the value that was provided on create. func (u *AccountUpsertBulk) UpdateHandle() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.UpdateHandle() }) } // SetName sets the "name" field. func (u *AccountUpsertBulk) SetName(v string) *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.SetName(v) }) } // UpdateName sets the "name" field to the value that was provided on create. func (u *AccountUpsertBulk) UpdateName() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.UpdateName() }) } // SetBio sets the "bio" field. func (u *AccountUpsertBulk) SetBio(v string) *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.SetBio(v) }) } // UpdateBio sets the "bio" field to the value that was provided on create. func (u *AccountUpsertBulk) UpdateBio() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.UpdateBio() }) } // ClearBio clears the value of the "bio" field. func (u *AccountUpsertBulk) ClearBio() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.ClearBio() }) } // SetKind sets the "kind" field. func (u *AccountUpsertBulk) SetKind(v account.Kind) *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.SetKind(v) }) } // UpdateKind sets the "kind" field to the value that was provided on create. func (u *AccountUpsertBulk) UpdateKind() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.UpdateKind() }) } // SetAdmin sets the "admin" field. func (u *AccountUpsertBulk) SetAdmin(v bool) *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.SetAdmin(v) }) } // UpdateAdmin sets the "admin" field to the value that was provided on create. func (u *AccountUpsertBulk) UpdateAdmin() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.UpdateAdmin() }) } // SetLinks sets the "links" field. func (u *AccountUpsertBulk) SetLinks(v []schema.ExternalLink) *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.SetLinks(v) }) } // UpdateLinks sets the "links" field to the value that was provided on create. func (u *AccountUpsertBulk) UpdateLinks() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.UpdateLinks() }) } // ClearLinks clears the value of the "links" field. func (u *AccountUpsertBulk) ClearLinks() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.ClearLinks() }) } // SetMetadata sets the "metadata" field. func (u *AccountUpsertBulk) SetMetadata(v map[string]interface{}) *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.SetMetadata(v) }) } // UpdateMetadata sets the "metadata" field to the value that was provided on create. func (u *AccountUpsertBulk) UpdateMetadata() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.UpdateMetadata() }) } // ClearMetadata clears the value of the "metadata" field. func (u *AccountUpsertBulk) ClearMetadata() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.ClearMetadata() }) } // SetInvitedByID sets the "invited_by_id" field. func (u *AccountUpsertBulk) SetInvitedByID(v xid.ID) *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.SetInvitedByID(v) }) } // UpdateInvitedByID sets the "invited_by_id" field to the value that was provided on create. func (u *AccountUpsertBulk) UpdateInvitedByID() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.UpdateInvitedByID() }) } // ClearInvitedByID clears the value of the "invited_by_id" field. func (u *AccountUpsertBulk) ClearInvitedByID() *AccountUpsertBulk { return u.Update(func(s *AccountUpsert) { s.ClearInvitedByID() }) } // Exec executes the query. func (u *AccountUpsertBulk) 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("ent: OnConflict was set for builder %d. Set it on the AccountCreateBulk instead", i) } } if len(u.create.conflict) == 0 { return errors.New("ent: missing options for AccountCreateBulk.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *AccountUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } }

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