In sequalize query like findAll and findAndCountAll , how can i add association of other table without including the model in the model.js
This is my current code
const {
storeProduct,
product,
Location: locationModel,
Media, productIndex
} = require(“../db”).models;
const query = {
distinct: true,
attributes: { exclude: [“deletedAt”] },
where,
order,
where,
include: [
{
required: true,
model: locationModel,
as: “location”,
where: whereStore,
},
{
required: true,
model: product,
as: "productDetail",
},
],
};
storeProduct.hasOne(productIndex, {
foreignKey: "product_id",
sourceKey: "product_id",
as: "productIndex",
});
const storeProducts = await storeProduct.findAndCountAll(query);
Elango Ponnusamy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.