Ordering, Grouping & Limit
orderBy
The orderBy
method allows you to sort the result of the query by a given column. The first argument to the orderBy
method should be the column you wish to sort by, while the second argument controls the direction of the sort and may be either asc
or desc
:
If you want to order by multiple columns, you can call orderBy
multiple times.
groupBy / having
The groupBy
and having
methods may be used to group the query results. The having
method's signature is similar to that of the where
method:
take / limit
To limit the number of results returned from the query, you may use the take
method:
Alternatively, you may use the limit
method:
offset
To offset the number of results returned from the query, use the offset
method:
forPage
Combine limit
and offset
in one method. Pass the current page number and the number of results per page (limit
) and we'll calculate the rest.
Last updated