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

Add count flag to Parse.Query.find #865

Closed
BufferUnderflower opened this issue Jul 16, 2019 · 3 comments · Fixed by #868
Closed

Add count flag to Parse.Query.find #865

BufferUnderflower opened this issue Jul 16, 2019 · 3 comments · Fixed by #868
Labels
type:feature New feature or improvement of existing feature

Comments

@BufferUnderflower
Copy link
Contributor

REST api supports adding &count=true.
Using JS SDK one needs to run a separate query.count() to get this number

Would be nice to have some optional flag like query.withCount(true/false) to avoid
making separate async calls

@davimacedo davimacedo added type:feature New feature or improvement of existing feature good first task labels Jul 16, 2019
@davimacedo
Copy link
Member

davimacedo commented Jul 16, 2019

I like the idea. We'd need two changes

  • In Parse Server side, to receive the additional option and return both results in the same request;
  • In JS side, to include the new option in Parse.Query.

@BufferUnderflower is this something that you would be willed to tackle?

@BufferUnderflower
Copy link
Contributor Author

@davimacedo I've read through js sdk, and stumbled upon in what form should the count be sent back to client. Since query returns the array of Parse.Objects - it's not a good idea to break current api and wrap count and objects array in another object. The only option i see so far is response header like it's done for example in wordpress api

@davimacedo
Copy link
Member

The API currently returns in the following format:

{
    "results": [ ... ]
}

We could add a count field and return in the body instead of the header.

{
    "results": [ ... ],
    "count": 30
}

dplewis pushed a commit to parse-community/docs that referenced this issue Jul 23, 2019
* Documentation for ParseQuery.withCount

See:
parse-community/Parse-SDK-JS#865
parse-community/Parse-SDK-JS#868

* added disclaimer

* remove extra line breaks

* Update _includes/js/queries.md

Co-Authored-By: Tom Fox <tomfox@surprises.io>

* Update _includes/js/queries.md

Co-Authored-By: Tom Fox <tomfox@surprises.io>

* simpler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or improvement of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants