This commit is contained in:
matteo
2019-03-03 20:16:01 +01:00
parent 3a4a0e84c7
commit 12f375afed
+12 -8
View File
@@ -80,16 +80,20 @@ low(new FileAsync(__dirname + '/db.json')) // production
}); });
const videos = db.get('videos'); const videos = db.get('videos');
if (req.query.prevId) { if (req.query.prevId) {
let tmp = videos.map(el => el.id.reason.map(el => let tmp = [];
el.reason.map(el2 => { for (let i = 0; i < videos.lenght; i++) {
if (el2.prevId === req.query.prevId) { for (let j = 0; i < videos[i].reason.lenght; j++) {
return ({ ...el2, 'id': this.id }) if (videos[i].reason[j].prevId === req.query.prevId) {
let tmp2 = {
...videos[i].reason[j],
'id': videos[i].id
}
tmp.push(tmp2);
} }
return {} }
}, el))); }
res.send(tmp) res.send(tmp)
} } else {
else {
res.send(videos) res.send(videos)
} }
}); });