Last updated: 2023-09-19

  1. Learn
  2. Next Steps
  3. Extending Search Filter

How to extend the search filter

In the Professional plan the search filter option can be activated for entities with CRUD functionality, allowing to limit the list to the matching entries. In addition to the controller and service code, initially there is a simple query for the primary key in the repository. How can we extend our filter with more fields?

Initial filter logic in the TodoListService - integrated into the frontend and the REST API

To extend the functionality of the filter, we can simply adjust the query. With the following code we additionally filter for the name of our TodoList. Only a part of the name has to match.

Extension of our query with a like clause for the name field

For MongoDB the query looks slightly different to get the same result.

Adjustment of our query for MongoDB

In addition to the service, the query within the repository must also be adapted. If there are a lot of records in our table, it is a good idea to add an index suitable for our database later on.