Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
227
account_query.go78.6 kB
// Code generated by ent, DO NOT EDIT. package ent import ( "context" "database/sql/driver" "fmt" "math" "entgo.io/ent" "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/predicate" "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/session" "github.com/Southclaws/storyden/internal/ent/tag" "github.com/rs/xid" ) // AccountQuery is the builder for querying Account entities. type AccountQuery struct { config ctx *QueryContext order []account.OrderOption inters []Interceptor predicates []predicate.Account withSessions *SessionQuery withEmails *EmailQuery withNotifications *NotificationQuery withTriggeredNotifications *NotificationQuery withFollowing *AccountFollowQuery withFollowedBy *AccountFollowQuery withInvitations *InvitationQuery withInvitedBy *InvitationQuery withPosts *PostQuery withQuestions *QuestionQuery withReacts *ReactQuery withLikes *LikePostQuery withMentions *MentionProfileQuery withRoles *RoleQuery withAuthentication *AuthenticationQuery withTags *TagQuery withCollections *CollectionQuery withNodes *NodeQuery withAssets *AssetQuery withEvents *EventParticipantQuery withPostReads *PostReadQuery withReports *ReportQuery withHandledReports *ReportQuery withAccountRoles *AccountRolesQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) } // Where adds a new predicate for the AccountQuery builder. func (_q *AccountQuery) Where(ps ...predicate.Account) *AccountQuery { _q.predicates = append(_q.predicates, ps...) return _q } // Limit the number of records to be returned by this query. func (_q *AccountQuery) Limit(limit int) *AccountQuery { _q.ctx.Limit = &limit return _q } // Offset to start from. func (_q *AccountQuery) Offset(offset int) *AccountQuery { _q.ctx.Offset = &offset return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. func (_q *AccountQuery) Unique(unique bool) *AccountQuery { _q.ctx.Unique = &unique return _q } // Order specifies how the records should be ordered. func (_q *AccountQuery) Order(o ...account.OrderOption) *AccountQuery { _q.order = append(_q.order, o...) return _q } // QuerySessions chains the current query on the "sessions" edge. func (_q *AccountQuery) QuerySessions() *SessionQuery { query := (&SessionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(session.Table, session.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.SessionsTable, account.SessionsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryEmails chains the current query on the "emails" edge. func (_q *AccountQuery) QueryEmails() *EmailQuery { query := (&EmailClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(email.Table, email.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.EmailsTable, account.EmailsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryNotifications chains the current query on the "notifications" edge. func (_q *AccountQuery) QueryNotifications() *NotificationQuery { query := (&NotificationClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(notification.Table, notification.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.NotificationsTable, account.NotificationsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryTriggeredNotifications chains the current query on the "triggered_notifications" edge. func (_q *AccountQuery) QueryTriggeredNotifications() *NotificationQuery { query := (&NotificationClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(notification.Table, notification.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.TriggeredNotificationsTable, account.TriggeredNotificationsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryFollowing chains the current query on the "following" edge. func (_q *AccountQuery) QueryFollowing() *AccountFollowQuery { query := (&AccountFollowClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(accountfollow.Table, accountfollow.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.FollowingTable, account.FollowingColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryFollowedBy chains the current query on the "followed_by" edge. func (_q *AccountQuery) QueryFollowedBy() *AccountFollowQuery { query := (&AccountFollowClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(accountfollow.Table, accountfollow.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.FollowedByTable, account.FollowedByColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryInvitations chains the current query on the "invitations" edge. func (_q *AccountQuery) QueryInvitations() *InvitationQuery { query := (&InvitationClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(invitation.Table, invitation.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.InvitationsTable, account.InvitationsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryInvitedBy chains the current query on the "invited_by" edge. func (_q *AccountQuery) QueryInvitedBy() *InvitationQuery { query := (&InvitationClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(invitation.Table, invitation.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, account.InvitedByTable, account.InvitedByColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPosts chains the current query on the "posts" edge. func (_q *AccountQuery) QueryPosts() *PostQuery { query := (&PostClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(post.Table, post.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.PostsTable, account.PostsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryQuestions chains the current query on the "questions" edge. func (_q *AccountQuery) QueryQuestions() *QuestionQuery { query := (&QuestionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(question.Table, question.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.QuestionsTable, account.QuestionsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryReacts chains the current query on the "reacts" edge. func (_q *AccountQuery) QueryReacts() *ReactQuery { query := (&ReactClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(react.Table, react.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.ReactsTable, account.ReactsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryLikes chains the current query on the "likes" edge. func (_q *AccountQuery) QueryLikes() *LikePostQuery { query := (&LikePostClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(likepost.Table, likepost.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.LikesTable, account.LikesColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryMentions chains the current query on the "mentions" edge. func (_q *AccountQuery) QueryMentions() *MentionProfileQuery { query := (&MentionProfileClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(mentionprofile.Table, mentionprofile.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.MentionsTable, account.MentionsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryRoles chains the current query on the "roles" edge. func (_q *AccountQuery) QueryRoles() *RoleQuery { query := (&RoleClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(role.Table, role.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, account.RolesTable, account.RolesPrimaryKey...), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryAuthentication chains the current query on the "authentication" edge. func (_q *AccountQuery) QueryAuthentication() *AuthenticationQuery { query := (&AuthenticationClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(authentication.Table, authentication.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.AuthenticationTable, account.AuthenticationColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryTags chains the current query on the "tags" edge. func (_q *AccountQuery) QueryTags() *TagQuery { query := (&TagClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(tag.Table, tag.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, account.TagsTable, account.TagsPrimaryKey...), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryCollections chains the current query on the "collections" edge. func (_q *AccountQuery) QueryCollections() *CollectionQuery { query := (&CollectionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(collection.Table, collection.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.CollectionsTable, account.CollectionsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryNodes chains the current query on the "nodes" edge. func (_q *AccountQuery) QueryNodes() *NodeQuery { query := (&NodeClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(node.Table, node.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.NodesTable, account.NodesColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryAssets chains the current query on the "assets" edge. func (_q *AccountQuery) QueryAssets() *AssetQuery { query := (&AssetClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(asset.Table, asset.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.AssetsTable, account.AssetsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryEvents chains the current query on the "events" edge. func (_q *AccountQuery) QueryEvents() *EventParticipantQuery { query := (&EventParticipantClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(eventparticipant.Table, eventparticipant.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.EventsTable, account.EventsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPostReads chains the current query on the "post_reads" edge. func (_q *AccountQuery) QueryPostReads() *PostReadQuery { query := (&PostReadClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(postread.Table, postread.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.PostReadsTable, account.PostReadsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryReports chains the current query on the "reports" edge. func (_q *AccountQuery) QueryReports() *ReportQuery { query := (&ReportClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(report.Table, report.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.ReportsTable, account.ReportsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryHandledReports chains the current query on the "handled_reports" edge. func (_q *AccountQuery) QueryHandledReports() *ReportQuery { query := (&ReportClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(report.Table, report.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.HandledReportsTable, account.HandledReportsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryAccountRoles chains the current query on the "account_roles" edge. func (_q *AccountQuery) QueryAccountRoles() *AccountRolesQuery { query := (&AccountRolesClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err } selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, selector), sqlgraph.To(accountroles.Table, accountroles.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, account.AccountRolesTable, account.AccountRolesColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // First returns the first Account entity from the query. // Returns a *NotFoundError when no Account was found. func (_q *AccountQuery) First(ctx context.Context) (*Account, error) { nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } if len(nodes) == 0 { return nil, &NotFoundError{account.Label} } return nodes[0], nil } // FirstX is like First, but panics if an error occurs. func (_q *AccountQuery) FirstX(ctx context.Context) *Account { node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } return node } // FirstID returns the first Account ID from the query. // Returns a *NotFoundError when no Account ID was found. func (_q *AccountQuery) FirstID(ctx context.Context) (id xid.ID, err error) { var ids []xid.ID if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { err = &NotFoundError{account.Label} return } return ids[0], nil } // FirstIDX is like FirstID, but panics if an error occurs. func (_q *AccountQuery) FirstIDX(ctx context.Context) xid.ID { id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } return id } // Only returns a single Account entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one Account entity is found. // Returns a *NotFoundError when no Account entities are found. func (_q *AccountQuery) Only(ctx context.Context) (*Account, error) { nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } switch len(nodes) { case 1: return nodes[0], nil case 0: return nil, &NotFoundError{account.Label} default: return nil, &NotSingularError{account.Label} } } // OnlyX is like Only, but panics if an error occurs. func (_q *AccountQuery) OnlyX(ctx context.Context) *Account { node, err := _q.Only(ctx) if err != nil { panic(err) } return node } // OnlyID is like Only, but returns the only Account ID in the query. // Returns a *NotSingularError when more than one Account ID is found. // Returns a *NotFoundError when no entities are found. func (_q *AccountQuery) OnlyID(ctx context.Context) (id xid.ID, err error) { var ids []xid.ID if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { case 1: id = ids[0] case 0: err = &NotFoundError{account.Label} default: err = &NotSingularError{account.Label} } return } // OnlyIDX is like OnlyID, but panics if an error occurs. func (_q *AccountQuery) OnlyIDX(ctx context.Context) xid.ID { id, err := _q.OnlyID(ctx) if err != nil { panic(err) } return id } // All executes the query and returns a list of Accounts. func (_q *AccountQuery) All(ctx context.Context) ([]*Account, error) { ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*Account, *AccountQuery]() return withInterceptors[[]*Account](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. func (_q *AccountQuery) AllX(ctx context.Context) []*Account { nodes, err := _q.All(ctx) if err != nil { panic(err) } return nodes } // IDs executes the query and returns a list of Account IDs. func (_q *AccountQuery) IDs(ctx context.Context) (ids []xid.ID, err error) { if _q.ctx.Unique == nil && _q.path != nil { _q.Unique(true) } ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) if err = _q.Select(account.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. func (_q *AccountQuery) IDsX(ctx context.Context) []xid.ID { ids, err := _q.IDs(ctx) if err != nil { panic(err) } return ids } // Count returns the count of the given query. func (_q *AccountQuery) Count(ctx context.Context) (int, error) { ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) if err := _q.prepareQuery(ctx); err != nil { return 0, err } return withInterceptors[int](ctx, _q, querierCount[*AccountQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. func (_q *AccountQuery) CountX(ctx context.Context) int { count, err := _q.Count(ctx) if err != nil { panic(err) } return count } // Exist returns true if the query has elements in the graph. func (_q *AccountQuery) Exist(ctx context.Context) (bool, error) { ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: return false, fmt.Errorf("ent: check existence: %w", err) default: return true, nil } } // ExistX is like Exist, but panics if an error occurs. func (_q *AccountQuery) ExistX(ctx context.Context) bool { exist, err := _q.Exist(ctx) if err != nil { panic(err) } return exist } // Clone returns a duplicate of the AccountQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. func (_q *AccountQuery) Clone() *AccountQuery { if _q == nil { return nil } return &AccountQuery{ config: _q.config, ctx: _q.ctx.Clone(), order: append([]account.OrderOption{}, _q.order...), inters: append([]Interceptor{}, _q.inters...), predicates: append([]predicate.Account{}, _q.predicates...), withSessions: _q.withSessions.Clone(), withEmails: _q.withEmails.Clone(), withNotifications: _q.withNotifications.Clone(), withTriggeredNotifications: _q.withTriggeredNotifications.Clone(), withFollowing: _q.withFollowing.Clone(), withFollowedBy: _q.withFollowedBy.Clone(), withInvitations: _q.withInvitations.Clone(), withInvitedBy: _q.withInvitedBy.Clone(), withPosts: _q.withPosts.Clone(), withQuestions: _q.withQuestions.Clone(), withReacts: _q.withReacts.Clone(), withLikes: _q.withLikes.Clone(), withMentions: _q.withMentions.Clone(), withRoles: _q.withRoles.Clone(), withAuthentication: _q.withAuthentication.Clone(), withTags: _q.withTags.Clone(), withCollections: _q.withCollections.Clone(), withNodes: _q.withNodes.Clone(), withAssets: _q.withAssets.Clone(), withEvents: _q.withEvents.Clone(), withPostReads: _q.withPostReads.Clone(), withReports: _q.withReports.Clone(), withHandledReports: _q.withHandledReports.Clone(), withAccountRoles: _q.withAccountRoles.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithSessions tells the query-builder to eager-load the nodes that are connected to // the "sessions" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithSessions(opts ...func(*SessionQuery)) *AccountQuery { query := (&SessionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withSessions = query return _q } // WithEmails tells the query-builder to eager-load the nodes that are connected to // the "emails" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithEmails(opts ...func(*EmailQuery)) *AccountQuery { query := (&EmailClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withEmails = query return _q } // WithNotifications tells the query-builder to eager-load the nodes that are connected to // the "notifications" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithNotifications(opts ...func(*NotificationQuery)) *AccountQuery { query := (&NotificationClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withNotifications = query return _q } // WithTriggeredNotifications tells the query-builder to eager-load the nodes that are connected to // the "triggered_notifications" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithTriggeredNotifications(opts ...func(*NotificationQuery)) *AccountQuery { query := (&NotificationClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withTriggeredNotifications = query return _q } // WithFollowing tells the query-builder to eager-load the nodes that are connected to // the "following" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithFollowing(opts ...func(*AccountFollowQuery)) *AccountQuery { query := (&AccountFollowClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withFollowing = query return _q } // WithFollowedBy tells the query-builder to eager-load the nodes that are connected to // the "followed_by" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithFollowedBy(opts ...func(*AccountFollowQuery)) *AccountQuery { query := (&AccountFollowClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withFollowedBy = query return _q } // WithInvitations tells the query-builder to eager-load the nodes that are connected to // the "invitations" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithInvitations(opts ...func(*InvitationQuery)) *AccountQuery { query := (&InvitationClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withInvitations = query return _q } // WithInvitedBy tells the query-builder to eager-load the nodes that are connected to // the "invited_by" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithInvitedBy(opts ...func(*InvitationQuery)) *AccountQuery { query := (&InvitationClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withInvitedBy = query return _q } // WithPosts tells the query-builder to eager-load the nodes that are connected to // the "posts" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithPosts(opts ...func(*PostQuery)) *AccountQuery { query := (&PostClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withPosts = query return _q } // WithQuestions tells the query-builder to eager-load the nodes that are connected to // the "questions" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithQuestions(opts ...func(*QuestionQuery)) *AccountQuery { query := (&QuestionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withQuestions = query return _q } // WithReacts tells the query-builder to eager-load the nodes that are connected to // the "reacts" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithReacts(opts ...func(*ReactQuery)) *AccountQuery { query := (&ReactClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withReacts = query return _q } // WithLikes tells the query-builder to eager-load the nodes that are connected to // the "likes" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithLikes(opts ...func(*LikePostQuery)) *AccountQuery { query := (&LikePostClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withLikes = query return _q } // WithMentions tells the query-builder to eager-load the nodes that are connected to // the "mentions" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithMentions(opts ...func(*MentionProfileQuery)) *AccountQuery { query := (&MentionProfileClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withMentions = query return _q } // WithRoles tells the query-builder to eager-load the nodes that are connected to // the "roles" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithRoles(opts ...func(*RoleQuery)) *AccountQuery { query := (&RoleClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withRoles = query return _q } // WithAuthentication tells the query-builder to eager-load the nodes that are connected to // the "authentication" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithAuthentication(opts ...func(*AuthenticationQuery)) *AccountQuery { query := (&AuthenticationClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withAuthentication = query return _q } // WithTags tells the query-builder to eager-load the nodes that are connected to // the "tags" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithTags(opts ...func(*TagQuery)) *AccountQuery { query := (&TagClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withTags = query return _q } // WithCollections tells the query-builder to eager-load the nodes that are connected to // the "collections" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithCollections(opts ...func(*CollectionQuery)) *AccountQuery { query := (&CollectionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withCollections = query return _q } // WithNodes tells the query-builder to eager-load the nodes that are connected to // the "nodes" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithNodes(opts ...func(*NodeQuery)) *AccountQuery { query := (&NodeClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withNodes = query return _q } // WithAssets tells the query-builder to eager-load the nodes that are connected to // the "assets" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithAssets(opts ...func(*AssetQuery)) *AccountQuery { query := (&AssetClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withAssets = query return _q } // WithEvents tells the query-builder to eager-load the nodes that are connected to // the "events" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithEvents(opts ...func(*EventParticipantQuery)) *AccountQuery { query := (&EventParticipantClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withEvents = query return _q } // WithPostReads tells the query-builder to eager-load the nodes that are connected to // the "post_reads" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithPostReads(opts ...func(*PostReadQuery)) *AccountQuery { query := (&PostReadClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withPostReads = query return _q } // WithReports tells the query-builder to eager-load the nodes that are connected to // the "reports" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithReports(opts ...func(*ReportQuery)) *AccountQuery { query := (&ReportClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withReports = query return _q } // WithHandledReports tells the query-builder to eager-load the nodes that are connected to // the "handled_reports" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithHandledReports(opts ...func(*ReportQuery)) *AccountQuery { query := (&ReportClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withHandledReports = query return _q } // WithAccountRoles tells the query-builder to eager-load the nodes that are connected to // the "account_roles" edge. The optional arguments are used to configure the query builder of the edge. func (_q *AccountQuery) WithAccountRoles(opts ...func(*AccountRolesQuery)) *AccountQuery { query := (&AccountRolesClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } _q.withAccountRoles = query return _q } // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // // Example: // // var v []struct { // CreatedAt time.Time `json:"created_at,omitempty"` // Count int `json:"count,omitempty"` // } // // client.Account.Query(). // GroupBy(account.FieldCreatedAt). // Aggregate(ent.Count()). // Scan(ctx, &v) func (_q *AccountQuery) GroupBy(field string, fields ...string) *AccountGroupBy { _q.ctx.Fields = append([]string{field}, fields...) grbuild := &AccountGroupBy{build: _q} grbuild.flds = &_q.ctx.Fields grbuild.label = account.Label grbuild.scan = grbuild.Scan return grbuild } // Select allows the selection one or more fields/columns for the given query, // instead of selecting all fields in the entity. // // Example: // // var v []struct { // CreatedAt time.Time `json:"created_at,omitempty"` // } // // client.Account.Query(). // Select(account.FieldCreatedAt). // Scan(ctx, &v) func (_q *AccountQuery) Select(fields ...string) *AccountSelect { _q.ctx.Fields = append(_q.ctx.Fields, fields...) sbuild := &AccountSelect{AccountQuery: _q} sbuild.label = account.Label sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a AccountSelect configured with the given aggregations. func (_q *AccountQuery) Aggregate(fns ...AggregateFunc) *AccountSelect { return _q.Select().Aggregate(fns...) } func (_q *AccountQuery) prepareQuery(ctx context.Context) error { for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { if err := trv.Traverse(ctx, _q); err != nil { return err } } } for _, f := range _q.ctx.Fields { if !account.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } if _q.path != nil { prev, err := _q.path(ctx) if err != nil { return err } _q.sql = prev } return nil } func (_q *AccountQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Account, error) { var ( nodes = []*Account{} _spec = _q.querySpec() loadedTypes = [24]bool{ _q.withSessions != nil, _q.withEmails != nil, _q.withNotifications != nil, _q.withTriggeredNotifications != nil, _q.withFollowing != nil, _q.withFollowedBy != nil, _q.withInvitations != nil, _q.withInvitedBy != nil, _q.withPosts != nil, _q.withQuestions != nil, _q.withReacts != nil, _q.withLikes != nil, _q.withMentions != nil, _q.withRoles != nil, _q.withAuthentication != nil, _q.withTags != nil, _q.withCollections != nil, _q.withNodes != nil, _q.withAssets != nil, _q.withEvents != nil, _q.withPostReads != nil, _q.withReports != nil, _q.withHandledReports != nil, _q.withAccountRoles != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*Account).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { node := &Account{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } if len(_q.modifiers) > 0 { _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } if query := _q.withSessions; query != nil { if err := _q.loadSessions(ctx, query, nodes, func(n *Account) { n.Edges.Sessions = []*Session{} }, func(n *Account, e *Session) { n.Edges.Sessions = append(n.Edges.Sessions, e) }); err != nil { return nil, err } } if query := _q.withEmails; query != nil { if err := _q.loadEmails(ctx, query, nodes, func(n *Account) { n.Edges.Emails = []*Email{} }, func(n *Account, e *Email) { n.Edges.Emails = append(n.Edges.Emails, e) }); err != nil { return nil, err } } if query := _q.withNotifications; query != nil { if err := _q.loadNotifications(ctx, query, nodes, func(n *Account) { n.Edges.Notifications = []*Notification{} }, func(n *Account, e *Notification) { n.Edges.Notifications = append(n.Edges.Notifications, e) }); err != nil { return nil, err } } if query := _q.withTriggeredNotifications; query != nil { if err := _q.loadTriggeredNotifications(ctx, query, nodes, func(n *Account) { n.Edges.TriggeredNotifications = []*Notification{} }, func(n *Account, e *Notification) { n.Edges.TriggeredNotifications = append(n.Edges.TriggeredNotifications, e) }); err != nil { return nil, err } } if query := _q.withFollowing; query != nil { if err := _q.loadFollowing(ctx, query, nodes, func(n *Account) { n.Edges.Following = []*AccountFollow{} }, func(n *Account, e *AccountFollow) { n.Edges.Following = append(n.Edges.Following, e) }); err != nil { return nil, err } } if query := _q.withFollowedBy; query != nil { if err := _q.loadFollowedBy(ctx, query, nodes, func(n *Account) { n.Edges.FollowedBy = []*AccountFollow{} }, func(n *Account, e *AccountFollow) { n.Edges.FollowedBy = append(n.Edges.FollowedBy, e) }); err != nil { return nil, err } } if query := _q.withInvitations; query != nil { if err := _q.loadInvitations(ctx, query, nodes, func(n *Account) { n.Edges.Invitations = []*Invitation{} }, func(n *Account, e *Invitation) { n.Edges.Invitations = append(n.Edges.Invitations, e) }); err != nil { return nil, err } } if query := _q.withInvitedBy; query != nil { if err := _q.loadInvitedBy(ctx, query, nodes, nil, func(n *Account, e *Invitation) { n.Edges.InvitedBy = e }); err != nil { return nil, err } } if query := _q.withPosts; query != nil { if err := _q.loadPosts(ctx, query, nodes, func(n *Account) { n.Edges.Posts = []*Post{} }, func(n *Account, e *Post) { n.Edges.Posts = append(n.Edges.Posts, e) }); err != nil { return nil, err } } if query := _q.withQuestions; query != nil { if err := _q.loadQuestions(ctx, query, nodes, func(n *Account) { n.Edges.Questions = []*Question{} }, func(n *Account, e *Question) { n.Edges.Questions = append(n.Edges.Questions, e) }); err != nil { return nil, err } } if query := _q.withReacts; query != nil { if err := _q.loadReacts(ctx, query, nodes, func(n *Account) { n.Edges.Reacts = []*React{} }, func(n *Account, e *React) { n.Edges.Reacts = append(n.Edges.Reacts, e) }); err != nil { return nil, err } } if query := _q.withLikes; query != nil { if err := _q.loadLikes(ctx, query, nodes, func(n *Account) { n.Edges.Likes = []*LikePost{} }, func(n *Account, e *LikePost) { n.Edges.Likes = append(n.Edges.Likes, e) }); err != nil { return nil, err } } if query := _q.withMentions; query != nil { if err := _q.loadMentions(ctx, query, nodes, func(n *Account) { n.Edges.Mentions = []*MentionProfile{} }, func(n *Account, e *MentionProfile) { n.Edges.Mentions = append(n.Edges.Mentions, e) }); err != nil { return nil, err } } if query := _q.withRoles; query != nil { if err := _q.loadRoles(ctx, query, nodes, func(n *Account) { n.Edges.Roles = []*Role{} }, func(n *Account, e *Role) { n.Edges.Roles = append(n.Edges.Roles, e) }); err != nil { return nil, err } } if query := _q.withAuthentication; query != nil { if err := _q.loadAuthentication(ctx, query, nodes, func(n *Account) { n.Edges.Authentication = []*Authentication{} }, func(n *Account, e *Authentication) { n.Edges.Authentication = append(n.Edges.Authentication, e) }); err != nil { return nil, err } } if query := _q.withTags; query != nil { if err := _q.loadTags(ctx, query, nodes, func(n *Account) { n.Edges.Tags = []*Tag{} }, func(n *Account, e *Tag) { n.Edges.Tags = append(n.Edges.Tags, e) }); err != nil { return nil, err } } if query := _q.withCollections; query != nil { if err := _q.loadCollections(ctx, query, nodes, func(n *Account) { n.Edges.Collections = []*Collection{} }, func(n *Account, e *Collection) { n.Edges.Collections = append(n.Edges.Collections, e) }); err != nil { return nil, err } } if query := _q.withNodes; query != nil { if err := _q.loadNodes(ctx, query, nodes, func(n *Account) { n.Edges.Nodes = []*Node{} }, func(n *Account, e *Node) { n.Edges.Nodes = append(n.Edges.Nodes, e) }); err != nil { return nil, err } } if query := _q.withAssets; query != nil { if err := _q.loadAssets(ctx, query, nodes, func(n *Account) { n.Edges.Assets = []*Asset{} }, func(n *Account, e *Asset) { n.Edges.Assets = append(n.Edges.Assets, e) }); err != nil { return nil, err } } if query := _q.withEvents; query != nil { if err := _q.loadEvents(ctx, query, nodes, func(n *Account) { n.Edges.Events = []*EventParticipant{} }, func(n *Account, e *EventParticipant) { n.Edges.Events = append(n.Edges.Events, e) }); err != nil { return nil, err } } if query := _q.withPostReads; query != nil { if err := _q.loadPostReads(ctx, query, nodes, func(n *Account) { n.Edges.PostReads = []*PostRead{} }, func(n *Account, e *PostRead) { n.Edges.PostReads = append(n.Edges.PostReads, e) }); err != nil { return nil, err } } if query := _q.withReports; query != nil { if err := _q.loadReports(ctx, query, nodes, func(n *Account) { n.Edges.Reports = []*Report{} }, func(n *Account, e *Report) { n.Edges.Reports = append(n.Edges.Reports, e) }); err != nil { return nil, err } } if query := _q.withHandledReports; query != nil { if err := _q.loadHandledReports(ctx, query, nodes, func(n *Account) { n.Edges.HandledReports = []*Report{} }, func(n *Account, e *Report) { n.Edges.HandledReports = append(n.Edges.HandledReports, e) }); err != nil { return nil, err } } if query := _q.withAccountRoles; query != nil { if err := _q.loadAccountRoles(ctx, query, nodes, func(n *Account) { n.Edges.AccountRoles = []*AccountRoles{} }, func(n *Account, e *AccountRoles) { n.Edges.AccountRoles = append(n.Edges.AccountRoles, e) }); err != nil { return nil, err } } return nodes, nil } func (_q *AccountQuery) loadSessions(ctx context.Context, query *SessionQuery, nodes []*Account, init func(*Account), assign func(*Account, *Session)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(session.FieldAccountID) } query.Where(predicate.Session(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.SessionsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadEmails(ctx context.Context, query *EmailQuery, nodes []*Account, init func(*Account), assign func(*Account, *Email)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(email.FieldAccountID) } query.Where(predicate.Email(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.EmailsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountID if fk == nil { return fmt.Errorf(`foreign-key "account_id" is nil for node %v`, n.ID) } node, ok := nodeids[*fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_id" returned %v for node %v`, *fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadNotifications(ctx context.Context, query *NotificationQuery, nodes []*Account, init func(*Account), assign func(*Account, *Notification)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(notification.FieldOwnerAccountID) } query.Where(predicate.Notification(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.NotificationsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.OwnerAccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "owner_account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadTriggeredNotifications(ctx context.Context, query *NotificationQuery, nodes []*Account, init func(*Account), assign func(*Account, *Notification)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(notification.FieldSourceAccountID) } query.Where(predicate.Notification(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.TriggeredNotificationsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.SourceAccountID if fk == nil { return fmt.Errorf(`foreign-key "source_account_id" is nil for node %v`, n.ID) } node, ok := nodeids[*fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "source_account_id" returned %v for node %v`, *fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadFollowing(ctx context.Context, query *AccountFollowQuery, nodes []*Account, init func(*Account), assign func(*Account, *AccountFollow)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(accountfollow.FieldFollowerAccountID) } query.Where(predicate.AccountFollow(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.FollowingColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.FollowerAccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "follower_account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadFollowedBy(ctx context.Context, query *AccountFollowQuery, nodes []*Account, init func(*Account), assign func(*Account, *AccountFollow)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(accountfollow.FieldFollowingAccountID) } query.Where(predicate.AccountFollow(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.FollowedByColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.FollowingAccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "following_account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadInvitations(ctx context.Context, query *InvitationQuery, nodes []*Account, init func(*Account), assign func(*Account, *Invitation)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(invitation.FieldCreatorAccountID) } query.Where(predicate.Invitation(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.InvitationsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.CreatorAccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "creator_account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadInvitedBy(ctx context.Context, query *InvitationQuery, nodes []*Account, init func(*Account), assign func(*Account, *Invitation)) error { ids := make([]xid.ID, 0, len(nodes)) nodeids := make(map[xid.ID][]*Account) for i := range nodes { if nodes[i].InvitedByID == nil { continue } fk := *nodes[i].InvitedByID if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } nodeids[fk] = append(nodeids[fk], nodes[i]) } if len(ids) == 0 { return nil } query.Where(invitation.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { return fmt.Errorf(`unexpected foreign-key "invited_by_id" returned %v`, n.ID) } for i := range nodes { assign(nodes[i], n) } } return nil } func (_q *AccountQuery) loadPosts(ctx context.Context, query *PostQuery, nodes []*Account, init func(*Account), assign func(*Account, *Post)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(post.FieldAccountPosts) } query.Where(predicate.Post(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.PostsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountPosts node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_posts" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadQuestions(ctx context.Context, query *QuestionQuery, nodes []*Account, init func(*Account), assign func(*Account, *Question)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(question.FieldAccountID) } query.Where(predicate.Question(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.QuestionsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadReacts(ctx context.Context, query *ReactQuery, nodes []*Account, init func(*Account), assign func(*Account, *React)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(react.FieldAccountID) } query.Where(predicate.React(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.ReactsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadLikes(ctx context.Context, query *LikePostQuery, nodes []*Account, init func(*Account), assign func(*Account, *LikePost)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(likepost.FieldAccountID) } query.Where(predicate.LikePost(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.LikesColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadMentions(ctx context.Context, query *MentionProfileQuery, nodes []*Account, init func(*Account), assign func(*Account, *MentionProfile)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(mentionprofile.FieldAccountID) } query.Where(predicate.MentionProfile(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.MentionsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadRoles(ctx context.Context, query *RoleQuery, nodes []*Account, init func(*Account), assign func(*Account, *Role)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[xid.ID]*Account) nids := make(map[xid.ID]map[*Account]struct{}) for i, node := range nodes { edgeIDs[i] = node.ID byID[node.ID] = node if init != nil { init(node) } } query.Where(func(s *sql.Selector) { joinT := sql.Table(account.RolesTable) s.Join(joinT).On(s.C(role.FieldID), joinT.C(account.RolesPrimaryKey[0])) s.Where(sql.InValues(joinT.C(account.RolesPrimaryKey[1]), edgeIDs...)) columns := s.SelectedColumns() s.Select(joinT.C(account.RolesPrimaryKey[1])) s.AppendSelect(columns...) s.SetDistinct(false) }) if err := query.prepareQuery(ctx); err != nil { return err } qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { assign := spec.Assign values := spec.ScanValues spec.ScanValues = func(columns []string) ([]any, error) { values, err := values(columns[1:]) if err != nil { return nil, err } return append([]any{new(xid.ID)}, values...), nil } spec.Assign = func(columns []string, values []any) error { outValue := *values[0].(*xid.ID) inValue := *values[1].(*xid.ID) if nids[inValue] == nil { nids[inValue] = map[*Account]struct{}{byID[outValue]: {}} return assign(columns[1:], values[1:]) } nids[inValue][byID[outValue]] = struct{}{} return nil } }) }) neighbors, err := withInterceptors[[]*Role](ctx, query, qr, query.inters) if err != nil { return err } for _, n := range neighbors { nodes, ok := nids[n.ID] if !ok { return fmt.Errorf(`unexpected "roles" node returned %v`, n.ID) } for kn := range nodes { assign(kn, n) } } return nil } func (_q *AccountQuery) loadAuthentication(ctx context.Context, query *AuthenticationQuery, nodes []*Account, init func(*Account), assign func(*Account, *Authentication)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(authentication.FieldAccountAuthentication) } query.Where(predicate.Authentication(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.AuthenticationColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountAuthentication node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_authentication" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadTags(ctx context.Context, query *TagQuery, nodes []*Account, init func(*Account), assign func(*Account, *Tag)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[xid.ID]*Account) nids := make(map[xid.ID]map[*Account]struct{}) for i, node := range nodes { edgeIDs[i] = node.ID byID[node.ID] = node if init != nil { init(node) } } query.Where(func(s *sql.Selector) { joinT := sql.Table(account.TagsTable) s.Join(joinT).On(s.C(tag.FieldID), joinT.C(account.TagsPrimaryKey[1])) s.Where(sql.InValues(joinT.C(account.TagsPrimaryKey[0]), edgeIDs...)) columns := s.SelectedColumns() s.Select(joinT.C(account.TagsPrimaryKey[0])) s.AppendSelect(columns...) s.SetDistinct(false) }) if err := query.prepareQuery(ctx); err != nil { return err } qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { assign := spec.Assign values := spec.ScanValues spec.ScanValues = func(columns []string) ([]any, error) { values, err := values(columns[1:]) if err != nil { return nil, err } return append([]any{new(xid.ID)}, values...), nil } spec.Assign = func(columns []string, values []any) error { outValue := *values[0].(*xid.ID) inValue := *values[1].(*xid.ID) if nids[inValue] == nil { nids[inValue] = map[*Account]struct{}{byID[outValue]: {}} return assign(columns[1:], values[1:]) } nids[inValue][byID[outValue]] = struct{}{} return nil } }) }) neighbors, err := withInterceptors[[]*Tag](ctx, query, qr, query.inters) if err != nil { return err } for _, n := range neighbors { nodes, ok := nids[n.ID] if !ok { return fmt.Errorf(`unexpected "tags" node returned %v`, n.ID) } for kn := range nodes { assign(kn, n) } } return nil } func (_q *AccountQuery) loadCollections(ctx context.Context, query *CollectionQuery, nodes []*Account, init func(*Account), assign func(*Account, *Collection)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } query.withFKs = true query.Where(predicate.Collection(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.CollectionsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.account_collections if fk == nil { return fmt.Errorf(`foreign-key "account_collections" is nil for node %v`, n.ID) } node, ok := nodeids[*fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_collections" returned %v for node %v`, *fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadNodes(ctx context.Context, query *NodeQuery, nodes []*Account, init func(*Account), assign func(*Account, *Node)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(node.FieldAccountID) } query.Where(predicate.Node(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.NodesColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadAssets(ctx context.Context, query *AssetQuery, nodes []*Account, init func(*Account), assign func(*Account, *Asset)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(asset.FieldAccountID) } query.Where(predicate.Asset(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.AssetsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadEvents(ctx context.Context, query *EventParticipantQuery, nodes []*Account, init func(*Account), assign func(*Account, *EventParticipant)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(eventparticipant.FieldAccountID) } query.Where(predicate.EventParticipant(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.EventsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadPostReads(ctx context.Context, query *PostReadQuery, nodes []*Account, init func(*Account), assign func(*Account, *PostRead)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(postread.FieldAccountID) } query.Where(predicate.PostRead(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.PostReadsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadReports(ctx context.Context, query *ReportQuery, nodes []*Account, init func(*Account), assign func(*Account, *Report)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(report.FieldReportedByID) } query.Where(predicate.Report(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.ReportsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.ReportedByID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "reported_by_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadHandledReports(ctx context.Context, query *ReportQuery, nodes []*Account, init func(*Account), assign func(*Account, *Report)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(report.FieldHandledByID) } query.Where(predicate.Report(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.HandledReportsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.HandledByID if fk == nil { return fmt.Errorf(`foreign-key "handled_by_id" is nil for node %v`, n.ID) } node, ok := nodeids[*fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "handled_by_id" returned %v for node %v`, *fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) loadAccountRoles(ctx context.Context, query *AccountRolesQuery, nodes []*Account, init func(*Account), assign func(*Account, *AccountRoles)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] if init != nil { init(nodes[i]) } } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(accountroles.FieldAccountID) } query.Where(predicate.AccountRoles(func(s *sql.Selector) { s.Where(sql.InValues(s.C(account.AccountRolesColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { fk := n.AccountID node, ok := nodeids[fk] if !ok { return fmt.Errorf(`unexpected referenced foreign-key "account_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } return nil } func (_q *AccountQuery) sqlCount(ctx context.Context) (int, error) { _spec := _q.querySpec() if len(_q.modifiers) > 0 { _spec.Modifiers = _q.modifiers } _spec.Node.Columns = _q.ctx.Fields if len(_q.ctx.Fields) > 0 { _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } return sqlgraph.CountNodes(ctx, _q.driver, _spec) } func (_q *AccountQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(account.Table, account.Columns, sqlgraph.NewFieldSpec(account.FieldID, field.TypeString)) _spec.From = _q.sql if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique } else if _q.path != nil { _spec.Unique = true } if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, account.FieldID) for i := range fields { if fields[i] != account.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } if _q.withInvitedBy != nil { _spec.Node.AddColumnOnce(account.FieldInvitedByID) } } if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } return _spec } func (_q *AccountQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(account.Table) columns := _q.ctx.Fields if len(columns) == 0 { columns = account.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) if _q.sql != nil { selector = _q.sql selector.Select(selector.Columns(columns...)...) } if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } for _, m := range _q.modifiers { m(selector) } for _, p := range _q.predicates { p(selector) } for _, p := range _q.order { p(selector) } if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector } // Modify adds a query modifier for attaching custom logic to queries. func (_q *AccountQuery) Modify(modifiers ...func(s *sql.Selector)) *AccountSelect { _q.modifiers = append(_q.modifiers, modifiers...) return _q.Select() } // AccountGroupBy is the group-by builder for Account entities. type AccountGroupBy struct { selector build *AccountQuery } // Aggregate adds the given aggregation functions to the group-by query. func (_g *AccountGroupBy) Aggregate(fns ...AggregateFunc) *AccountGroupBy { _g.fns = append(_g.fns, fns...) return _g } // Scan applies the selector query and scans the result into the given value. func (_g *AccountGroupBy) Scan(ctx context.Context, v any) error { ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) if err := _g.build.prepareQuery(ctx); err != nil { return err } return scanWithInterceptors[*AccountQuery, *AccountGroupBy](ctx, _g.build, _g, _g.build.inters, v) } func (_g *AccountGroupBy) sqlScan(ctx context.Context, root *AccountQuery, v any) error { selector := root.sqlQuery(ctx).Select() aggregation := make([]string, 0, len(_g.fns)) for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) } // AccountSelect is the builder for selecting fields of Account entities. type AccountSelect struct { *AccountQuery selector } // Aggregate adds the given aggregation functions to the selector query. func (_s *AccountSelect) Aggregate(fns ...AggregateFunc) *AccountSelect { _s.fns = append(_s.fns, fns...) return _s } // Scan applies the selector query and scans the result into the given value. func (_s *AccountSelect) Scan(ctx context.Context, v any) error { ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) if err := _s.prepareQuery(ctx); err != nil { return err } return scanWithInterceptors[*AccountQuery, *AccountSelect](ctx, _s.AccountQuery, _s, _s.inters, v) } func (_s *AccountSelect) sqlScan(ctx context.Context, root *AccountQuery, v any) error { selector := root.sqlQuery(ctx) aggregation := make([]string, 0, len(_s.fns)) for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: selector.AppendSelect(aggregation...) } rows := &sql.Rows{} query, args := selector.Query() if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) } // Modify adds a query modifier for attaching custom logic to queries. func (_s *AccountSelect) Modify(modifiers ...func(s *sql.Selector)) *AccountSelect { _s.modifiers = append(_s.modifiers, modifiers...) return _s }

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