Last active
November 30, 2021 17:07
-
-
Save aboudard/7b5232cfbb2cae270f753184b210a9bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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