> For the complete documentation index, see [llms.txt](https://kinesis-school-of-programming.gitbook.io/nestjs-unleashed/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinesis-school-of-programming.gitbook.io/nestjs-unleashed/extra-module-5-advanced-querying.md).

# Extra module 5 - Advanced Querying

A more robust mechanism to find entities.

Another aspect that could be improved is **querying**. It would be interesting if, when searching for products, for example, we could have a more robust **pagination structure**, also including a **metadata** field with useful data, such as the **total item count**.

In addition, we could also allow for **filtering** and **sorting** the results. With this improvement, we would be able to search only for products that contain a specific text fragment in their name or description, and sort them alphabetically or by price, for example.

When querying entities, these three steps occur in the following order:

* **Filtering** - From the set of all the records, criteria are used to only grab a subset of them
* **Sorting** - The elements of this subset are then arranged in some way, like alphabetically
* **Pagination** - Finally, only some elements are retrieved at once, in order to avoid a bottleneck

In this chapter, the focus will be on the aforementioned topics, implementing ways to refine the searching process and have an overall more robust querying.
