Skip to content

Commit

Permalink
Do AND of filter words for string find
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaspsycle committed Jul 3, 2022
1 parent 3c2bf69 commit 366afa6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils/convert-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ export const convertFilter = (filter) => {
switch (property.type()) {
case 'string':
return {
[property.name()]: { $regex: escape(value), $options: 'i' },
[property.name()]: { $regex: new RegExp(
value
.split(' ')
.map((word) => '(?=.*\\b' + escape(word) + '\\b)')
.join('') + '.+'
), $options: 'i' },
...memo,
}
case 'date':
Expand Down

0 comments on commit 366afa6

Please sign in to comment.