Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/educata/everrest
Browse files Browse the repository at this point in the history
  • Loading branch information
KostaD02 committed Jun 14, 2024
2 parents 9f76144 + 10ca523 commit 0d316f4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/modules/shop/product/products.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ export class ProductsService {
} = {};

if (query.keywords) {
queryObject.title = { $regex: query.keywords, $options: 'i' };
const keywordsArray = query.keywords.split(' ');
const regexPattern = keywordsArray
.map((keyword) => `(?=.*${keyword})`)
.join('');
queryObject.title = { $regex: regexPattern, $options: 'i' };
}
if (query.category_id) {
queryObject['category.id'] = query.category_id;
Expand Down

0 comments on commit 0d316f4

Please sign in to comment.