I have following associations:
M:N relationship table
ProductCategory.hasMany(Product, { foreignKey: 'productId' });
ProductCategory.hasMany(Category, { foreignKey: 'categoryId', required: true });
Category.belongsToMany(Product, {
through: {
model: ProductCategory,
},
otherKey: 'productId',
foreignKey: 'categoryId',
});
Product.belongsToMany(Category, {
through: {
model: ProductCategory,
unique: false,
},
otherKey: 'categoryId',
foreignKey: 'productId',
});
When I invoke following method CategoryModel.findAll({ include: [ {model: ProductModel, limit: 1} ] }); I get something like this:
"Only HasMany associations support include.separate"
Anyone knows how can I handle this and limit include (many-to-many) relationship? If I remove limit everything works that's expected, I get categories with their associated products, but I want to limit products.
I will appreciate any help, regards.