I’m trying to filter products by their value attributes that are in the linking table
Product => product_has_attribute => Attribute
I was only able to do OR, but I need to make a more precise filter.
Thanks for any hint!
const category = await CategoryDB.findByPk(category_id);
const products = await category.getProducts({
offset: parseInt(offset, 10),
limit: parseInt(limit, 10),
where: {
...whereClause,
},
order: [["createdAt", "DESC"]],
include: [
{
model: AttributesDB,
where: {
id: {
[Op.or]: [1, 2],
},
},
through: {
where: {
value_ua: { [Op.or]: ["Коричневий", "Середній"] },
},
attributes: ["value_ru", "value_ua"],
},
attributes: ["id", "title_ru", "title_ua", "type"],
},
],
logging: customLogger,
});
New contributor
Valerii Holovatyi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.