travopti/backend/models/getRegionById.js

19 lines
547 B
JavaScript

module.exports = async (dbConn, id) => {
const region = await dbConn.query(
`SELECT regions.id AS region_id,
regions.region AS name,
regions.description,
regions.preview_img,
regions.country_id AS country_id,
countries.country AS country,
regions.meteostat_id AS meteostat_id
FROM regions
JOIN countries
ON regions.country_id = countries.id
WHERE regions.id = ?`,
[id]
);
return region;
};