Search on relationship fields by default

By default, the search is performed only on the classic columns of your table and does not take into account the belongsTo fields.

You usually have the possibility to click on Try an extended search to extend the search to belongsTo fields in a second step.

But you can as well extend Forest Admin's default routes to use the extended search by default.


  • An admin backend running on forest-express-sequelize

How it works

Directory: /routes

This directory contains the customers.js file where the model is declared.

You will have to update the routes that get the list but also the count of customers.

// Get a list of Customers - Check out our documentation for more details:
router.get('/customers', permissionMiddlewareCreator.list(), (request, response, next) => {
const recordsGetter = new RecordsGetter(customers);
const params = request.query;
params.searchExtended = '1';
.then(records => recordsGetter.serialize(records))
.then(recordsSerialized => response.send(recordsSerialized))
// Get a number of Customers - Check out our documentation for more details:
router.get('/customers/count', permissionMiddlewareCreator.list(), (request, response, next) => {
const recordsCounter = new RecordsCounter(customers);
const params = request.query;
params.searchExtended = '1';
.then(count => response.send({ count }))

With this snippet, only the customers'collection would use extended search by default.

Using extended search is less performant than default search. Use this wisely.