Override filtering behavior
You may want to read about the following topics before using those features:
Disabling operators
Filtering operators can be disabled one by one.
This is used mostly for performance reasons: on big collections, it can be interesting to let users filter only on fields that are indexed in your database to avoid full-table scans ↗.
collection.replaceFieldOperator('fullName', 'Equal', null);
Substitution
Operation substitution can be used for two motives:
Performance: provide a more efficient way to perform a given filtering operation
Capabilities: enable filtering on a computed field or other non-filterable fields
collection.replaceFieldOperator('fullName', 'Equal', (value, context) => {
const [firstName, ...lastNames] = value.split(' ');
return {
aggregation: 'And',
conditions: [
{ field: 'firstName', operator: 'Equal', value: firstName },
{ field: 'lastName', operator: 'Equal', value: lastNames.join(' ') },
],
};
});
Emulation
Filtering emulation allows making fields filterable automatically.
Filtering emulation performance cost is linear with the number of records in the collection. It is a convenient way to get things working quickly for collections that have a low number of records (in the thousands at most).
// Add support for all operators
collection.emulateFieldFiltering('fullName');
// Add support for a single operator
collection.emulateFieldOperator('fullName', 'Equal');
Last updated
Was this helpful?