2018-05-04 09:46:03 +00:00
|
|
|
module.exports = Self => {
|
2018-01-05 07:06:21 +00:00
|
|
|
Self.installMethod('filter', filterParams);
|
2017-12-04 07:17:29 +00:00
|
|
|
|
|
|
|
function filterParams(params) {
|
|
|
|
return {
|
|
|
|
where: {
|
|
|
|
clientFk: params.clientFk
|
|
|
|
},
|
|
|
|
skip: (params.page - 1) * params.size,
|
|
|
|
limit: params.size,
|
|
|
|
order: params.order || 'created DESC',
|
|
|
|
include: {
|
2018-01-29 11:37:54 +00:00
|
|
|
relation: "worker",
|
2017-12-04 07:17:29 +00:00
|
|
|
scope: {
|
2018-01-29 11:37:54 +00:00
|
|
|
fields: ["id", "firstName", "name"]
|
2017-12-04 07:17:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|