Skip to content

Instantly share code, notes, and snippets.

@aboudard
Last active November 30, 2021 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aboudard/7b5232cfbb2cae270f753184b210a9bd to your computer and use it in GitHub Desktop.
Save aboudard/7b5232cfbb2cae270f753184b210a9bd to your computer and use it in GitHub Desktop.
import { PropsFilterFnFactory, EntityMetadataMap } from '@ngrx/data';
/**
* Filter for entities whose name matches the case-insensitive pattern
* The filter works on ALL properties
* @param {T[]} entities
* @param {string} pattern
* @return {any[]}
*/
export function textFilter<T extends { title: string; description: string }>(
entities: T[],
pattern: string
) {
return PropsFilterFnFactory(['title', 'description'])(entities, pattern);
}
const entityMetadata: EntityMetadataMap = {
Todo: {
filterFn: textFilter
}
};
export const entityConfig = {
entityMetadata
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment