Skip to content

Commit

Permalink
(fga-eps-mds/2023-1-CAPJu-Doc#122) - Aumenta cobertura
Browse files Browse the repository at this point in the history
Co-authored-by: OscarDeBrito <[email protected]>
Co-authored-by: YanWerlley <[email protected]>
  • Loading branch information
3 people committed Jul 3, 2023
1 parent 651bfe2 commit 043210a
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/utils/filters.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import { Op } from "sequelize";

export function filterByNicknameAndRecord(req) {
const { filter } = req.query;
return filter
return req.query.filter
? {
[Op.or]: [
{ record: { [Op.like]: `%${filter}%` } },
{ nickname: { [Op.like]: `%${filter}%` } },
{ record: { [Op.like]: `%${req.query.filter}%` } },
{ nickname: { [Op.like]: `%${req.query.filter}%` } },
],
}
: {};
}

export function filterByName(req) {
const { filter } = req.query;
return filter
return req.query.filter
? {
[Op.or]: [{ name: { [Op.like]: `%${filter}%` } }],
[Op.or]: [{ name: { [Op.like]: `%${req.query.filter}%` } }],
}
: {};
}

export function filterByFullName(req) {
const { filter } = req.query;
return filter
return req.query.filter
? {
[Op.or]: [{ fullName: { [Op.like]: `%${filter}%` } }],
[Op.or]: [{ fullName: { [Op.like]: `%${req.query.filter}%` } }],
}
: {};
}

0 comments on commit 043210a

Please sign in to comment.