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 => {
const vehicles = await Self.rawSql(`
SELECT ROW_NUMBER() OVER (ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate) AS 'order',
v.id,
v.warehouseFk,
CONCAT(v.numberPlate, ' - ', w.name) as description
FROM vehicle v
JOIN warehouse w ON w.id = v.warehouseFk
ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC`, [warehouseFk, warehouseFk]);
return vehicles;
return Self.rawSql(`
SELECT v.id, v.warehouseFk, CONCAT(v.numberPlate, ' - ', w.name) as description
FROM vehicle v
JOIN warehouse w ON w.id = v.warehouseFk
ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC;
`, [warehouseFk]);
};
};