We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi
I want to use search an array and keep an item in the array if it or any of its children contain my search string
Example data
const data = [ { name: 'Simon', children: [{ name: 'Simon' }] }, { name: 'Ben', children: [{ name: 'Fred' }] }, ];
I tried with the following function
const filter = (searchString) => filterDeep( data, (value: any, key: string, parent: any) => { return value.toString().toLowerCase().includes(searchString.toLowerCase()); } );
filter('Simon') returns
filter('Simon')
[ { name: 'Simon', children: [{ name: 'Simon' }] }, ]
Which is what I want
filter('Fred') returns
filter('Fred')
[ { children: [{ name: 'Fred' }] }, ]
But I want
[ { name: 'Ben', children: [{ name: 'Fred' }] }, ]
When a child is found I want its parent/parents to be included in the result
Is this possible with deepdash?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi
I want to use search an array and keep an item in the array if it or any of its children contain my search string
Example data
I tried with the following function
filter('Simon')
returnsWhich is what I want
filter('Fred')
returnsBut I want
When a child is found I want its parent/parents to be included in the result
Is this possible with deepdash?
The text was updated successfully, but these errors were encountered: