Skip to content

Custom Nested Select Attribute? #1142

Closed

Description

@schonfeld

Say I need to fetch all users (with pagination -- offset + limit), along with a count of each user's "form" count -- in SQL, I'd do something like this:

SELECT *, (SELECT COUNT(*) FROM `Forms` WHERE UserId = Users.id) FROM `Users` LIMIT 10;

How can I achieve the same thing, using db.User.findAndCountAll({ limit: 10 }) ?

Activity

  1. mickhansen commented on Jan 7, 2014

    @mickhansen
    Contributor

    You can count users with limit. But it's not currently possible to count associations with a limit. You can however count both users and associations without a limit using some custom attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions