I have four tables: brands
, countries
, packaging_styles
, reviews
The requirement is: Write a function to find reviews for a set of brands.
NOTE1: The brands param is an array of strings - Array of brands.
NOTE2: The function should return an array of review object that match the given brands.
The query itself is tested in Postico application and it works as it should be
const getByBrands = async (brands = []) => {
const review = await pool.query('SELECT b.brand "Brand", c.country "country",\
r.id "ID", r.stars "Stars",\
s.packaging_style "Style",\
r.url "URL", r.variety "Variety"\
FROM brands b, countries c, reviews r, packaging_styles s\
WHERE r.brand_id = b.id\
AND b.brand IN ($1, $2, $3)', brands);
return review.rows;
};
getByBrands(['Koka', 'Boss', 'Peyang']);
Now what I am stuck at is I can only get records for three brands as opposed to as much as I want