Skip to content

Commit

Permalink
update: make filter case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelonah committed Jan 6, 2025
1 parent a7a6762 commit c861973
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions server/src/routes/influencer/index.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ export class InfluencerModel {
return Influencer.find().lean().exec();
}

private static insensitiseQuery(key: string, value: string | undefined) {
if (value) {
return { [key]: { $regex: value, $options: 'i' } };
}

return {};
}

public static getByNameOrManager({ firstName, lastName, managerId }: InfluencerQueryParams) {
const query = {
...(firstName && { firstName }),
...(lastName && { lastName }),
const query: Record<string, object | string> = {
...this.insensitiseQuery('firstName', firstName),
...this.insensitiseQuery('lastName', lastName),
...(managerId && { 'manager.id': managerId }),
};

Expand Down

0 comments on commit c861973

Please sign in to comment.