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

Fix: Pagination to consider limit value while returning response. #280

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iamvishalkhare
Copy link

@iamvishalkhare iamvishalkhare commented Jun 25, 2022

Pagination fix

Problem?
Often times in production we don't want to return all matching records instead returning a paginated response based on values of limit and offset is desirable.

What is being fixed?
Even after setting a limit value it was not working and .all() or .execute() function were returning complete set of records matching the search criterion.

How is it fixed?
To break away from loop executing the query a condition is added wherein if total number of fetched records is equal or greater than limit.

NOTE: If no limit is provided, default value i.e. 10 records will be returned. Returning all records is usually a bad idea. Take Elasticsearch or Apache solr for example where if you don't provide a limit, by default only 10 records are returned.

Problem?
Often time in production we don't want to return all matching records instead returning a paginated response based on values of limit and offset is desirable.

What is being fixed?
Even after setting a limit value it was not working and .all() or .execute() function were returning complete set of records matching the search criterion.

How is it fixed?
To break away from loop executing the query a condition is added wherein if total number of fetched records is equal or greater than limit.
If no limit is provided, default value i.e. 10 records will be returned.
@iamvishalkhare
Copy link
Author

iamvishalkhare commented Jun 25, 2022

@simonprickett - Any input will be appreciated

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

Successfully merging this pull request may close these issues.

None yet

1 participant