Fix: Pagination to consider limit value while returning response.
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.
@simonprickett - Any input will be appreciated