Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count of items returned for a specific query #46

Open
jirzi0 opened this issue Jul 21, 2020 · 3 comments
Open

Count of items returned for a specific query #46

jirzi0 opened this issue Jul 21, 2020 · 3 comments
Assignees

Comments

@jirzi0
Copy link
Contributor

jirzi0 commented Jul 21, 2020

Is your feature request related to a problem? Please describe.
Implementing pagination using skip & limit, only total resource count is available though (to my knowlage at least).
Describe the solution you'd like
It would feel more graceful on the frontend side if a total of items returned by specific query was also provided.
Describe alternatives you've considered
It's all right, I just check for an empty array to come and stop there...

@zjttoefs
Copy link
Member

@henrikjohansson712 is that not part of the default loopback functionality? If yes, we should add this to the documentation.

@henrikjohansson712
Copy link
Collaborator

The count endpoints have support for the "where" part of the filter, e.g, if you send a request to GET /documents with the filter:

{
  "where": {
    "type": "publication"
  },
  "include": [
    {
      "relation": "datasets",
      "scope": {
        "include": [
          {
            "relation": "techniques",
            "scope": {
              "where": {
                "name": "small-angle neutron scattering"
              }
            }
          }
        ]
      }
    }
  ]
}

then the GET /documents/count query filter would be:

{
  "type":"publication"
}

which would give you all documents of type publication.

So the functionality of the count endpoints is limited, at least when it comes to queries where you filter on related models.

The count endpoints documentation states that they only accept a where query, but maybe it needs some clarification?

@jirzi0
Copy link
Contributor Author

jirzi0 commented Jun 30, 2021

Bumping this issue. Thanks for the clarification. Obviously it would be great if the count also took account for the include key query stuff as at is quite a limitation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants