Skip to content
Snippets Groups Projects
Commit 8deefecb authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Fix id2str to work with multiqueries

parent 0cafab17
No related branches found
No related tags found
1 merge request!116Release v1.0.0
Pipeline #
......@@ -64,8 +64,25 @@ function transform(removeId=false) {
};
}
function multitransform(removeId=false) {
return (req, res, next) => {
Object.keys(req.result[0]).forEach((query) => {
req.result[0][query].forEach((obj) => {
Object.keys(obj).forEach((key) => {
if(typeof ids[key] === 'undefined') return;
let id = obj[key];
obj[key.replace('_id', '_name')] = ids[key](id);
if(removeId) delete obj[key];
});
})
});
next();
}
}
module.exports = {
transform,
multitransform,
gender,
period,
schoolYear,
......
......@@ -539,6 +539,6 @@ infrastructureApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
}];
next();
}, id2str.transform(false), response('infrastructure'));
}, id2str.multitransform(false), response('infrastructure'));
module.exports = infrastructureApp;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment