5066-vehicleSorted #1467

Merged
carlossa merged 23 commits from 5066-vehicleSorted into dev 2023-07-18 15:21:57 +00:00
1 changed files with 6 additions and 9 deletions
Showing only changes of commit 0661bf8fa9 - Show all commits

View File

@ -17,14 +17,11 @@ module.exports = Self => {
}); });
Self.sorted = async warehouseFk => { Self.sorted = async warehouseFk => {
const vehicles = await Self.rawSql(` return Self.rawSql(`
SELECT ROW_NUMBER() OVER (ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate) AS 'order', SELECT v.id, v.warehouseFk, CONCAT(v.numberPlate, ' - ', w.name) as description
v.id,
v.warehouseFk,
CONCAT(v.numberPlate, ' - ', w.name) as description
FROM vehicle v FROM vehicle v
JOIN warehouse w ON w.id = v.warehouseFk JOIN warehouse w ON w.id = v.warehouseFk
ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC`, [warehouseFk, warehouseFk]); ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC;
return vehicles; `, [warehouseFk]);
}; };
}; };