mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
Refactor combineFilters
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
parent
dc28c0e921
commit
6f1f774146
@ -21,6 +21,14 @@ const generateFileName = name => {
|
||||
return `${baseName}_${randomSuffix()}`;
|
||||
};
|
||||
|
||||
const combineFilters = params => {
|
||||
// FIXME: until we support boolean operators for querying we need to make mime_ncontains use AND instead of OR
|
||||
if (_.has(params, 'mime_ncontains') && Array.isArray(params.mime_ncontains)) {
|
||||
params._where = params.mime_ncontains.map(val => ({ mime_ncontains: val }));
|
||||
delete params.mime_ncontains;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
formatFileInfo({ filename, type, size }, fileInfo = {}, metas = {}) {
|
||||
const ext = path.extname(filename);
|
||||
@ -250,12 +258,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
fetchAll(params) {
|
||||
// FIXME: until we support boolean operators for querying we need to make mime_ncontains use AND instead of OR
|
||||
if (_.has(params, 'mime_ncontains') && Array.isArray(params.mime_ncontains)) {
|
||||
params._where = params.mime_ncontains.map(val => ({ mime_ncontains: val }));
|
||||
delete params.mime_ncontains;
|
||||
}
|
||||
|
||||
combineFilters(params);
|
||||
return strapi.query('file', 'upload').find(params);
|
||||
},
|
||||
|
||||
@ -268,12 +271,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
count(params) {
|
||||
// FIXME: until we support boolean operators for querying we need to make mime_ncontains use AND instead of OR
|
||||
if (_.has(params, 'mime_ncontains') && Array.isArray(params.mime_ncontains)) {
|
||||
params._where = params.mime_ncontains.map(val => ({ mime_ncontains: val }));
|
||||
delete params.mime_ncontains;
|
||||
}
|
||||
|
||||
combineFilters(params);
|
||||
return strapi.query('file', 'upload').count(params);
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user